From c05cd530dbc1cc2e56f936524400b368e07ee5cb Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Fri, 23 Jan 2015 08:54:55 -0800 Subject: [PATCH] Bump to 0.1.10 --- Cargo.toml | 2 +- src/bigint.rs | 22 ++++++---------------- src/complex.rs | 13 ++----------- src/rational.rs | 14 ++------------ 4 files changed, 11 insertions(+), 40 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 86aa142..5559078 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "num" -version = "0.1.9" +version = "0.1.10" authors = ["The Rust Project Developers"] license = "MIT/Apache-2.0" homepage = "https://github.com/rust-lang/num" diff --git a/src/bigint.rs b/src/bigint.rs index 389fa42..d868add 100644 --- a/src/bigint.rs +++ b/src/bigint.rs @@ -116,7 +116,7 @@ pub mod big_digit { /// /// A `BigUint`-typed value `BigUint { data: vec!(a, b, c) }` represents a number /// `(a + b * big_digit::BASE + c * big_digit::BASE^2)`. -#[derive(Clone, RustcEncodable, RustcDecodable)] +#[derive(Clone, RustcEncodable, RustcDecodable, Debug)] pub struct BigUint { data: Vec } @@ -172,12 +172,7 @@ impl hash::Hash for BigUint { } } -impl fmt::Show for BigUint { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - write!(f, "{}", to_str_radix(self, 10)) - } -} -impl fmt::String for BigUint { +impl fmt::Display for BigUint { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "{}", to_str_radix(self, 10)) } @@ -989,7 +984,7 @@ impl Neg for Sign { } /// A big signed integer type. -#[derive(Clone, RustcEncodable, RustcDecodable)] +#[derive(Clone, RustcEncodable, RustcDecodable, Debug)] pub struct BigInt { sign: Sign, data: BigUint @@ -1030,12 +1025,7 @@ impl Default for BigInt { fn default() -> BigInt { Zero::zero() } } -impl fmt::Show for BigInt { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - write!(f, "{}", to_str_radix_signed(self, 10)) - } -} -impl fmt::String for BigInt { +impl fmt::Display for BigInt { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "{}", to_str_radix_signed(self, 10)) } @@ -1673,7 +1663,7 @@ mod biguint_tests { let data: [&[_]; 7] = [ &[], &[1], &[2], &[-1], &[0, 1], &[2, 1], &[1, 1, 1] ]; let data: Vec = data.iter().map(|v| BigUint::from_slice(*v)).collect(); for (i, ni) in data.iter().enumerate() { - for (j0, nj) in data.slice(i, data.len()).iter().enumerate() { + for (j0, nj) in data[i..].iter().enumerate() { let j = j0 + i; if i == j { assert_eq!(ni.cmp(nj), Equal); @@ -2545,7 +2535,7 @@ mod bigint_tests { nums.extend(vs.iter().map(|s| BigInt::from_slice(Plus, *s))); for (i, ni) in nums.iter().enumerate() { - for (j0, nj) in nums.slice(i, nums.len()).iter().enumerate() { + for (j0, nj) in nums[i..].iter().enumerate() { let j = i + j0; if i == j { assert_eq!(ni.cmp(nj), Equal); diff --git a/src/complex.rs b/src/complex.rs index 3eaf169..ee0c6cd 100644 --- a/src/complex.rs +++ b/src/complex.rs @@ -21,7 +21,7 @@ use {Zero, One, Num}; // probably doesn't map to C's _Complex correctly. /// A complex number in Cartesian form. -#[derive(PartialEq, Copy, Clone, Hash, RustcEncodable, RustcDecodable)] +#[derive(PartialEq, Copy, Clone, Hash, RustcEncodable, RustcDecodable, Debug)] pub struct Complex { /// Real portion of the complex number pub re: T, @@ -241,16 +241,7 @@ impl One for Complex { } /* string conversions */ -impl fmt::Show for Complex { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - if self.im < Zero::zero() { - write!(f, "{:?}-{:?}i", self.re, -self.im.clone()) - } else { - write!(f, "{:?}+{:?}i", self.re, self.im) - } - } -} -impl fmt::String for Complex { +impl fmt::Display for Complex { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { if self.im < Zero::zero() { write!(f, "{}-{}i", self.re, -self.im.clone()) diff --git a/src/rational.rs b/src/rational.rs index ea20c50..a37dd07 100644 --- a/src/rational.rs +++ b/src/rational.rs @@ -22,7 +22,7 @@ use bigint::{BigInt, BigUint, Sign}; use {Num, Signed, Zero, One}; /// Represents the ratio between 2 numbers. -#[derive(Copy, Clone, Hash, RustcEncodable, RustcDecodable)] +#[derive(Copy, Clone, Hash, RustcEncodable, RustcDecodable, Debug)] #[allow(missing_docs)] pub struct Ratio { numer: T, @@ -406,17 +406,7 @@ impl } /* String conversions */ -impl fmt::Show for Ratio { - /// Renders as `numer/denom`. If denom=1, renders as numer. - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - if self.denom == One::one() { - write!(f, "{:?}", self.numer) - } else { - write!(f, "{:?}/{:?}", self.numer, self.denom) - } - } -} -impl fmt::String for Ratio { +impl fmt::Display for Ratio { /// Renders as `numer/denom`. If denom=1, renders as numer. fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { if self.denom == One::one() {