thin_newtype

Macro thin_newtype 

Source
macro_rules! thin_newtype {
    ($name:ident, $inner:ty) => { ... };
    ($name:ident, $inner:ty, derives: [ $( $derive:ident ),* $(,)? ]) => { ... };
}
Expand description

Thin wrapper that derefs to the inner type.

By default the wrapper derives a common set of traits (Debug, Clone, Copy, …). You can optionally provide an extra list of derives - e.g. Add, Sub, FromStr, or any custom derive - by writing:

use derive_more::{Add, Sub};
thin_newtype!(MyInt, i32, derives: [Add, Sub]);

(you’ll need the corresponding crates - e.g. derive_more for Add, Sub).