Macro uom::storage_types [−][src]
macro_rules! storage_types { ($(#[$attr:meta])* types: $($T:ident),+; $($tt:tt)*) => { ... }; ($(#[$attr:meta])* pub types: $($T:ident),+; $($tt:tt)*) => { ... }; (@types $attr:tt @$M:ident $($T:ident),+; $tt:tt) => { ... }; (@type ($(#[$attr:meta])*) @$M:ident usize ($($tt:tt)*)) => { ... }; (@type ($(#[$attr:meta])*) @$M:ident u8 ($($tt:tt)*)) => { ... }; (@type ($(#[$attr:meta])*) @$M:ident u16 ($($tt:tt)*)) => { ... }; (@type ($(#[$attr:meta])*) @$M:ident u32 ($($tt:tt)*)) => { ... }; (@type ($(#[$attr:meta])*) @$M:ident u64 ($($tt:tt)*)) => { ... }; (@type ($(#[$attr:meta])*) @$M:ident isize ($($tt:tt)*)) => { ... }; (@type ($(#[$attr:meta])*) @$M:ident i8 ($($tt:tt)*)) => { ... }; (@type ($(#[$attr:meta])*) @$M:ident i16 ($($tt:tt)*)) => { ... }; (@type ($(#[$attr:meta])*) @$M:ident i32 ($($tt:tt)*)) => { ... }; (@type ($(#[$attr:meta])*) @$M:ident i64 ($($tt:tt)*)) => { ... }; (@type ($(#[$attr:meta])*) @$M:ident BigInt ($($tt:tt)*)) => { ... }; (@type ($(#[$attr:meta])*) @$M:ident BigUint ($($tt:tt)*)) => { ... }; (@type ($(#[$attr:meta])*) @$M:ident Rational ($($tt:tt)*)) => { ... }; (@type ($(#[$attr:meta])*) @$M:ident Rational32 ($($tt:tt)*)) => { ... }; (@type ($(#[$attr:meta])*) @$M:ident Rational64 ($($tt:tt)*)) => { ... }; (@type ($(#[$attr:meta])*) @$M:ident BigRational ($($tt:tt)*)) => { ... }; (@type ($(#[$attr:meta])*) @$M:ident f32 ($($tt:tt)*)) => { ... }; (@type ($(#[$attr:meta])*) @$M:ident f64 ($($tt:tt)*)) => { ... }; (@type ($(#[$attr:meta])*) @$M:ident All ($($tt:tt)*)) => { ... }; (@type ($(#[$attr:meta])*) @$M:ident PrimInt ($($tt:tt)*)) => { ... }; (@type ($(#[$attr:meta])*) @$M:ident Ratio ($($tt:tt)*)) => { ... }; (@type ($(#[$attr:meta])*) @$M:ident Float ($($tt:tt)*)) => { ... }; (@type ($(#[$attr:meta])*) @$M:ident Signed ($($tt:tt)*)) => { ... }; (@type ($(#[$attr:meta])*) @$M:ident Unsigned ($($tt:tt)*)) => { ... }; (@mod ($(#[$attr:meta])*) $M:ident, $V:ty; ($($tt:tt)*)) => { ... }; (@pub_mod ($(#[$attr:meta])*) $M:ident, $V:ty; ($($tt:tt)*)) => { ... }; ($($tt:tt)*) => { ... }; }
Macro to duplicate code a per-storage type basis. The given code is duplicated in new modules
named for each storage type. A type alias, V
, is generated that code can use for the type.
@...
match arms are considered private.
$attr
: Module attributes. Generally used to set documentation comments for storage type modules generated by the macro.$T
: Types to generate a module for. Accepts all underlying storage types along with a number of different categories:All
:usize
,u8
,u16
,u32
,u64
,isize
,i8
,i16
,i32
,i64
,BigInt
,BigUint
,Rational
,Rational32
,Rational64
,BigRational
,f32
, andf64
.PrimInt
:usize
,u8
,u16
,u32
,u64
,isize
,i8
,i16
,i32
,i64
.Ratio
:Rational
,Rational32
,Rational64
, andBigRational
.Float
:f32
andf64
.Signed
:isize
,i8
,i16
,i32
,i64
,BigInt
,Rational
,Rational32
,Rational64
,BigRational
,f32
, andf64
.Unsigned
:usize
,u8
,u16
,u32
,u64
, andBigUint
.
$tt
: Code to place into each storage type module.
#[macro_use] extern crate uom; fn main() { f32::do_work(1.234_f32); f64::do_work(1.234_f64); } storage_types! { /// Type modules. pub types: Float; pub fn do_work(_v: V) {} }