macro_rules! storage_types {
($(#[$attr:meta])* $vis:vis types: $($T:ident),+; $($tt:tt)*) => { ... };
($($tt:tt)*) => { ... };
}Expand description
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.
$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,Complex32,Complex64,f32, andf64.PrimInt:usize,u8,u16,u32,u64,u128,isize,i8,i16,i32,i64, andi128.Ratio:Rational,Rational32,Rational64, andBigRational.Float:f32andf64.Signed:isize,i8,i16,i32,i64,i128,BigInt,Rational,Rational32,Rational64,BigRational,f32, andf64.Unsigned:usize,u8,u16,u32,u64,u128, andBigUint.Complex:Complex32andComplex64.
$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) {}
}