@@ -359,7 +359,7 @@ impl Integer for BigUint {
359359
360360 fn div_mod_floor_inner ( a : BigUint , b : BigUint ) -> ( BigUint , BigUint ) {
361361 let mut m = a;
362- let mut d = Zero :: zero :: < BigUint > ( ) ;
362+ let mut d: BigUint = Zero :: zero ( ) ;
363363 let mut n = 1 ;
364364 while m >= b {
365365 let ( d0, d_unit, b_unit) = div_estimate ( & m, & b, n) ;
@@ -411,8 +411,9 @@ impl Integer for BigUint {
411411 if shift == 0 {
412412 return ( BigUint :: new ( d) , One :: one ( ) , ( * b) . clone ( ) ) ;
413413 }
414+ let one: BigUint = One :: one ( ) ;
414415 return ( BigUint :: from_slice ( d) . shl_unit ( shift) ,
415- One :: one :: < BigUint > ( ) . shl_unit ( shift) ,
416+ one. shl_unit ( shift) ,
416417 b. shl_unit ( shift) ) ;
417418 }
418419 }
@@ -1445,11 +1446,18 @@ mod biguint_tests {
14451446
14461447 #[ test]
14471448 fn test_is_even ( ) {
1448- assert ! ( FromStr :: from_str:: <BigUint >( "1" ) . unwrap( ) . is_odd( ) ) ;
1449- assert ! ( FromStr :: from_str:: <BigUint >( "2" ) . unwrap( ) . is_even( ) ) ;
1450- assert ! ( FromStr :: from_str:: <BigUint >( "1000" ) . unwrap( ) . is_even( ) ) ;
1451- assert ! ( FromStr :: from_str:: <BigUint >( "1000000000000000000000" ) . unwrap( ) . is_even( ) ) ;
1452- assert ! ( FromStr :: from_str:: <BigUint >( "1000000000000000000001" ) . unwrap( ) . is_odd( ) ) ;
1449+ let one: Option < BigUint > = FromStr :: from_str ( "1" ) ;
1450+ let two: Option < BigUint > = FromStr :: from_str ( "2" ) ;
1451+ let thousand: Option < BigUint > = FromStr :: from_str ( "1000" ) ;
1452+ let big: Option < BigUint > =
1453+ FromStr :: from_str ( "1000000000000000000000" ) ;
1454+ let bigger: Option < BigUint > =
1455+ FromStr :: from_str ( "1000000000000000000001" ) ;
1456+ assert ! ( one. unwrap( ) . is_odd( ) ) ;
1457+ assert ! ( two. unwrap( ) . is_even( ) ) ;
1458+ assert ! ( thousand. unwrap( ) . is_even( ) ) ;
1459+ assert ! ( big. unwrap( ) . is_even( ) ) ;
1460+ assert ! ( bigger. unwrap( ) . is_odd( ) ) ;
14531461 assert ! ( ( BigUint :: from_uint( 1 ) << 64 ) . is_even( ) ) ;
14541462 assert ! ( ( ( BigUint :: from_uint( 1 ) << 64 ) + BigUint :: from_uint( 1 ) ) . is_odd( ) ) ;
14551463 }
@@ -1534,15 +1542,19 @@ mod biguint_tests {
15341542 }
15351543 }
15361544
1537- assert_eq ! ( FromStrRadix :: from_str_radix:: <BigUint >( "Z" , 10 ) , None ) ;
1538- assert_eq ! ( FromStrRadix :: from_str_radix:: <BigUint >( "_" , 2 ) , None ) ;
1539- assert_eq ! ( FromStrRadix :: from_str_radix:: <BigUint >( "-1" , 10 ) , None ) ;
1545+ let zed: Option < BigUint > = FromStrRadix :: from_str_radix ( "Z" , 10 ) ;
1546+ assert_eq ! ( zed, None ) ;
1547+ let blank: Option < BigUint > = FromStrRadix :: from_str_radix ( "_" , 2 ) ;
1548+ assert_eq ! ( blank, None ) ;
1549+ let minus_one: Option < BigUint > = FromStrRadix :: from_str_radix ( "-1" ,
1550+ 10 ) ;
1551+ assert_eq ! ( minus_one, None ) ;
15401552 }
15411553
15421554 #[ test]
15431555 fn test_factor ( ) {
15441556 fn factor ( n : uint ) -> BigUint {
1545- let mut f= One :: one :: < BigUint > ( ) ;
1557+ let mut f: BigUint = One :: one ( ) ;
15461558 for i in range ( 2 , n + 1 ) {
15471559 // FIXME(#6102): Assignment operator for BigInt causes ICE
15481560 // f *= BigUint::from_uint(i);
@@ -1939,17 +1951,24 @@ mod bigint_tests {
19391951
19401952 #[ test]
19411953 fn test_abs_sub ( ) {
1942- assert_eq ! ( ( -One :: one:: <BigInt >( ) ) . abs_sub( & One :: one( ) ) , Zero :: zero( ) ) ;
1943- assert_eq ! ( One :: one:: <BigInt >( ) . abs_sub( & One :: one( ) ) , Zero :: zero( ) ) ;
1944- assert_eq ! ( One :: one:: <BigInt >( ) . abs_sub( & Zero :: zero( ) ) , One :: one( ) ) ;
1945- assert_eq ! ( One :: one:: <BigInt >( ) . abs_sub( & -One :: one:: <BigInt >( ) ) ,
1946- IntConvertible :: from_int( 2 ) ) ;
1954+ let zero: BigInt = Zero :: zero ( ) ;
1955+ let one: BigInt = One :: one ( ) ;
1956+ assert_eq ! ( ( -one) . abs_sub( & one) , zero) ;
1957+ let one: BigInt = One :: one ( ) ;
1958+ let zero: BigInt = Zero :: zero ( ) ;
1959+ assert_eq ! ( one. abs_sub( & one) , zero) ;
1960+ let one: BigInt = One :: one ( ) ;
1961+ let zero: BigInt = Zero :: zero ( ) ;
1962+ assert_eq ! ( one. abs_sub( & zero) , one) ;
1963+ let one: BigInt = One :: one ( ) ;
1964+ assert_eq ! ( one. abs_sub( & -one) , IntConvertible :: from_int( 2 ) ) ;
19471965 }
19481966
19491967 #[ test]
19501968 fn test_to_str_radix ( ) {
19511969 fn check ( n : int , ans : & str ) {
1952- assert ! ( ans == IntConvertible :: from_int:: <BigInt >( n) . to_str_radix( 10 ) ) ;
1970+ let n: BigInt = IntConvertible :: from_int ( n) ;
1971+ assert ! ( ans == n. to_str_radix( 10 ) ) ;
19531972 }
19541973 check ( 10 , "10" ) ;
19551974 check ( 1 , "1" ) ;
@@ -1962,7 +1981,10 @@ mod bigint_tests {
19621981 #[ test]
19631982 fn test_from_str_radix ( ) {
19641983 fn check ( s : & str , ans : Option < int > ) {
1965- let ans = ans. map_move ( |n| IntConvertible :: from_int :: < BigInt > ( n) ) ;
1984+ let ans = ans. map_move ( |n| {
1985+ let x: BigInt = IntConvertible :: from_int ( n) ;
1986+ x
1987+ } ) ;
19661988 assert_eq ! ( FromStrRadix :: from_str_radix( s, 10 ) , ans) ;
19671989 }
19681990 check ( "10" , Some ( 10 ) ) ;
@@ -1980,7 +2002,8 @@ mod bigint_tests {
19802002 BigInt :: new( Minus , ~[ 1 , 1 , 1 ] ) ) ;
19812003 assert ! ( -BigInt :: new( Minus , ~[ 1 , 1 , 1 ] ) ==
19822004 BigInt :: new( Plus , ~[ 1 , 1 , 1 ] ) ) ;
1983- assert_eq ! ( -Zero :: zero:: <BigInt >( ) , Zero :: zero:: <BigInt >( ) ) ;
2005+ let zero: BigInt = Zero :: zero ( ) ;
2006+ assert_eq ! ( -zero, zero) ;
19842007 }
19852008}
19862009
0 commit comments