@@ -22,7 +22,7 @@ extern crate std;
2222extern crate num_traits as traits;
2323
2424use core:: mem;
25- use core:: ops:: { Add , SubAssign } ;
25+ use core:: ops:: Add ;
2626
2727use traits:: { Num , Signed , Zero } ;
2828
@@ -135,20 +135,21 @@ pub trait Integer: Sized + Num + PartialOrd + Ord + Eq {
135135 #[ inline]
136136 fn extended_gcd ( & self , other : & Self ) -> ExtendedGcd < Self >
137137 where
138- Self : Clone + SubAssign < Self > , {
138+ Self : Clone {
139139 let mut s = ( Self :: zero ( ) , Self :: one ( ) ) ;
140140 let mut t = ( Self :: one ( ) , Self :: zero ( ) ) ;
141141 let mut r = ( other. clone ( ) , self . clone ( ) ) ;
142142
143143 while !r. 0 . is_zero ( ) {
144144 let q = r. 1 . clone ( ) / r. 0 . clone ( ) ;
145- let f = |r : & mut ( Self , Self ) | {
145+ let f = |mut r : ( Self , Self ) | {
146146 mem:: swap ( & mut r. 0 , & mut r. 1 ) ;
147- r. 0 -= q. clone ( ) * r. 1 . clone ( ) ;
147+ r. 0 = r. 0 . clone ( ) - q. clone ( ) * r. 1 . clone ( ) ;
148+ r
148149 } ;
149- f ( & mut r) ;
150- f ( & mut s) ;
151- f ( & mut t) ;
150+ r = f ( r) ;
151+ s = f ( s) ;
152+ t = f ( t) ;
152153 }
153154
154155 if r. 1 >= Self :: zero ( ) {
@@ -170,7 +171,7 @@ pub trait Integer: Sized + Num + PartialOrd + Ord + Eq {
170171 #[ inline]
171172 fn extended_gcd_lcm ( & self , other : & Self ) -> ( ExtendedGcd < Self > , Self )
172173 where
173- Self : Clone + SubAssign < Self > , {
174+ Self : Clone + Signed {
174175 ( self . extended_gcd ( other) , self . lcm ( other) )
175176 }
176177
0 commit comments