This crate provides modular arithmetic integer types.
modtype::Z
]```
type F = modtype::u64::Z<1_000_000_007u64>;
asserteq!((F(1000000006) + F(2)).to_string(), "1"); ```
modtype::thread_local::Z
]```
modtype::threadlocal::u32::Z::with(7, |F| { asserteq!(F(6) + F(1), F(0)); }); ```
modtype::field_param::Z
]``` use modtype::field_param::u32::Z; use num::CheckedDiv as _;
let Z = Z::factory(1000);
asserteq!(Z(1).checkeddiv(&Z(777)), Some(Z(713))); // 777 × 713 ≡ 1 (mod 1000) ```
Z
s can be customized via [modtype::Impl
].
```
type F = modtype::Z
enum Impl {}
impl modtype::Impl for Impl { type Uint = u64;
// your implementation here
} ```
use_modtype
| Name | Format | Optional |
| :------------ | :----------------------------- | :---------------------------------------------------- |
| constant
| constant($
[Ident
])
| Yes (default = concat!(_, $value, $type_uppercase)
) |
| constructor
| constructor($
[Ident
])
| Yes (default = the type alias) |