Update to rust master

This commit is contained in:
Alex Crichton 2015-03-29 10:05:02 -07:00
parent 0fa0b75e68
commit 1841c8ace4
2 changed files with 48 additions and 49 deletions

View File

@ -1796,7 +1796,7 @@ mod biguint_tests {
#[test] #[test]
fn test_from_slice() { fn test_from_slice() {
fn check(slice: &[BigDigit], data: &[BigDigit]) { fn check(slice: &[BigDigit], data: &[BigDigit]) {
assert!(data == BigUint::from_slice(slice).data.as_slice()); assert!(data == BigUint::from_slice(slice).data);
} }
check(&[1], &[1]); check(&[1], &[1]);
check(&[0, 0, 0], &[]); check(&[0, 0, 0], &[]);
@ -1965,7 +1965,7 @@ mod biguint_tests {
fn check(s: &str, shift: usize, ans: &str) { fn check(s: &str, shift: usize, ans: &str) {
let opt_biguint: Option<BigUint> = FromStrRadix::from_str_radix(s, 16).ok(); let opt_biguint: Option<BigUint> = FromStrRadix::from_str_radix(s, 16).ok();
let bu = to_str_radix(&(opt_biguint.unwrap() << shift), 16); let bu = to_str_radix(&(opt_biguint.unwrap() << shift), 16);
assert_eq!(bu.as_slice(), ans); assert_eq!(bu, ans);
} }
check("0", 3, "0"); check("0", 3, "0");
@ -2087,7 +2087,7 @@ mod biguint_tests {
let opt_biguint: Option<BigUint> = let opt_biguint: Option<BigUint> =
FromStrRadix::from_str_radix(s, 16).ok(); FromStrRadix::from_str_radix(s, 16).ok();
let bu = to_str_radix(&(opt_biguint.unwrap() >> shift), 16); let bu = to_str_radix(&(opt_biguint.unwrap() >> shift), 16);
assert_eq!(bu.as_slice(), ans); assert_eq!(bu, ans);
} }
check("0", 3, "0"); check("0", 3, "0");
@ -2586,8 +2586,7 @@ mod biguint_tests {
let &(ref n, ref rs) = num_pair; let &(ref n, ref rs) = num_pair;
for str_pair in rs.iter() { for str_pair in rs.iter() {
let &(ref radix, ref str) = str_pair; let &(ref radix, ref str) = str_pair;
assert_eq!(to_str_radix(n, *radix).as_slice(), assert_eq!(to_str_radix(n, *radix), *str);
str.as_slice());
} }
} }
} }
@ -2600,7 +2599,7 @@ mod biguint_tests {
for str_pair in rs.iter() { for str_pair in rs.iter() {
let &(ref radix, ref str) = str_pair; let &(ref radix, ref str) = str_pair;
assert_eq!(n, assert_eq!(n,
&FromStrRadix::from_str_radix(str.as_slice(), &FromStrRadix::from_str_radix(str,
*radix).unwrap()); *radix).unwrap());
} }
} }

View File

@ -22,15 +22,15 @@ pub trait Integer: Sized + Num + PartialOrd
/// ///
/// ~~~ /// ~~~
/// # use num::Integer; /// # use num::Integer;
/// assert!(( 8i).div_floor(& 3) == 2); /// assert!(( 8).div_floor(& 3) == 2);
/// assert!(( 8i).div_floor(&-3) == -3); /// assert!(( 8).div_floor(&-3) == -3);
/// assert!((-8i).div_floor(& 3) == -3); /// assert!((-8).div_floor(& 3) == -3);
/// assert!((-8i).div_floor(&-3) == 2); /// assert!((-8).div_floor(&-3) == 2);
/// ///
/// assert!(( 1i).div_floor(& 2) == 0); /// assert!(( 1).div_floor(& 2) == 0);
/// assert!(( 1i).div_floor(&-2) == -1); /// assert!(( 1).div_floor(&-2) == -1);
/// assert!((-1i).div_floor(& 2) == -1); /// assert!((-1).div_floor(& 2) == -1);
/// assert!((-1i).div_floor(&-2) == 0); /// assert!((-1).div_floor(&-2) == 0);
/// ~~~ /// ~~~
fn div_floor(&self, other: &Self) -> Self; fn div_floor(&self, other: &Self) -> Self;
@ -38,7 +38,7 @@ pub trait Integer: Sized + Num + PartialOrd
/// ///
/// ~~~ /// ~~~
/// # use num::Integer; /// # use num::Integer;
/// # let n = 1i; let d = 1i; /// # let n = 1; let d = 1;
/// assert!(n.div_floor(&d) * d + n.mod_floor(&d) == n) /// assert!(n.div_floor(&d) * d + n.mod_floor(&d) == n)
/// ~~~ /// ~~~
/// ///
@ -46,15 +46,15 @@ pub trait Integer: Sized + Num + PartialOrd
/// ///
/// ~~~ /// ~~~
/// # use num::Integer; /// # use num::Integer;
/// assert!(( 8i).mod_floor(& 3) == 2); /// assert!(( 8).mod_floor(& 3) == 2);
/// assert!(( 8i).mod_floor(&-3) == -1); /// assert!(( 8).mod_floor(&-3) == -1);
/// assert!((-8i).mod_floor(& 3) == 1); /// assert!((-8).mod_floor(& 3) == 1);
/// assert!((-8i).mod_floor(&-3) == -2); /// assert!((-8).mod_floor(&-3) == -2);
/// ///
/// assert!(( 1i).mod_floor(& 2) == 1); /// assert!(( 1).mod_floor(& 2) == 1);
/// assert!(( 1i).mod_floor(&-2) == -1); /// assert!(( 1).mod_floor(&-2) == -1);
/// assert!((-1i).mod_floor(& 2) == 1); /// assert!((-1).mod_floor(& 2) == 1);
/// assert!((-1i).mod_floor(&-2) == -1); /// assert!((-1).mod_floor(&-2) == -1);
/// ~~~ /// ~~~
fn mod_floor(&self, other: &Self) -> Self; fn mod_floor(&self, other: &Self) -> Self;
@ -64,8 +64,8 @@ pub trait Integer: Sized + Num + PartialOrd
/// ///
/// ~~~ /// ~~~
/// # use num::Integer; /// # use num::Integer;
/// assert_eq!(6i.gcd(&8), 2); /// assert_eq!(6.gcd(&8), 2);
/// assert_eq!(7i.gcd(&3), 1); /// assert_eq!(7.gcd(&3), 1);
/// ~~~ /// ~~~
fn gcd(&self, other: &Self) -> Self; fn gcd(&self, other: &Self) -> Self;
@ -75,8 +75,8 @@ pub trait Integer: Sized + Num + PartialOrd
/// ///
/// ~~~ /// ~~~
/// # use num::Integer; /// # use num::Integer;
/// assert_eq!(7i.lcm(&3), 21); /// assert_eq!(7.lcm(&3), 21);
/// assert_eq!(2i.lcm(&4), 4); /// assert_eq!(2.lcm(&4), 4);
/// ~~~ /// ~~~
fn lcm(&self, other: &Self) -> Self; fn lcm(&self, other: &Self) -> Self;
@ -90,8 +90,8 @@ pub trait Integer: Sized + Num + PartialOrd
/// ///
/// ~~~ /// ~~~
/// # use num::Integer; /// # use num::Integer;
/// assert_eq!(9i.is_multiple_of(&3), true); /// assert_eq!(9.is_multiple_of(&3), true);
/// assert_eq!(3i.is_multiple_of(&9), false); /// assert_eq!(3.is_multiple_of(&9), false);
/// ~~~ /// ~~~
fn is_multiple_of(&self, other: &Self) -> bool; fn is_multiple_of(&self, other: &Self) -> bool;
@ -101,8 +101,8 @@ pub trait Integer: Sized + Num + PartialOrd
/// ///
/// ~~~ /// ~~~
/// # use num::Integer; /// # use num::Integer;
/// assert_eq!(3i.is_even(), false); /// assert_eq!(3.is_even(), false);
/// assert_eq!(4i.is_even(), true); /// assert_eq!(4.is_even(), true);
/// ~~~ /// ~~~
fn is_even(&self) -> bool; fn is_even(&self) -> bool;
@ -112,8 +112,8 @@ pub trait Integer: Sized + Num + PartialOrd
/// ///
/// ~~~ /// ~~~
/// # use num::Integer; /// # use num::Integer;
/// assert_eq!(3i.is_odd(), true); /// assert_eq!(3.is_odd(), true);
/// assert_eq!(4i.is_odd(), false); /// assert_eq!(4.is_odd(), false);
/// ~~~ /// ~~~
fn is_odd(&self) -> bool; fn is_odd(&self) -> bool;
@ -124,15 +124,15 @@ pub trait Integer: Sized + Num + PartialOrd
/// ///
/// ~~~ /// ~~~
/// # use num::Integer; /// # use num::Integer;
/// assert_eq!(( 8i).div_rem( &3), ( 2, 2)); /// assert_eq!(( 8).div_rem( &3), ( 2, 2));
/// assert_eq!(( 8i).div_rem(&-3), (-2, 2)); /// assert_eq!(( 8).div_rem(&-3), (-2, 2));
/// assert_eq!((-8i).div_rem( &3), (-2, -2)); /// assert_eq!((-8).div_rem( &3), (-2, -2));
/// assert_eq!((-8i).div_rem(&-3), ( 2, -2)); /// assert_eq!((-8).div_rem(&-3), ( 2, -2));
/// ///
/// assert_eq!(( 1i).div_rem( &2), ( 0, 1)); /// assert_eq!(( 1).div_rem( &2), ( 0, 1));
/// assert_eq!(( 1i).div_rem(&-2), ( 0, 1)); /// assert_eq!(( 1).div_rem(&-2), ( 0, 1));
/// assert_eq!((-1i).div_rem( &2), ( 0, -1)); /// assert_eq!((-1).div_rem( &2), ( 0, -1));
/// assert_eq!((-1i).div_rem(&-2), ( 0, -1)); /// assert_eq!((-1).div_rem(&-2), ( 0, -1));
/// ~~~ /// ~~~
#[inline] #[inline]
fn div_rem(&self, other: &Self) -> (Self, Self); fn div_rem(&self, other: &Self) -> (Self, Self);
@ -144,15 +144,15 @@ pub trait Integer: Sized + Num + PartialOrd
/// ///
/// ~~~ /// ~~~
/// # use num::Integer; /// # use num::Integer;
/// assert_eq!(( 8i).div_mod_floor( &3), ( 2, 2)); /// assert_eq!(( 8).div_mod_floor( &3), ( 2, 2));
/// assert_eq!(( 8i).div_mod_floor(&-3), (-3, -1)); /// assert_eq!(( 8).div_mod_floor(&-3), (-3, -1));
/// assert_eq!((-8i).div_mod_floor( &3), (-3, 1)); /// assert_eq!((-8).div_mod_floor( &3), (-3, 1));
/// assert_eq!((-8i).div_mod_floor(&-3), ( 2, -2)); /// assert_eq!((-8).div_mod_floor(&-3), ( 2, -2));
/// ///
/// assert_eq!(( 1i).div_mod_floor( &2), ( 0, 1)); /// assert_eq!(( 1).div_mod_floor( &2), ( 0, 1));
/// assert_eq!(( 1i).div_mod_floor(&-2), (-1, -1)); /// assert_eq!(( 1).div_mod_floor(&-2), (-1, -1));
/// assert_eq!((-1i).div_mod_floor( &2), (-1, 1)); /// assert_eq!((-1).div_mod_floor( &2), (-1, 1));
/// assert_eq!((-1i).div_mod_floor(&-2), ( 0, -1)); /// assert_eq!((-1).div_mod_floor(&-2), ( 0, -1));
/// ~~~ /// ~~~
fn div_mod_floor(&self, other: &Self) -> (Self, Self) { fn div_mod_floor(&self, other: &Self) -> (Self, Self) {
(self.div_floor(other), self.mod_floor(other)) (self.div_floor(other), self.mod_floor(other))