1 unstable release
0.1.0 | Jun 25, 2024 |
---|
#17 in #into
78 downloads per month
3KB
Derive for From and Into usize.
use derive_into::ToUsize;
#[derive(ToUsize)]
enum Foo {
Bar,
E
}
assert_eq!(0_usize, Foo::Bar.into());
assert_eq!(1_usize, Foo::E.into());
Same as:
enum Foo {
Bar,
E
}
impl From<Foo> for usize {
fn from(value: Foo) -> usize {
Foo as usize
}
}
lib.rs
:
Derive for From and Into usize
use derive_into::ToUsize;
#[derive(ToUsize)]
enum Foo {
Bar,
E
}
assert_eq!(0_usize, Foo::Bar.into());
assert_eq!(1_usize, Foo::E.into());
Dependencies
~240–680KB
~16K SLoC