derive-to-usize

Crates.ioderive-to-usize
lib.rsderive-to-usize
version0.1.0
sourcesrc
created_at2024-06-25 03:44:56.963977
updated_at2024-06-25 03:44:56.963977
descriptionDerive for From and Into usize
homepage
repositoryhttps://github.com/abss-witch/derive-to-usize
max_upload_size
id1282937
size3,766
abyss-witch (abss-witch)

documentation

README

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
    }
}
Commit count: 2

cargo fmt