pub trait Modulus:
'static
+ Copy
+ Eq {
const VALUE: u32;
const HINT_VALUE_IS_PRIME: bool;
// Required method
fn butterfly_cache( ) -> &'static LocalKey<RefCell<Option<ButterflyCache<Self>>>>;
}
Expand description
Represents a modulus.
§Example
macro_rules! modulus {
($($name:ident($value:expr, $is_prime:expr)),*) => {
$(
#[derive(Copy, Clone, Eq, PartialEq)]
enum $name {}
impl ac_library::modint::Modulus for $name {
const VALUE: u32 = $value;
const HINT_VALUE_IS_PRIME: bool = $is_prime;
fn butterfly_cache() -> &'static ::std::thread::LocalKey<::std::cell::RefCell<::std::option::Option<ac_library::modint::ButterflyCache<Self>>>> {
thread_local! {
static BUTTERFLY_CACHE: ::std::cell::RefCell<::std::option::Option<ac_library::modint::ButterflyCache<$name>>> = ::std::default::Default::default();
}
&BUTTERFLY_CACHE
}
}
)*
};
}
use ac_library::StaticModInt;
modulus!(Mod101(101, true), Mod103(103, true));
type Z101 = StaticModInt<Mod101>;
type Z103 = StaticModInt<Mod103>;
assert_eq!(Z101::new(101), Z101::new(0));
assert_eq!(Z103::new(103), Z103::new(0));
Required Associated Constants§
Required Methods§
fn butterfly_cache() -> &'static LocalKey<RefCell<Option<ButterflyCache<Self>>>>
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.