Skip to content

Commit

Permalink
Remove the FromStr implementation from DynamicModInt<_>
Browse files Browse the repository at this point in the history
  • Loading branch information
qryxip committed Oct 25, 2020
1 parent 19509cd commit 41977c9
Showing 1 changed file with 11 additions and 17 deletions.
28 changes: 11 additions & 17 deletions src/modint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,17 @@ impl<M: Modulus> ModIntBase for StaticModInt<M> {
}
}

impl<M: Modulus> FromStr for StaticModInt<M> {
type Err = Infallible;

#[inline]
fn from_str(s: &str) -> Result<Self, Infallible> {
Ok(s.parse::<i64>()
.map(Self::new)
.unwrap_or_else(|_| todo!("parsing as an arbitrary precision integer?")))
}
}

/// Represents a modulus.
///
/// # Example
Expand Down Expand Up @@ -512,7 +523,6 @@ impl Default for Barrett {
/// [`DynamicModInt`]: ../struct.DynamicModInt.html
pub trait ModIntBase:
Default
+ FromStr
+ From<i8>
+ From<i16>
+ From<i32>
Expand Down Expand Up @@ -763,13 +773,6 @@ trait InternalImplementations: ModIntBase {
Self::raw(0)
}

#[inline]
fn from_str_impl(s: &str) -> Result<Self, Infallible> {
Ok(s.parse::<i64>()
.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)
Expand Down Expand Up @@ -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, Infallible> {
Self::from_str_impl(s)
}
}

impl<$generic_param: $generic_param_bound, V: RemEuclidU32> From<V> for $self {
#[inline]
fn from(from: V) -> Self {
Expand Down

0 comments on commit 41977c9

Please sign in to comment.