Skip to content

Commit e965ba8

Browse files
committed
Remove lots of numeric traits from the preludes
Num, NumCast, Unsigned, Float, Primitive and Int have been removed.
1 parent 891559e commit e965ba8

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+100
-66
lines changed

src/doc/guide-lifetimes.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ expensive. So we'd like to define a function that takes the points just as
5151
a reference.
5252

5353
~~~
54+
# use std::num::Float;
5455
# struct Point {x: f64, y: f64}
5556
# fn sqrt(f: f64) -> f64 { 0.0 }
5657
fn compute_distance(p1: &Point, p2: &Point) -> f64 {

src/doc/guide-tasks.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,7 @@ Here is another example showing how futures allow you to background
225225
computations. The workload will be distributed on the available cores.
226226

227227
```{rust}
228+
# use std::num::Float;
228229
# use std::sync::Future;
229230
fn partial_sum(start: uint) -> f64 {
230231
let mut local_sum = 0f64;
@@ -262,6 +263,7 @@ several computations on a single large vector of floats. Each task needs the
262263
full vector to perform its duty.
263264

264265
```{rust}
266+
use std::num::Float;
265267
use std::rand;
266268
use std::sync::Arc;
267269

src/libarena/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ use std::cmp;
3838
use std::intrinsics::{TyDesc, get_tydesc};
3939
use std::intrinsics;
4040
use std::mem;
41-
use std::num::UnsignedInt;
41+
use std::num::{Int, UnsignedInt};
4242
use std::ptr;
4343
use std::rc::Rc;
4444
use std::rt::heap::{allocate, deallocate};

src/libcollections/bit.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
//!
2323
//! ```
2424
//! use std::collections::{BitvSet, Bitv};
25+
//! use std::num::Float;
2526
//! use std::iter;
2627
//!
2728
//! let max_prime = 10000;
@@ -69,6 +70,7 @@ use core::default::Default;
6970
use core::fmt;
7071
use core::iter::{Chain, Enumerate, Repeat, Skip, Take};
7172
use core::iter;
73+
use core::num::Int;
7274
use core::slice;
7375
use core::u32;
7476
use std::hash;

src/libcollections/enum_set.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
1616
use core::prelude::*;
1717
use core::fmt;
18+
use core::num::Int;
1819

1920
// FIXME(contentions): implement union family of methods? (general design may be wrong here)
2021

src/libcollections/hash/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ use alloc::boxed::Box;
6969
use alloc::rc::Rc;
7070
use core::intrinsics::TypeId;
7171
use core::mem;
72+
use core::num::Int;
7273

7374
use vec::Vec;
7475

src/libcollections/vec.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ use core::default::Default;
2121
use core::fmt;
2222
use core::kinds::marker::{ContravariantLifetime, InvariantType};
2323
use core::mem;
24-
use core::num::UnsignedInt;
24+
use core::num::{Int, UnsignedInt};
2525
use core::ops;
2626
use core::ptr;
2727
use core::raw::Slice as RawSlice;

src/libcore/num/f32.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,8 @@ impl Float for f32 {
234234
/// The fractional part of the number, satisfying:
235235
///
236236
/// ```rust
237+
/// use core::num::Float;
238+
///
237239
/// let x = 1.65f32;
238240
/// assert!(x == x.trunc() + x.fract())
239241
/// ```

src/libcore/num/f64.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,8 @@ impl Float for f64 {
240240
/// The fractional part of the number, satisfying:
241241
///
242242
/// ```rust
243+
/// use core::num::Float;
244+
///
243245
/// let x = 1.65f64;
244246
/// assert!(x == x.trunc() + x.fract())
245247
/// ```

src/libcore/num/mod.rs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,8 @@ pub trait Int
204204
/// # Example
205205
///
206206
/// ```rust
207+
/// use std::num::Int;
208+
///
207209
/// let n = 0b01001100u8;
208210
///
209211
/// assert_eq!(n.count_ones(), 3);
@@ -215,6 +217,8 @@ pub trait Int
215217
/// # Example
216218
///
217219
/// ```rust
220+
/// use std::num::Int;
221+
///
218222
/// let n = 0b01001100u8;
219223
///
220224
/// assert_eq!(n.count_zeros(), 5);
@@ -230,6 +234,8 @@ pub trait Int
230234
/// # Example
231235
///
232236
/// ```rust
237+
/// use std::num::Int;
238+
///
233239
/// let n = 0b0101000u16;
234240
///
235241
/// assert_eq!(n.leading_zeros(), 10);
@@ -242,6 +248,8 @@ pub trait Int
242248
/// # Example
243249
///
244250
/// ```rust
251+
/// use std::num::Int;
252+
///
245253
/// let n = 0b0101000u16;
246254
///
247255
/// assert_eq!(n.trailing_zeros(), 3);
@@ -254,6 +262,8 @@ pub trait Int
254262
/// # Example
255263
///
256264
/// ```rust
265+
/// use std::num::Int;
266+
///
257267
/// let n = 0x0123456789ABCDEFu64;
258268
/// let m = 0x3456789ABCDEF012u64;
259269
///
@@ -267,6 +277,8 @@ pub trait Int
267277
/// # Example
268278
///
269279
/// ```rust
280+
/// use std::num::Int;
281+
///
270282
/// let n = 0x0123456789ABCDEFu64;
271283
/// let m = 0xDEF0123456789ABCu64;
272284
///
@@ -279,6 +291,8 @@ pub trait Int
279291
/// # Example
280292
///
281293
/// ```rust
294+
/// use std::num::Int;
295+
///
282296
/// let n = 0x0123456789ABCDEFu64;
283297
/// let m = 0xEFCDAB8967452301u64;
284298
///
@@ -293,6 +307,8 @@ pub trait Int
293307
/// # Example
294308
///
295309
/// ```rust
310+
/// use std::num::Int;
311+
///
296312
/// let n = 0x0123456789ABCDEFu64;
297313
///
298314
/// if cfg!(target_endian = "big") {
@@ -313,6 +329,8 @@ pub trait Int
313329
/// # Example
314330
///
315331
/// ```rust
332+
/// use std::num::Int;
333+
///
316334
/// let n = 0x0123456789ABCDEFu64;
317335
///
318336
/// if cfg!(target_endian = "little") {
@@ -333,6 +351,8 @@ pub trait Int
333351
/// # Example
334352
///
335353
/// ```rust
354+
/// use std::num::Int;
355+
///
336356
/// let n = 0x0123456789ABCDEFu64;
337357
///
338358
/// if cfg!(target_endian = "big") {
@@ -353,6 +373,8 @@ pub trait Int
353373
/// # Example
354374
///
355375
/// ```rust
376+
/// use std::num::Int;
377+
///
356378
/// let n = 0x0123456789ABCDEFu64;
357379
///
358380
/// if cfg!(target_endian = "little") {

0 commit comments

Comments
 (0)