Skip to content

Commit 93454cf

Browse files
committed
Remove the FromStr implementation from DynamicModInt<_>
1 parent 3056e2a commit 93454cf

File tree

1 file changed

+11
-17
lines changed

1 file changed

+11
-17
lines changed

Diff for: src/modint.rs

+11-17
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,17 @@ impl<M: Modulus> ModIntBase for StaticModInt<M> {
114114
}
115115
}
116116

117+
impl<M: Modulus> FromStr for StaticModInt<M> {
118+
type Err = Infallible;
119+
120+
#[inline]
121+
fn from_str(s: &str) -> Result<Self, Infallible> {
122+
Ok(s.parse::<i64>()
123+
.map(Self::new)
124+
.unwrap_or_else(|_| todo!("parsing as an arbitrary precision integer?")))
125+
}
126+
}
127+
117128
pub trait Modulus: 'static + Copy + Eq {
118129
const VALUE: u32;
119130
const HINT_VALUE_IS_PRIME: bool;
@@ -273,7 +284,6 @@ impl Default for Barrett {
273284

274285
pub trait ModIntBase:
275286
Default
276-
+ FromStr
277287
+ From<i8>
278288
+ From<i16>
279289
+ From<i32>
@@ -400,13 +410,6 @@ trait InternalImplementations: ModIntBase {
400410
Self::raw(0)
401411
}
402412

403-
#[inline]
404-
fn from_str_impl(s: &str) -> Result<Self, Infallible> {
405-
Ok(s.parse::<i64>()
406-
.map(Self::new)
407-
.unwrap_or_else(|_| todo!("parsing as an arbitrary precision integer?")))
408-
}
409-
410413
#[inline]
411414
fn hash_impl(this: &Self, state: &mut impl Hasher) {
412415
this.val().hash(state)
@@ -479,15 +482,6 @@ macro_rules! impl_basic_traits {
479482
}
480483
}
481484

482-
impl <$generic_param: $generic_param_bound> FromStr for $self {
483-
type Err = Infallible;
484-
485-
#[inline]
486-
fn from_str(s: &str) -> Result<Self, Infallible> {
487-
Self::from_str_impl(s)
488-
}
489-
}
490-
491485
impl<$generic_param: $generic_param_bound, V: RemEuclidU32> From<V> for $self {
492486
#[inline]
493487
fn from(from: V) -> Self {

0 commit comments

Comments
 (0)