Skip to content

Fix owned string usage #3

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 30, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions deps/rust-gmp/gmp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@ impl Div<Mpz, Mpz> for Mpz {
fn div(&self, other: &Mpz) -> Mpz {
unsafe {
if other.is_zero() {
fail!(~"divide by zero")
fail!("divide by zero")
}

let mut res = Mpz::new();
Expand All @@ -390,7 +390,7 @@ impl Rem<Mpz, Mpz> for Mpz {
fn rem(&self, other: &Mpz) -> Mpz {
unsafe {
if other.is_zero() {
fail!(~"divide by zero")
fail!("divide by zero")
}

let mut res = Mpz::new();
Expand All @@ -412,10 +412,10 @@ impl Neg<Mpz> for Mpz {

impl ToPrimitive for Mpz {
fn to_i64(&self) -> Option<i64> {
fail!(~"not implemented")
fail!("not implemented")
}
fn to_u64(&self) -> Option<u64> {
fail!(~"not implemented")
fail!("not implemented")
}
}

Expand Down Expand Up @@ -685,7 +685,7 @@ impl Mpq {
pub fn invert(&self) -> Mpq {
unsafe {
if self.is_zero() {
fail!(~"divide by zero")
fail!("divide by zero")
}

let mut res = Mpq::new();
Expand Down Expand Up @@ -761,7 +761,7 @@ impl Div<Mpq, Mpq> for Mpq {
fn div(&self, other: &Mpq) -> Mpq {
unsafe {
if self.is_zero() {
fail!(~"divide by zero")
fail!("divide by zero")
}

let mut res = Mpq::new();
Expand All @@ -783,10 +783,10 @@ impl Neg<Mpq> for Mpq {

impl ToPrimitive for Mpq {
fn to_i64(&self) -> Option<i64> {
fail!(~"not implemented")
fail!("not implemented")
}
fn to_u64(&self) -> Option<u64> {
fail!(~"not implemented")
fail!("not implemented")
}
}

Expand Down Expand Up @@ -960,7 +960,7 @@ impl Div<Mpf, Mpf> for Mpf {
fn div(&self, other: &Mpf) -> Mpf {
unsafe {
if __gmpf_cmp_ui(&self.mpf, 0) == 0 {
fail!(~"divide by zero")
fail!("divide by zero")
}

let mut res = Mpf::new(cmp::max(self.get_prec() as uint,
Expand Down Expand Up @@ -1107,13 +1107,13 @@ mod test_mpz {
#[test]
fn test_to_str_radix() {
let x: Mpz = FromPrimitive::from_int(255).unwrap();
assert!(x.to_str_radix(16) == ~"ff");
assert!(x.to_str_radix(16).as_slice() == "ff");
}

#[test]
fn test_to_str() {
let x: Mpz = FromStr::from_str("1234567890").unwrap();
assert!(x.to_str() == ~"1234567890");
assert!(x.to_str().as_slice() == "1234567890");
}

#[test]
Expand All @@ -1134,7 +1134,7 @@ mod test_mpz {
#[test]
fn test_from_int() {
let x: Mpz = FromPrimitive::from_int(150).unwrap();
assert!(x.to_str() == ~"150");
assert!(x.to_str().as_slice() == "150");
assert!(x == FromStr::from_str("150").unwrap());
}

Expand Down
42 changes: 21 additions & 21 deletions src/bignum/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -365,25 +365,25 @@ mod test_biguint {
#[test]
fn test_from_primitive() {
let two: BigUint = FromPrimitive::from_uint(2).unwrap();
assert_eq!(two.to_str(), ~"2");
assert_eq!(two.to_str().as_slice(), "2");
}

#[test]
fn test_from_str() {
let two: BigUint = FromStr::from_str("2").unwrap();
assert_eq!(two.to_str(), ~"2");
assert_eq!(two.to_str().as_slice(), "2");
}

#[test]
fn test_from_str_radix() {
let two = BigUint::from_str_radix("1a", 16).unwrap();
assert_eq!(two.to_str(), ~"26");
assert_eq!(two.to_str().as_slice(), "26");
}

#[test]
fn test_to_biguint() {
let three = 3u.to_biguint().unwrap();
assert_eq!(three.to_str(), ~"3");
assert_eq!(three.to_str().as_slice(), "3");
}

#[test]
Expand Down Expand Up @@ -411,8 +411,8 @@ mod test_biguint {
fn test_zero_and_one() {
let zero: BigUint = Zero::zero();
let one: BigUint = One::one();
assert_eq!(zero.to_str(), ~"0");
assert_eq!(one.to_str(), ~"1");
assert_eq!(zero.to_str().as_slice(), "0");
assert_eq!(one.to_str().as_slice(), "1");
}

#[test]
Expand All @@ -436,26 +436,26 @@ mod test_biguint {
let two: BigUint = FromPrimitive::from_uint(2).unwrap();
let three: BigUint = FromPrimitive::from_uint(3).unwrap();

assert_eq!(two.add(&three).to_str(), ~"5");
assert_eq!((two + three).to_str(), ~"5");
assert_eq!(two.add(&three).to_str().as_slice(), "5");
assert_eq!((two + three).to_str().as_slice(), "5");
}

#[test]
fn test_simple_sub() {
let two: BigUint = FromPrimitive::from_uint(2).unwrap();
let three: BigUint = FromPrimitive::from_uint(3).unwrap();

assert_eq!(three.sub(&two).to_str(), ~"1");
assert_eq!((three - two).to_str(), ~"1");
assert_eq!(three.sub(&two).to_str().as_slice(), "1");
assert_eq!((three - two).to_str().as_slice(), "1");
}

#[test]
fn test_mul() {
let two: BigUint = FromPrimitive::from_uint(2).unwrap();
let three: BigUint = FromPrimitive::from_uint(3).unwrap();

assert_eq!(two.mul(&three).to_str(), ~"6");
assert_eq!((two * three).to_str(), ~"6");
assert_eq!(two.mul(&three).to_str().as_slice(), "6");
assert_eq!((two * three).to_str().as_slice(), "6");
}

#[test]
Expand Down Expand Up @@ -569,15 +569,15 @@ mod test_bigint {
fn test_zero_and_one() {
let zero: BigInt = Zero::zero();
let one: BigInt = One::one();
assert_eq!(zero.to_str(), ~"0");
assert_eq!(one.to_str(), ~"1");
assert_eq!(zero.to_str().as_slice(), "0");
assert_eq!(one.to_str().as_slice(), "1");
}

#[test]
fn test_to_biguint() {
let three: BigInt = FromPrimitive::from_int(3).unwrap();
let minusthree: BigInt = FromPrimitive::from_int(-3).unwrap();
assert_eq!(three.to_biguint().unwrap().to_str(), ~"3");
assert_eq!(three.to_biguint().unwrap().to_str().as_slice(), "3");
assert_eq!(minusthree.to_biguint(), None);
}

Expand All @@ -586,26 +586,26 @@ mod test_bigint {
let two: BigInt = FromPrimitive::from_uint(2).unwrap();
let three: BigInt = FromPrimitive::from_uint(3).unwrap();

assert_eq!(two.add(&three).to_str(), ~"5");
assert_eq!((two + three).to_str(), ~"5");
assert_eq!(two.add(&three).to_str().as_slice(), "5");
assert_eq!((two + three).to_str().as_slice(), "5");
}

#[test]
fn test_simple_sub() {
let two: BigInt = FromPrimitive::from_uint(2).unwrap();
let three: BigInt = FromPrimitive::from_uint(3).unwrap();

assert_eq!(three.sub(&two).to_str(), ~"1");
assert_eq!((three - two).to_str(), ~"1");
assert_eq!(three.sub(&two).to_str().as_slice(), "1");
assert_eq!((three - two).to_str().as_slice(), "1");
}

#[test]
fn test_mul() {
let two: BigInt = FromPrimitive::from_uint(2).unwrap();
let three: BigInt = FromPrimitive::from_uint(3).unwrap();

assert_eq!(two.mul(&three).to_str(), ~"6");
assert_eq!((two * three).to_str(), ~"6");
assert_eq!(two.mul(&three).to_str().as_slice(), "6");
assert_eq!((two * three).to_str().as_slice(), "6");
}

#[test]
Expand Down