Closed zpzigi754 closed 2 weeks ago
There is a feature called Structural
that can be used to make this work:
#[derive(Structural, PartialEq, Clone, Copy)]
pub enum Fruits {
APPLE,
BANANA,
}
pub struct Meal {
pub fruit: Fruits,
}
impl Meal {
fn test(&self) {
if self.fruit == Fruits::BANANA {
}
}
}
I guess we need to add documentation on this, and perhaps also update the error message to hint at using Structural
.
Thank you for the suggestion of using Structural
! I've also confirmed that the test code works with Structural
.
I tried the below code where an equality operator is used for an enum type.
It failed with the following error.
I've confirmed that using
match
orif let
(the same semantic) works well.