[][src]Macro generic_modular::def_modular

macro_rules! def_modular {
    ($name:ident : $int:ty | $sint:ty, $mod:expr ; $label:ident $(#[$docs:meta])*) => { ... };
}

This macro generates a struct that implements Modular.

See ExampleModular101 for an example of what is generated.

Parameters

  • $name is the name of the struct to be generated.
  • $int is the type of integer to work with. It must be one of u8, u16, u32, u64 or u128.
  • $sint is the type of integer to work with. It must be the signed version of $int, i.e. i8, i16, i32, i64 or i128.
  • $mod is the modulus of this type of modular value. It must be a const value. It must satisfy $mod * $mod < $int::max_value() and $mod * 2 < $sint::max_value().
  • $label is a dummy label name for static assertions. This is unused on nightly builds with the underscore_const_names feature.

Example

This example is not tested
def_modular!(ExampleModular101 : u16 | i16, 101 ; some_random_label
             #[doc = "your own documentation here"]);