Przeglądaj źródła

Update to rust master

Alex Crichton 10 lat temu
rodzic
commit
e2f0b0d327
3 zmienionych plików z 11 dodań i 6 usunięć
  1. 1 0
      Cargo.toml
  2. 8 5
      src/bigint.rs
  3. 2 1
      src/lib.rs

+ 1 - 0
Cargo.toml

@@ -15,3 +15,4 @@ rational, and complex types.
 
 [dependencies]
 rustc-serialize = "0.2"
+rand = "0.1"

+ 8 - 5
src/bigint.rs

@@ -41,9 +41,10 @@
 //! It's easy to generate large random numbers:
 //!
 //! ```rust
-//! # #![allow(unstable)]
+//! extern crate rand;
+//! extern crate num;
+//! # fn main() {
 //! use num::bigint::{ToBigInt, RandBigInt};
-//! use std::rand;
 //!
 //! let mut rng = rand::thread_rng();
 //! let a = rng.gen_bigint(1000);
@@ -54,6 +55,7 @@
 //!
 //! // Probably an even larger number.
 //! println!("{}", a * b);
+//! # }
 //! ```
 
 extern crate "rustc-serialize" as rustc_serialize;
@@ -67,12 +69,12 @@ use std::error::{Error, FromError};
 use std::iter::repeat;
 use std::num::{Int, ToPrimitive, FromPrimitive, FromStrRadix};
 use std::ops::{Add, BitAnd, BitOr, BitXor, Div, Mul, Neg, Rem, Shl, Shr, Sub};
-use std::rand::Rng;
 use std::str::{self, FromStr};
 use std::{cmp, fmt, hash, mem};
 use std::cmp::Ordering::{self, Less, Greater, Equal};
 use std::{i64, u64};
 
+use rand::Rng;
 use rustc_serialize::hex::ToHex;
 
 use {Num, Unsigned, CheckedAdd, CheckedSub, CheckedMul, CheckedDiv, Signed, Zero, One};
@@ -1785,10 +1787,10 @@ mod biguint_tests {
     use std::iter::repeat;
     use std::num::FromStrRadix;
     use std::num::{ToPrimitive, FromPrimitive};
-    use std::rand::thread_rng;
     use std::str::FromStr;
     use std::u64;
 
+    use rand::thread_rng;
     use {Zero, One, CheckedAdd, CheckedSub, CheckedMul, CheckedDiv};
 
     #[test]
@@ -2713,10 +2715,11 @@ mod bigint_tests {
     use std::iter::repeat;
     use std::num::FromStrRadix;
     use std::num::{ToPrimitive, FromPrimitive};
-    use std::rand::thread_rng;
     use std::u64;
     use std::ops::{Neg};
 
+    use rand::thread_rng;
+
     use {Zero, One, Signed};
 
     #[test]

+ 2 - 1
src/lib.rs

@@ -44,7 +44,7 @@
 //!
 //! [newt]: https://en.wikipedia.org/wiki/Methods_of_computing_square_roots#Babylonian_method
 
-#![feature(slicing_syntax, collections, core, hash, rand, std_misc)]
+#![feature(slicing_syntax, collections, core, hash, std_misc)]
 #![cfg_attr(test, deny(warnings))]
 #![cfg_attr(test, feature(test))]
 #![doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
@@ -54,6 +54,7 @@
 
 extern crate "rustc-serialize" as rustc_serialize;
 extern crate core;
+extern crate rand;
 
 pub use bigint::{BigInt, BigUint};
 pub use rational::{Rational, BigRational};