File tree 1 file changed +11
-17
lines changed
1 file changed +11
-17
lines changed Original file line number Diff line number Diff line change @@ -114,6 +114,17 @@ impl<M: Modulus> ModIntBase for StaticModInt<M> {
114
114
}
115
115
}
116
116
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
+
117
128
pub trait Modulus : ' static + Copy + Eq {
118
129
const VALUE : u32 ;
119
130
const HINT_VALUE_IS_PRIME : bool ;
@@ -273,7 +284,6 @@ impl Default for Barrett {
273
284
274
285
pub trait ModIntBase :
275
286
Default
276
- + FromStr
277
287
+ From < i8 >
278
288
+ From < i16 >
279
289
+ From < i32 >
@@ -400,13 +410,6 @@ trait InternalImplementations: ModIntBase {
400
410
Self :: raw ( 0 )
401
411
}
402
412
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
-
410
413
#[ inline]
411
414
fn hash_impl ( this : & Self , state : & mut impl Hasher ) {
412
415
this. val ( ) . hash ( state)
@@ -479,15 +482,6 @@ macro_rules! impl_basic_traits {
479
482
}
480
483
}
481
484
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
-
491
485
impl <$generic_param: $generic_param_bound, V : RemEuclidU32 > From <V > for $self {
492
486
#[ inline]
493
487
fn from( from: V ) -> Self {
You can’t perform that action at this time.
0 commit comments