Bump to 0.1.10

This commit is contained in:
Alex Crichton 2015-01-23 08:54:55 -08:00
parent 51b94c5e2e
commit c05cd530db
4 changed files with 11 additions and 40 deletions

View File

@ -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"

View File

@ -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<BigDigit>
}
@ -172,12 +172,7 @@ impl<S: hash::Hasher + hash::Writer> hash::Hash<S> 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<BigUint> = 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);

View File

@ -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<T> {
/// Real portion of the complex number
pub re: T,
@ -241,16 +241,7 @@ impl<T: Clone + Num> One for Complex<T> {
}
/* string conversions */
impl<T: fmt::Show + Num + PartialOrd + Clone> fmt::Show for Complex<T> {
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<T: fmt::String + Num + PartialOrd + Clone> fmt::String for Complex<T> {
impl<T: fmt::Display + Num + PartialOrd + Clone> fmt::Display for Complex<T> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
if self.im < Zero::zero() {
write!(f, "{}-{}i", self.re, -self.im.clone())

View File

@ -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<T> {
numer: T,
@ -406,17 +406,7 @@ impl<T: Clone + Integer + PartialOrd>
}
/* String conversions */
impl<T: fmt::Show + Eq + One> fmt::Show for Ratio<T> {
/// 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<T: fmt::String + Eq + One> fmt::String for Ratio<T> {
impl<T: fmt::Display + Eq + One> fmt::Display for Ratio<T> {
/// Renders as `numer/denom`. If denom=1, renders as numer.
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
if self.denom == One::one() {