diff --git a/.cargo/config.toml b/.cargo/config.toml deleted file mode 100644 index 3d99f63..0000000 --- a/.cargo/config.toml +++ /dev/null @@ -1,8 +0,0 @@ -[build] -# This works both on local `cargo doc` and on docs.rs because we don't have any `normal` dependency. -# In most cases, `package.metadata.docs.rs` is recommended. -# -# See also: -# - https://docs.rs/rustdoc-katex-demo -# - https://docs.rs/rust-latex-doc-minimal-example -rustdocflags = ["--html-in-header", "./doc/katex-header.html"] diff --git a/Cargo.toml b/Cargo.toml index c630983..70ff13a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -10,6 +10,7 @@ keywords = ["competitive"] categories = ["algorithms", "data-structures"] [package.metadata.docs.rs] +all-features = true rustdoc-args = ["--html-in-header", "./doc/katex-header.html"] [lib] @@ -18,6 +19,7 @@ name = "ac_library" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] +num-traits = { version = "0.2.15", optional = true } [dev-dependencies] proconio = "=0.3.6" diff --git a/src/modint.rs b/src/modint.rs index 022263c..b3846f0 100644 --- a/src/modint.rs +++ b/src/modint.rs @@ -898,6 +898,39 @@ macro_rules! impl_basic_traits { } } + #[cfg(feature = "num-traits")] + impl<$generic_param: $generic_param_bound> num_traits::Zero for $self { + #[inline] + fn zero() -> Self { + Self::new(0) + } + #[inline] + fn is_zero(&self) -> bool { + self == &Self::zero() + } + } + + #[cfg(feature = "num-traits")] + impl<$generic_param: $generic_param_bound> num_traits::One for $self { + #[inline] + fn one() -> Self { + Self::new(1) + } + #[inline] + fn is_one(&self) -> bool { + self == &Self::one() + } + } + + #[cfg(feature = "num-traits")] + impl<$generic_param: $generic_param_bound> num_traits::Pow for $self { + type Output=$self; + #[inline] + fn pow(self, rhs: u64) -> Self::Output { + self.pow(rhs) + } + } + impl_basic_traits!($($rest)*); }; }