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 u128 ($($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 i128 ($($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 on 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, u128, isize, i8, i16, i32, i64,
i128, BigInt, BigUint, Rational, Rational32, Rational64, BigRational, f32,
and f64.
PrimInt: usize, u8, u16, u32, u64, u128, isize, i8, i16, i32, i64,
and i128.
Ratio: Rational, Rational32, Rational64, and BigRational.
Float: f32 and f64.
Signed: isize, i8, i16, i32, i64, i128, BigInt, Rational, Rational32,
Rational64, BigRational, f32, and f64.
Unsigned: usize, u8, u16, u32, u64, u128, and BigUint.
$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! {
pub types: Float;
pub fn do_work(_v: V) {}
}