Expand description
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.
§Examples
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,
}
Attribute Macros§
- new_
type - Implement common traits in a wrapper for a type,with the specifie field as arg where needed.