I have this code, where XYBin
is a superset of Bin
:
impl Into<Bin> for XYBin {
fn into(self) -> Bin {
Bin {
packets_tx: self.packets_tx,
octets_tx: self.octets_tx,
packets_rx: self.packets_tx,
octets_rx: self.octets_rx,
packets_rx_on_only: self.packets_rx_on_only,
octets_rx_on_only: self.octets_rx_on_only,
packets_rx_on: self.packets_rx_on,
octets_rx_on: self.octets_rx_on
}
}
}
Is there a way of using punning, or another approach (except macros) to reduce the repetitive code?
What I had before was:
After reading ColonelThirtyTwo's comment, I now have: