Fix build warnings
This commit is contained in:
parent
e0e63cf241
commit
5d4b921537
14
.travis.yml
14
.travis.yml
|
@ -1,7 +1,15 @@
|
||||||
install:
|
language: rust
|
||||||
- curl https://static.rust-lang.org/rustup.sh | sudo sh -
|
|
||||||
script:
|
script:
|
||||||
- cargo build --verbose
|
- cargo build --verbose
|
||||||
- cargo test --verbose
|
- cargo test --verbose
|
||||||
|
- cargo doc
|
||||||
|
after_success: |
|
||||||
|
[ $TRAVIS_BRANCH = master ] &&
|
||||||
|
[ $TRAVIS_PULL_REQUEST = false ] &&
|
||||||
|
echo '<meta http-equiv=refresh content=0;url=num/index.html>' > target/doc/index.html &&
|
||||||
|
sudo pip install ghp-import &&
|
||||||
|
ghp-import -n target/doc &&
|
||||||
|
git push -fq https://${TOKEN}@github.com/${TRAVIS_REPO_SLUG}.git gh-pages
|
||||||
env:
|
env:
|
||||||
- LD_LIBRARY_PATH=/usr/local/lib
|
global:
|
||||||
|
secure: NNQ8QgQFZ05OhljZiuCg39AEPU7Yhko/shFlJG1lqYFoFrELibSmBPd7zJsTubufHRddn0ed6IH7qPLnzWJ/cS+dxwAopuqCFzGMOcd/JW8DJgD5PUBA8EVh8x0tNFJVxxdnGac1ufRneWMvMIxH2hO1DMc+8FZBBd7u1DNG1Lk=
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
[package]
|
[package]
|
||||||
|
|
||||||
name = "num"
|
name = "num"
|
||||||
version = "0.1.2"
|
version = "0.1.3"
|
||||||
authors = ["The Rust Project Developers"]
|
authors = ["The Rust Project Developers"]
|
||||||
license = "MIT/Apache-2.0"
|
license = "MIT/Apache-2.0"
|
||||||
homepage = "https://github.com/rust-lang/num"
|
homepage = "https://github.com/rust-lang/num"
|
||||||
|
@ -11,3 +11,6 @@ description = """
|
||||||
Simple numerics. This crate contains basic arbitrary-sized integer,
|
Simple numerics. This crate contains basic arbitrary-sized integer,
|
||||||
rational, and complex types.
|
rational, and complex types.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
rustc-serialize = "0.1"
|
||||||
|
|
|
@ -56,14 +56,15 @@
|
||||||
//! ```
|
//! ```
|
||||||
|
|
||||||
use Integer;
|
use Integer;
|
||||||
use rand::Rng;
|
|
||||||
|
|
||||||
use std::{cmp, fmt, hash};
|
|
||||||
use std::default::Default;
|
use std::default::Default;
|
||||||
|
use std::iter::repeat;
|
||||||
use std::iter::{AdditiveIterator, MultiplicativeIterator};
|
use std::iter::{AdditiveIterator, MultiplicativeIterator};
|
||||||
use std::num::{Int, ToPrimitive, FromPrimitive};
|
|
||||||
use std::num::FromStrRadix;
|
use std::num::FromStrRadix;
|
||||||
|
use std::num::{Int, ToPrimitive, FromPrimitive};
|
||||||
|
use std::rand::Rng;
|
||||||
use std::str::{mod, FromStr};
|
use std::str::{mod, FromStr};
|
||||||
|
use std::{cmp, fmt, hash};
|
||||||
use std::{i64, u64};
|
use std::{i64, u64};
|
||||||
|
|
||||||
use {Num, Unsigned, CheckedAdd, CheckedSub, CheckedMul, CheckedDiv, Signed, Zero, One};
|
use {Num, Unsigned, CheckedAdd, CheckedSub, CheckedMul, CheckedDiv, Signed, Zero, One};
|
||||||
|
@ -112,7 +113,7 @@ pub mod BigDigit {
|
||||||
///
|
///
|
||||||
/// A `BigUint`-typed value `BigUint { data: vec!(a, b, c) }` represents a number
|
/// A `BigUint`-typed value `BigUint { data: vec!(a, b, c) }` represents a number
|
||||||
/// `(a + b * BigDigit::BASE + c * BigDigit::BASE^2)`.
|
/// `(a + b * BigDigit::BASE + c * BigDigit::BASE^2)`.
|
||||||
#[deriving(Clone, Encodable, Decodable)]
|
#[deriving(Clone, RustcEncodable, RustcDecodable)]
|
||||||
pub struct BigUint {
|
pub struct BigUint {
|
||||||
data: Vec<BigDigit>
|
data: Vec<BigDigit>
|
||||||
}
|
}
|
||||||
|
@ -759,7 +760,7 @@ fn to_str_radix(me: &BigUint, radix: uint) -> String {
|
||||||
let mut s = String::with_capacity(v.len() * l);
|
let mut s = String::with_capacity(v.len() * l);
|
||||||
for n in v.iter().rev() {
|
for n in v.iter().rev() {
|
||||||
let ss = fmt::radix(*n as uint, radix as u8).to_string();
|
let ss = fmt::radix(*n as uint, radix as u8).to_string();
|
||||||
s.push_str("0".repeat(l - ss.len())[]);
|
s.extend(repeat("0").take(l - ss.len()));
|
||||||
s.push_str(ss[]);
|
s.push_str(ss[]);
|
||||||
}
|
}
|
||||||
s.trim_left_chars('0').to_string()
|
s.trim_left_chars('0').to_string()
|
||||||
|
@ -932,7 +933,7 @@ fn get_radix_base(radix: uint) -> (DoubleBigDigit, uint) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A Sign is a `BigInt`'s composing element.
|
/// A Sign is a `BigInt`'s composing element.
|
||||||
#[deriving(PartialEq, PartialOrd, Eq, Ord, Copy, Clone, Show, Encodable, Decodable)]
|
#[deriving(PartialEq, PartialOrd, Eq, Ord, Copy, Clone, Show, RustcEncodable, RustcDecodable)]
|
||||||
pub enum Sign { Minus, NoSign, Plus }
|
pub enum Sign { Minus, NoSign, Plus }
|
||||||
|
|
||||||
impl Neg<Sign> for Sign {
|
impl Neg<Sign> for Sign {
|
||||||
|
@ -948,7 +949,7 @@ impl Neg<Sign> for Sign {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A big signed integer type.
|
/// A big signed integer type.
|
||||||
#[deriving(Clone, Encodable, Decodable)]
|
#[deriving(Clone, RustcEncodable, RustcDecodable)]
|
||||||
pub struct BigInt {
|
pub struct BigInt {
|
||||||
sign: Sign,
|
sign: Sign,
|
||||||
data: BigUint
|
data: BigUint
|
||||||
|
@ -1581,13 +1582,14 @@ mod biguint_tests {
|
||||||
use super::Sign::Plus;
|
use super::Sign::Plus;
|
||||||
|
|
||||||
use std::cmp::Ordering::{Less, Equal, Greater};
|
use std::cmp::Ordering::{Less, Equal, Greater};
|
||||||
use std::str::FromStr;
|
use std::hash::hash;
|
||||||
use std::i64;
|
use std::i64;
|
||||||
|
use std::iter::repeat;
|
||||||
use std::num::FromStrRadix;
|
use std::num::FromStrRadix;
|
||||||
use std::num::{ToPrimitive, FromPrimitive};
|
use std::num::{ToPrimitive, FromPrimitive};
|
||||||
use std::rand::task_rng;
|
use std::rand::task_rng;
|
||||||
|
use std::str::FromStr;
|
||||||
use std::u64;
|
use std::u64;
|
||||||
use std::hash::hash;
|
|
||||||
|
|
||||||
use {Zero, One, CheckedAdd, CheckedSub, CheckedMul, CheckedDiv};
|
use {Zero, One, CheckedAdd, CheckedSub, CheckedMul, CheckedDiv};
|
||||||
|
|
||||||
|
@ -2284,25 +2286,25 @@ mod biguint_tests {
|
||||||
(16, "fff".to_string())
|
(16, "fff".to_string())
|
||||||
)), ( BigUint::from_slice(&[ 1, 2 ]), vec!(
|
)), ( BigUint::from_slice(&[ 1, 2 ]), vec!(
|
||||||
(2,
|
(2,
|
||||||
format!("10{}1", "0".repeat(bits - 1))),
|
format!("10{}1", repeat("0").take(bits - 1).collect::<String>())),
|
||||||
(4,
|
(4,
|
||||||
format!("2{}1", "0".repeat(bits / 2 - 1))),
|
format!("2{}1", repeat("0").take(bits / 2 - 1).collect::<String>())),
|
||||||
(10, match bits {
|
(10, match bits {
|
||||||
32 => "8589934593".to_string(),
|
32 => "8589934593".to_string(),
|
||||||
16 => "131073".to_string(),
|
16 => "131073".to_string(),
|
||||||
_ => panic!()
|
_ => panic!()
|
||||||
}),
|
}),
|
||||||
(16,
|
(16,
|
||||||
format!("2{}1", "0".repeat(bits / 4 - 1)))
|
format!("2{}1", repeat("0").take(bits / 4 - 1).collect::<String>()))
|
||||||
)), ( BigUint::from_slice(&[ 1, 2, 3 ]), vec!(
|
)), ( BigUint::from_slice(&[ 1, 2, 3 ]), vec!(
|
||||||
(2,
|
(2,
|
||||||
format!("11{}10{}1",
|
format!("11{}10{}1",
|
||||||
"0".repeat(bits - 2),
|
repeat("0").take(bits - 2).collect::<String>(),
|
||||||
"0".repeat(bits - 1))),
|
repeat("0").take(bits - 1).collect::<String>())),
|
||||||
(4,
|
(4,
|
||||||
format!("3{}2{}1",
|
format!("3{}2{}1",
|
||||||
"0".repeat(bits / 2 - 1),
|
repeat("0").take(bits / 2 - 1).collect::<String>(),
|
||||||
"0".repeat(bits / 2 - 1))),
|
repeat("0").take(bits / 2 - 1).collect::<String>())),
|
||||||
(10, match bits {
|
(10, match bits {
|
||||||
32 => "55340232229718589441".to_string(),
|
32 => "55340232229718589441".to_string(),
|
||||||
16 => "12885032961".to_string(),
|
16 => "12885032961".to_string(),
|
||||||
|
@ -2310,8 +2312,8 @@ mod biguint_tests {
|
||||||
}),
|
}),
|
||||||
(16,
|
(16,
|
||||||
format!("3{}2{}1",
|
format!("3{}2{}1",
|
||||||
"0".repeat(bits / 4 - 1),
|
repeat("0").take(bits / 4 - 1).collect::<String>(),
|
||||||
"0".repeat(bits / 4 - 1)))
|
repeat("0").take(bits / 4 - 1).collect::<String>()))
|
||||||
)) )
|
)) )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2447,12 +2449,13 @@ mod bigint_tests {
|
||||||
use super::Sign::{Minus, NoSign, Plus};
|
use super::Sign::{Minus, NoSign, Plus};
|
||||||
|
|
||||||
use std::cmp::Ordering::{Less, Equal, Greater};
|
use std::cmp::Ordering::{Less, Equal, Greater};
|
||||||
|
use std::hash::hash;
|
||||||
use std::i64;
|
use std::i64;
|
||||||
|
use std::iter::repeat;
|
||||||
use std::num::FromStrRadix;
|
use std::num::FromStrRadix;
|
||||||
use std::num::{ToPrimitive, FromPrimitive};
|
use std::num::{ToPrimitive, FromPrimitive};
|
||||||
use std::rand::task_rng;
|
use std::rand::task_rng;
|
||||||
use std::u64;
|
use std::u64;
|
||||||
use std::hash::hash;
|
|
||||||
|
|
||||||
use {Zero, One, Signed};
|
use {Zero, One, Signed};
|
||||||
|
|
||||||
|
@ -2972,7 +2975,7 @@ mod bigint_tests {
|
||||||
// issue 10522, this hit an edge case that caused it to
|
// issue 10522, this hit an edge case that caused it to
|
||||||
// attempt to allocate a vector of size (-1u) == huge.
|
// attempt to allocate a vector of size (-1u) == huge.
|
||||||
let x: BigInt =
|
let x: BigInt =
|
||||||
from_str(format!("1{}", "0".repeat(36)).as_slice()).unwrap();
|
format!("1{}", repeat("0").take(36).collect::<String>()).parse().unwrap();
|
||||||
let _y = x.to_string();
|
let _y = x.to_string();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -21,7 +21,7 @@ use {Zero, One, Num};
|
||||||
// probably doesn't map to C's _Complex correctly.
|
// probably doesn't map to C's _Complex correctly.
|
||||||
|
|
||||||
/// A complex number in Cartesian form.
|
/// A complex number in Cartesian form.
|
||||||
#[deriving(PartialEq, Copy, Clone, Hash, Encodable, Decodable)]
|
#[deriving(PartialEq, Copy, Clone, Hash, RustcEncodable, RustcDecodable)]
|
||||||
pub struct Complex<T> {
|
pub struct Complex<T> {
|
||||||
/// Real portion of the complex number
|
/// Real portion of the complex number
|
||||||
pub re: T,
|
pub re: T,
|
||||||
|
|
11
src/lib.rs
11
src/lib.rs
|
@ -45,18 +45,13 @@
|
||||||
#![feature(macro_rules)]
|
#![feature(macro_rules)]
|
||||||
#![feature(default_type_params)]
|
#![feature(default_type_params)]
|
||||||
#![feature(slicing_syntax)]
|
#![feature(slicing_syntax)]
|
||||||
|
#![cfg_attr(test, deny(warnings))]
|
||||||
#![crate_name = "num"]
|
|
||||||
#![experimental]
|
|
||||||
#![crate_type = "rlib"]
|
|
||||||
#![crate_type = "dylib"]
|
|
||||||
#![doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
|
#![doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
|
||||||
html_favicon_url = "http://www.rust-lang.org/favicon.ico",
|
html_favicon_url = "http://www.rust-lang.org/favicon.ico",
|
||||||
html_root_url = "http://doc.rust-lang.org/master/",
|
html_root_url = "http://doc.rust-lang.org/num/",
|
||||||
html_playground_url = "http://play.rust-lang.org/")]
|
html_playground_url = "http://play.rust-lang.org/")]
|
||||||
|
|
||||||
extern crate rand;
|
extern crate "rustc-serialize" as rustc_serialize;
|
||||||
extern crate serialize;
|
|
||||||
|
|
||||||
pub use bigint::{BigInt, BigUint};
|
pub use bigint::{BigInt, BigUint};
|
||||||
pub use rational::{Rational, BigRational};
|
pub use rational::{Rational, BigRational};
|
||||||
|
|
|
@ -22,7 +22,7 @@ use bigint::{BigInt, BigUint, Sign};
|
||||||
use {Num, Signed, Zero, One};
|
use {Num, Signed, Zero, One};
|
||||||
|
|
||||||
/// Represents the ratio between 2 numbers.
|
/// Represents the ratio between 2 numbers.
|
||||||
#[deriving(Copy, Clone, Hash, Encodable, Decodable)]
|
#[deriving(Copy, Clone, Hash, RustcEncodable, RustcDecodable)]
|
||||||
#[allow(missing_docs)]
|
#[allow(missing_docs)]
|
||||||
pub struct Ratio<T> {
|
pub struct Ratio<T> {
|
||||||
numer: T,
|
numer: T,
|
||||||
|
|
Loading…
Reference in New Issue