From 93454cfe94a76cc4caaa44bec9b1d7f10dff67d9 Mon Sep 17 00:00:00 2001 From: Ryo Yamashita Date: Wed, 30 Sep 2020 19:34:08 +0900 Subject: [PATCH] Remove the `FromStr` implementation from `DynamicModInt<_>` --- src/modint.rs | 28 +++++++++++----------------- 1 file changed, 11 insertions(+), 17 deletions(-) diff --git a/src/modint.rs b/src/modint.rs index a589c09..3e7ec52 100644 --- a/src/modint.rs +++ b/src/modint.rs @@ -114,6 +114,17 @@ impl ModIntBase for StaticModInt { } } +impl FromStr for StaticModInt { + type Err = Infallible; + + #[inline] + fn from_str(s: &str) -> Result { + Ok(s.parse::() + .map(Self::new) + .unwrap_or_else(|_| todo!("parsing as an arbitrary precision integer?"))) + } +} + pub trait Modulus: 'static + Copy + Eq { const VALUE: u32; const HINT_VALUE_IS_PRIME: bool; @@ -273,7 +284,6 @@ impl Default for Barrett { pub trait ModIntBase: Default - + FromStr + From + From + From @@ -400,13 +410,6 @@ trait InternalImplementations: ModIntBase { Self::raw(0) } - #[inline] - fn from_str_impl(s: &str) -> Result { - Ok(s.parse::() - .map(Self::new) - .unwrap_or_else(|_| todo!("parsing as an arbitrary precision integer?"))) - } - #[inline] fn hash_impl(this: &Self, state: &mut impl Hasher) { this.val().hash(state) @@ -479,15 +482,6 @@ macro_rules! impl_basic_traits { } } - impl <$generic_param: $generic_param_bound> FromStr for $self { - type Err = Infallible; - - #[inline] - fn from_str(s: &str) -> Result { - Self::from_str_impl(s) - } - } - impl<$generic_param: $generic_param_bound, V: RemEuclidU32> From for $self { #[inline] fn from(from: V) -> Self {