Crates.io | fast_new_type |
lib.rs | fast_new_type |
version | 0.1.7 |
source | src |
created_at | 2019-12-22 06:12:03.238429 |
updated_at | 2020-01-20 09:56:44.948609 |
description | A proc_macro attribute to implement common traits for a custom type wrapping other. |
homepage | |
repository | https://github.com/NonNullableName/fast_new_type/ |
max_upload_size | |
id | 191398 |
size | 10,793 |
This crate serves the purporse of implement Deref
,DerefMut
,AsRef
,AsMut
and From
in new
types,either for the first value of a struct,the "value" or "slot" field or the specified in the attribute.
With default-features = false
you can opt-out of the From
impl which in some cases is not desirable.
This crate is no_std.
use fast_new_type::new_type;
#[new_type]
struct FirstField(u32, u16);
#[new_type]
struct ValueField {
value: u16,
other_meta: u16,
}
#[new_type]
struct SlotField {
slot: u16,
other_meta: u16,
}
#[new_type(other)]
struct SpecField {
other: u16,
other_meta: u16,
}
This code is licensed under the Unlicense.