BitAndAssign

The BitAndAssign trait enables the &= operator for data types that implement it.

Implementing BitAndAssign looks like this:

pub enum BitExample {
Yes,
No,
}

impl BitAndAssign for BitExample {
fn bitand_assign(&mut self, other: BitExample) {
*self = match (&self, other) {
(BitExample::Yes, BitExample::Yes) => BitExample::Yes,
(BitExample::No, BitExample::Yes) => BitExample::No,
(BitExample::Yes, BitExample::No) => BitExample::No,

            (BitExample::No, BitExample::No) => BitExample::No,
};
}
}
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
52.15.129.253