pub trait EnumConst: Sized {
// Required methods
fn get_const_isize(&self) -> Option<isize>;
fn from_const_isize(i: isize) -> Option<Self>;
}
Expand description
example:
use enum_const::EnumConst;
#[derive(EnumConst, PartialEq, Debug)]
enum Foo {
X = 1,
Y = 2,
Z,
}
#[test]
fn it_works() {
assert_eq!(Some(Foo::X), Foo::from_const_isize(1));
assert_eq!(Some(1isize), Foo::X.get_const_isize());
}
Required Methods§
fn get_const_isize(&self) -> Option<isize>
fn from_const_isize(i: isize) -> Option<Self>
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.