Eq

The Eq trait means the same thing that PartialEq does, except that a data value is always equal to itself.

Implementing the Eq trait requires implementing the PartialEq trait as well, and the only thing it does beyond what PartialEq does is provide the compiler with the hint that it doesn't need to bother running the Eq function when both sides of the comparison are the same data value.

Deriving Eq looks like this:

#[derive(Eq, PartialEq)]
pub enum EqExample {
Good,
Bad,
}
..................Content has been hidden....................

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