#construct #newtype #attributes #macro

macro no-std fast_new_type

A proc_macro attribute to implement common traits for a custom type wrapping other

2 releases

0.1.7 Jan 20, 2020
0.1.6 Jan 20, 2020
0.1.1 Dec 22, 2019

#11 in #attribute

31 downloads per month
Used in 3 crates (via high_mem_utils)

Unlicense

10KB
167 lines

fast_new_type

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.

Usage

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,
}

License

This code is licensed under the Unlicense.

Dependencies

~85KB