Skip to content

Commit 71b58eb

Browse files
committed
Merge pull request #3 from riccieri/fix-owned-strings
Fix owned string usage
2 parents d446cfa + c6fa260 commit 71b58eb

File tree

2 files changed

+33
-33
lines changed

2 files changed

+33
-33
lines changed

deps/rust-gmp/gmp.rs

+12-12
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,7 @@ impl Div<Mpz, Mpz> for Mpz {
376376
fn div(&self, other: &Mpz) -> Mpz {
377377
unsafe {
378378
if other.is_zero() {
379-
fail!(~"divide by zero")
379+
fail!("divide by zero")
380380
}
381381

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

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

413413
impl ToPrimitive for Mpz {
414414
fn to_i64(&self) -> Option<i64> {
415-
fail!(~"not implemented")
415+
fail!("not implemented")
416416
}
417417
fn to_u64(&self) -> Option<u64> {
418-
fail!(~"not implemented")
418+
fail!("not implemented")
419419
}
420420
}
421421

@@ -685,7 +685,7 @@ impl Mpq {
685685
pub fn invert(&self) -> Mpq {
686686
unsafe {
687687
if self.is_zero() {
688-
fail!(~"divide by zero")
688+
fail!("divide by zero")
689689
}
690690

691691
let mut res = Mpq::new();
@@ -761,7 +761,7 @@ impl Div<Mpq, Mpq> for Mpq {
761761
fn div(&self, other: &Mpq) -> Mpq {
762762
unsafe {
763763
if self.is_zero() {
764-
fail!(~"divide by zero")
764+
fail!("divide by zero")
765765
}
766766

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

784784
impl ToPrimitive for Mpq {
785785
fn to_i64(&self) -> Option<i64> {
786-
fail!(~"not implemented")
786+
fail!("not implemented")
787787
}
788788
fn to_u64(&self) -> Option<u64> {
789-
fail!(~"not implemented")
789+
fail!("not implemented")
790790
}
791791
}
792792

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

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

11131113
#[test]
11141114
fn test_to_str() {
11151115
let x: Mpz = FromStr::from_str("1234567890").unwrap();
1116-
assert!(x.to_str() == ~"1234567890");
1116+
assert!(x.to_str().as_slice() == "1234567890");
11171117
}
11181118

11191119
#[test]
@@ -1134,7 +1134,7 @@ mod test_mpz {
11341134
#[test]
11351135
fn test_from_int() {
11361136
let x: Mpz = FromPrimitive::from_int(150).unwrap();
1137-
assert!(x.to_str() == ~"150");
1137+
assert!(x.to_str().as_slice() == "150");
11381138
assert!(x == FromStr::from_str("150").unwrap());
11391139
}
11401140

src/bignum/lib.rs

+21-21
Original file line numberDiff line numberDiff line change
@@ -365,25 +365,25 @@ mod test_biguint {
365365
#[test]
366366
fn test_from_primitive() {
367367
let two: BigUint = FromPrimitive::from_uint(2).unwrap();
368-
assert_eq!(two.to_str(), ~"2");
368+
assert_eq!(two.to_str().as_slice(), "2");
369369
}
370370

371371
#[test]
372372
fn test_from_str() {
373373
let two: BigUint = FromStr::from_str("2").unwrap();
374-
assert_eq!(two.to_str(), ~"2");
374+
assert_eq!(two.to_str().as_slice(), "2");
375375
}
376376

377377
#[test]
378378
fn test_from_str_radix() {
379379
let two = BigUint::from_str_radix("1a", 16).unwrap();
380-
assert_eq!(two.to_str(), ~"26");
380+
assert_eq!(two.to_str().as_slice(), "26");
381381
}
382382

383383
#[test]
384384
fn test_to_biguint() {
385385
let three = 3u.to_biguint().unwrap();
386-
assert_eq!(three.to_str(), ~"3");
386+
assert_eq!(three.to_str().as_slice(), "3");
387387
}
388388

389389
#[test]
@@ -411,8 +411,8 @@ mod test_biguint {
411411
fn test_zero_and_one() {
412412
let zero: BigUint = Zero::zero();
413413
let one: BigUint = One::one();
414-
assert_eq!(zero.to_str(), ~"0");
415-
assert_eq!(one.to_str(), ~"1");
414+
assert_eq!(zero.to_str().as_slice(), "0");
415+
assert_eq!(one.to_str().as_slice(), "1");
416416
}
417417

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

439-
assert_eq!(two.add(&three).to_str(), ~"5");
440-
assert_eq!((two + three).to_str(), ~"5");
439+
assert_eq!(two.add(&three).to_str().as_slice(), "5");
440+
assert_eq!((two + three).to_str().as_slice(), "5");
441441
}
442442

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

448-
assert_eq!(three.sub(&two).to_str(), ~"1");
449-
assert_eq!((three - two).to_str(), ~"1");
448+
assert_eq!(three.sub(&two).to_str().as_slice(), "1");
449+
assert_eq!((three - two).to_str().as_slice(), "1");
450450
}
451451

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

457-
assert_eq!(two.mul(&three).to_str(), ~"6");
458-
assert_eq!((two * three).to_str(), ~"6");
457+
assert_eq!(two.mul(&three).to_str().as_slice(), "6");
458+
assert_eq!((two * three).to_str().as_slice(), "6");
459459
}
460460

461461
#[test]
@@ -569,15 +569,15 @@ mod test_bigint {
569569
fn test_zero_and_one() {
570570
let zero: BigInt = Zero::zero();
571571
let one: BigInt = One::one();
572-
assert_eq!(zero.to_str(), ~"0");
573-
assert_eq!(one.to_str(), ~"1");
572+
assert_eq!(zero.to_str().as_slice(), "0");
573+
assert_eq!(one.to_str().as_slice(), "1");
574574
}
575575

576576
#[test]
577577
fn test_to_biguint() {
578578
let three: BigInt = FromPrimitive::from_int(3).unwrap();
579579
let minusthree: BigInt = FromPrimitive::from_int(-3).unwrap();
580-
assert_eq!(three.to_biguint().unwrap().to_str(), ~"3");
580+
assert_eq!(three.to_biguint().unwrap().to_str().as_slice(), "3");
581581
assert_eq!(minusthree.to_biguint(), None);
582582
}
583583

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

589-
assert_eq!(two.add(&three).to_str(), ~"5");
590-
assert_eq!((two + three).to_str(), ~"5");
589+
assert_eq!(two.add(&three).to_str().as_slice(), "5");
590+
assert_eq!((two + three).to_str().as_slice(), "5");
591591
}
592592

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

598-
assert_eq!(three.sub(&two).to_str(), ~"1");
599-
assert_eq!((three - two).to_str(), ~"1");
598+
assert_eq!(three.sub(&two).to_str().as_slice(), "1");
599+
assert_eq!((three - two).to_str().as_slice(), "1");
600600
}
601601

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

607-
assert_eq!(two.mul(&three).to_str(), ~"6");
608-
assert_eq!((two * three).to_str(), ~"6");
607+
assert_eq!(two.mul(&three).to_str().as_slice(), "6");
608+
assert_eq!((two * three).to_str().as_slice(), "6");
609609
}
610610

611611
#[test]

0 commit comments

Comments
 (0)