Skip to main content

storage_types

Macro storage_types 

Source
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, 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.
    • Complex: Complex32 and Complex64.
  • $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) {}
}