Skip to content

Instantly share code, notes, and snippets.

@matthewjberger
Created May 22, 2023 20:18
Show Gist options
  • Save matthewjberger/5a5ced920d4018cb0643550e75627b3d to your computer and use it in GitHub Desktop.
Save matthewjberger/5a5ced920d4018cb0643550e75627b3d to your computer and use it in GitHub Desktop.
#[derive(Debug, PartialEq, Eq)]
enum MyEnum {
Variant1(i32),
Variant2(String),
}
fn main() {
let a = MyEnum::Variant1(5);
let b = MyEnum::Variant1(5);
assert_eq!(a.eq(&b), true);
let c = MyEnum::Variant1(10);
assert_eq!(a.eq(&c), false);
let d = MyEnum::Variant2("Hello".into());
let e = MyEnum::Variant2("Hello".into());
assert_eq!(d.eq(&e), true);
let f = MyEnum::Variant2("World".into());
assert_eq!(d.eq(&f), false);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment