Crates.io | derive-to-usize |
lib.rs | derive-to-usize |
version | 0.1.0 |
source | src |
created_at | 2024-06-25 03:44:56.963977 |
updated_at | 2024-06-25 03:44:56.963977 |
description | Derive for From and Into usize |
homepage | |
repository | https://github.com/abss-witch/derive-to-usize |
max_upload_size | |
id | 1282937 |
size | 3,766 |
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
}
}