From 41977c97c2d1f3da1cdafa830d1f22f5f07283d0 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 8aa5220..2c5ffab 100644 --- a/src/modint.rs +++ b/src/modint.rs @@ -206,6 +206,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?"))) + } +} + /// Represents a modulus. /// /// # Example @@ -512,7 +523,6 @@ impl Default for Barrett { /// [`DynamicModInt`]: ../struct.DynamicModInt.html pub trait ModIntBase: Default - + FromStr + From + From + From @@ -763,13 +773,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) @@ -842,15 +845,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 {