1 unstable release

Uses old Rust 2015

0.1.0 May 26, 2018

#17 in #eq

GPL-3.0 license

14KB

this is macro try_enum!

e.g.:

=======================

#[derive(Eq,PartialEq)]
enum A<'a> {
    Bar(i32),
    Foo(&'a str),
}
let a=A::Bar(12);
assert_eq!(try_enum!(a,A::Bar),Some(12));
assert_eq!(try_enum!(a,A::Foo),None);
let a_foo=A::Foo("123");
assert_eq!(try_enum!(a_foo,A::Foo),Some("123"));
#[derive(Eq,PartialEq)]
enum B<'a> {
    Bar{a:A<'a>,b:i32},
    Foo(&'a str),
}
let b=B::Bar{a:A::Bar(12),b:14};
assert_eq!(try_enum!(&b,B::Bar[a],A::Bar),Some(&12));
assert_eq!(try_enum!(b,B::Foo),None);
let b_foo=B::Foo("123");
assert_eq!(try_enum!(b_foo,B::Foo),Some("123"));

No runtime deps