Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
e965ba85
R
Rust
项目概览
int
/
Rust
大约 1 年 前同步成功
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
Rust
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
e965ba85
编写于
11月 10, 2014
作者:
B
Brendan Zabarauskas
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Remove lots of numeric traits from the preludes
Num, NumCast, Unsigned, Float, Primitive and Int have been removed.
上级
891559e3
变更
48
显示空白变更内容
内联
并排
Showing
48 changed file
with
100 addition
and
66 deletion
+100
-66
src/doc/guide-lifetimes.md
src/doc/guide-lifetimes.md
+1
-0
src/doc/guide-tasks.md
src/doc/guide-tasks.md
+2
-0
src/libarena/lib.rs
src/libarena/lib.rs
+1
-1
src/libcollections/bit.rs
src/libcollections/bit.rs
+2
-0
src/libcollections/enum_set.rs
src/libcollections/enum_set.rs
+1
-0
src/libcollections/hash/mod.rs
src/libcollections/hash/mod.rs
+1
-0
src/libcollections/vec.rs
src/libcollections/vec.rs
+1
-1
src/libcore/num/f32.rs
src/libcore/num/f32.rs
+2
-0
src/libcore/num/f64.rs
src/libcore/num/f64.rs
+2
-0
src/libcore/num/mod.rs
src/libcore/num/mod.rs
+22
-0
src/libcore/prelude.rs
src/libcore/prelude.rs
+1
-3
src/libcoretest/iter.rs
src/libcoretest/iter.rs
+0
-46
src/libcoretest/num/int_macros.rs
src/libcoretest/num/int_macros.rs
+1
-0
src/libcoretest/num/mod.rs
src/libcoretest/num/mod.rs
+10
-2
src/libcoretest/num/uint_macros.rs
src/libcoretest/num/uint_macros.rs
+1
-0
src/librand/chacha.rs
src/librand/chacha.rs
+1
-0
src/librand/distributions/mod.rs
src/librand/distributions/mod.rs
+1
-0
src/librand/distributions/range.rs
src/librand/distributions/range.rs
+2
-0
src/librbml/lib.rs
src/librbml/lib.rs
+3
-2
src/librustc/back/lto.rs
src/librustc/back/lto.rs
+1
-0
src/librustc/middle/check_match.rs
src/librustc/middle/check_match.rs
+1
-0
src/librustc/middle/trans/type_of.rs
src/librustc/middle/trans/type_of.rs
+1
-0
src/librustc_back/sha2.rs
src/librustc_back/sha2.rs
+2
-0
src/libserialize/json.rs
src/libserialize/json.rs
+2
-1
src/libstd/fmt.rs
src/libstd/fmt.rs
+1
-0
src/libstd/num/f32.rs
src/libstd/num/f32.rs
+1
-0
src/libstd/num/f64.rs
src/libstd/num/f64.rs
+1
-0
src/libstd/num/mod.rs
src/libstd/num/mod.rs
+8
-1
src/libstd/prelude.rs
src/libstd/prelude.rs
+1
-3
src/libstd/rand/reader.rs
src/libstd/rand/reader.rs
+1
-0
src/libstd/sys/common/mod.rs
src/libstd/sys/common/mod.rs
+1
-0
src/libstd/sys/common/net.rs
src/libstd/sys/common/net.rs
+1
-0
src/libstd/sys/unix/mod.rs
src/libstd/sys/unix/mod.rs
+1
-0
src/libsyntax/ast.rs
src/libsyntax/ast.rs
+1
-0
src/libsyntax/parse/mod.rs
src/libsyntax/parse/mod.rs
+1
-0
src/libsyntax/parse/parser.rs
src/libsyntax/parse/parser.rs
+1
-0
src/libtest/lib.rs
src/libtest/lib.rs
+1
-0
src/libtest/stats.rs
src/libtest/stats.rs
+5
-4
src/test/bench/noise.rs
src/test/bench/noise.rs
+1
-0
src/test/bench/shootout-fasta.rs
src/test/bench/shootout-fasta.rs
+1
-0
src/test/bench/shootout-k-nucleotide-pipes.rs
src/test/bench/shootout-k-nucleotide-pipes.rs
+1
-0
src/test/bench/shootout-nbody.rs
src/test/bench/shootout-nbody.rs
+2
-0
src/test/bench/shootout-spectralnorm.rs
src/test/bench/shootout-spectralnorm.rs
+1
-0
src/test/bench/sudoku.rs
src/test/bench/sudoku.rs
+1
-0
src/test/run-pass/generic-extern-mangle.rs
src/test/run-pass/generic-extern-mangle.rs
+2
-0
src/test/run-pass/issue-11736.rs
src/test/run-pass/issue-11736.rs
+1
-0
src/test/run-pass/trait-inheritance-num2.rs
src/test/run-pass/trait-inheritance-num2.rs
+1
-0
src/test/run-pass/trait-inheritance-num3.rs
src/test/run-pass/trait-inheritance-num3.rs
+2
-2
未找到文件。
src/doc/guide-lifetimes.md
浏览文件 @
e965ba85
...
...
@@ -51,6 +51,7 @@ expensive. So we'd like to define a function that takes the points just as
a reference.
~~~
# use std::num::Float;
# struct Point {x: f64, y: f64}
# fn sqrt(f: f64) -> f64 { 0.0 }
fn compute_distance(p1: &Point, p2: &Point) -> f64 {
...
...
src/doc/guide-tasks.md
浏览文件 @
e965ba85
...
...
@@ -225,6 +225,7 @@ Here is another example showing how futures allow you to background
computations. The workload will be distributed on the available cores.
```
{rust}
# use std::num::Float;
# use std::sync::Future;
fn partial_sum(start: uint) -> f64 {
let mut local_sum = 0f64;
...
...
@@ -262,6 +263,7 @@ several computations on a single large vector of floats. Each task needs the
full vector to perform its duty.
```
{rust}
use std::num::Float;
use std::rand;
use std::sync::Arc;
...
...
src/libarena/lib.rs
浏览文件 @
e965ba85
...
...
@@ -38,7 +38,7 @@
use
std
::
intrinsics
::{
TyDesc
,
get_tydesc
};
use
std
::
intrinsics
;
use
std
::
mem
;
use
std
::
num
::
UnsignedInt
;
use
std
::
num
::
{
Int
,
UnsignedInt
}
;
use
std
::
ptr
;
use
std
::
rc
::
Rc
;
use
std
::
rt
::
heap
::{
allocate
,
deallocate
};
...
...
src/libcollections/bit.rs
浏览文件 @
e965ba85
...
...
@@ -22,6 +22,7 @@
//!
//! ```
//! use std::collections::{BitvSet, Bitv};
//! use std::num::Float;
//! use std::iter;
//!
//! let max_prime = 10000;
...
...
@@ -69,6 +70,7 @@
use
core
::
fmt
;
use
core
::
iter
::{
Chain
,
Enumerate
,
Repeat
,
Skip
,
Take
};
use
core
::
iter
;
use
core
::
num
::
Int
;
use
core
::
slice
;
use
core
::
u32
;
use
std
::
hash
;
...
...
src/libcollections/enum_set.rs
浏览文件 @
e965ba85
...
...
@@ -15,6 +15,7 @@
use
core
::
prelude
::
*
;
use
core
::
fmt
;
use
core
::
num
::
Int
;
// FIXME(contentions): implement union family of methods? (general design may be wrong here)
...
...
src/libcollections/hash/mod.rs
浏览文件 @
e965ba85
...
...
@@ -69,6 +69,7 @@
use
alloc
::
rc
::
Rc
;
use
core
::
intrinsics
::
TypeId
;
use
core
::
mem
;
use
core
::
num
::
Int
;
use
vec
::
Vec
;
...
...
src/libcollections/vec.rs
浏览文件 @
e965ba85
...
...
@@ -21,7 +21,7 @@
use
core
::
fmt
;
use
core
::
kinds
::
marker
::{
ContravariantLifetime
,
InvariantType
};
use
core
::
mem
;
use
core
::
num
::
UnsignedInt
;
use
core
::
num
::
{
Int
,
UnsignedInt
}
;
use
core
::
ops
;
use
core
::
ptr
;
use
core
::
raw
::
Slice
as
RawSlice
;
...
...
src/libcore/num/f32.rs
浏览文件 @
e965ba85
...
...
@@ -234,6 +234,8 @@ fn trunc(self) -> f32 {
/// The fractional part of the number, satisfying:
///
/// ```rust
/// use core::num::Float;
///
/// let x = 1.65f32;
/// assert!(x == x.trunc() + x.fract())
/// ```
...
...
src/libcore/num/f64.rs
浏览文件 @
e965ba85
...
...
@@ -240,6 +240,8 @@ fn trunc(self) -> f64 {
/// The fractional part of the number, satisfying:
///
/// ```rust
/// use core::num::Float;
///
/// let x = 1.65f64;
/// assert!(x == x.trunc() + x.fract())
/// ```
...
...
src/libcore/num/mod.rs
浏览文件 @
e965ba85
...
...
@@ -204,6 +204,8 @@ pub trait Int
/// # Example
///
/// ```rust
/// use std::num::Int;
///
/// let n = 0b01001100u8;
///
/// assert_eq!(n.count_ones(), 3);
...
...
@@ -215,6 +217,8 @@ pub trait Int
/// # Example
///
/// ```rust
/// use std::num::Int;
///
/// let n = 0b01001100u8;
///
/// assert_eq!(n.count_zeros(), 5);
...
...
@@ -230,6 +234,8 @@ fn count_zeros(self) -> uint {
/// # Example
///
/// ```rust
/// use std::num::Int;
///
/// let n = 0b0101000u16;
///
/// assert_eq!(n.leading_zeros(), 10);
...
...
@@ -242,6 +248,8 @@ fn count_zeros(self) -> uint {
/// # Example
///
/// ```rust
/// use std::num::Int;
///
/// let n = 0b0101000u16;
///
/// assert_eq!(n.trailing_zeros(), 3);
...
...
@@ -254,6 +262,8 @@ fn count_zeros(self) -> uint {
/// # Example
///
/// ```rust
/// use std::num::Int;
///
/// let n = 0x0123456789ABCDEFu64;
/// let m = 0x3456789ABCDEF012u64;
///
...
...
@@ -267,6 +277,8 @@ fn count_zeros(self) -> uint {
/// # Example
///
/// ```rust
/// use std::num::Int;
///
/// let n = 0x0123456789ABCDEFu64;
/// let m = 0xDEF0123456789ABCu64;
///
...
...
@@ -279,6 +291,8 @@ fn count_zeros(self) -> uint {
/// # Example
///
/// ```rust
/// use std::num::Int;
///
/// let n = 0x0123456789ABCDEFu64;
/// let m = 0xEFCDAB8967452301u64;
///
...
...
@@ -293,6 +307,8 @@ fn count_zeros(self) -> uint {
/// # Example
///
/// ```rust
/// use std::num::Int;
///
/// let n = 0x0123456789ABCDEFu64;
///
/// if cfg!(target_endian = "big") {
...
...
@@ -313,6 +329,8 @@ fn from_be(x: Self) -> Self {
/// # Example
///
/// ```rust
/// use std::num::Int;
///
/// let n = 0x0123456789ABCDEFu64;
///
/// if cfg!(target_endian = "little") {
...
...
@@ -333,6 +351,8 @@ fn from_le(x: Self) -> Self {
/// # Example
///
/// ```rust
/// use std::num::Int;
///
/// let n = 0x0123456789ABCDEFu64;
///
/// if cfg!(target_endian = "big") {
...
...
@@ -353,6 +373,8 @@ fn to_be(self) -> Self { // or not to be?
/// # Example
///
/// ```rust
/// use std::num::Int;
///
/// let n = 0x0123456789ABCDEFu64;
///
/// if cfg!(target_endian = "little") {
...
...
src/libcore/prelude.rs
浏览文件 @
e965ba85
...
...
@@ -51,9 +51,7 @@
pub
use
iter
::{
FromIterator
,
Extend
};
pub
use
iter
::{
Iterator
,
DoubleEndedIterator
,
RandomAccessIterator
,
CloneableIterator
};
pub
use
iter
::{
OrdIterator
,
MutableDoubleEndedIterator
,
ExactSize
};
pub
use
num
::{
Num
,
NumCast
};
pub
use
num
::{
Signed
,
Unsigned
,
Float
};
pub
use
num
::{
Primitive
,
Int
,
ToPrimitive
,
FromPrimitive
};
pub
use
num
::{
Signed
,
ToPrimitive
,
FromPrimitive
};
pub
use
option
::{
Option
,
Some
,
None
};
pub
use
ptr
::
RawPtr
;
pub
use
result
::{
Result
,
Ok
,
Err
};
...
...
src/libcoretest/iter.rs
浏览文件 @
e965ba85
...
...
@@ -12,7 +12,6 @@
use
core
::
iter
::
order
::
*
;
use
core
::
uint
;
use
core
::
cmp
;
use
core
::
num
;
use
core
::
ops
::
Slice
;
use
test
::
Bencher
;
...
...
@@ -689,50 +688,6 @@ fn test_double_ended_range() {
#[test]
fn
test_range
()
{
/// A mock type to check Range when ToPrimitive returns None
struct
Foo
;
impl
ToPrimitive
for
Foo
{
fn
to_i64
(
&
self
)
->
Option
<
i64
>
{
None
}
fn
to_u64
(
&
self
)
->
Option
<
u64
>
{
None
}
}
impl
Add
<
Foo
,
Foo
>
for
Foo
{
fn
add
(
&
self
,
_
:
&
Foo
)
->
Foo
{
Foo
}
}
impl
PartialEq
for
Foo
{
fn
eq
(
&
self
,
_
:
&
Foo
)
->
bool
{
true
}
}
impl
PartialOrd
for
Foo
{
fn
partial_cmp
(
&
self
,
_
:
&
Foo
)
->
Option
<
Ordering
>
{
None
}
}
impl
Clone
for
Foo
{
fn
clone
(
&
self
)
->
Foo
{
Foo
}
}
impl
Mul
<
Foo
,
Foo
>
for
Foo
{
fn
mul
(
&
self
,
_
:
&
Foo
)
->
Foo
{
Foo
}
}
impl
num
::
One
for
Foo
{
fn
one
()
->
Foo
{
Foo
}
}
assert
!
(
range
(
0
i
,
5
)
.collect
::
<
Vec
<
int
>>
()
==
vec!
[
0
i
,
1
,
2
,
3
,
4
]);
assert
!
(
range
(
-
10
i
,
-
1
)
.collect
::
<
Vec
<
int
>>
()
==
vec!
[
-
10
,
-
9
,
-
8
,
-
7
,
-
6
,
-
5
,
-
4
,
-
3
,
-
2
]);
...
...
@@ -746,7 +701,6 @@ fn one() -> Foo {
// this test is only meaningful when sizeof uint < sizeof u64
assert_eq!
(
range
(
uint
::
MAX
-
1
,
uint
::
MAX
)
.size_hint
(),
(
1
,
Some
(
1
)));
assert_eq!
(
range
(
-
10
i
,
-
1
)
.size_hint
(),
(
9
,
Some
(
9
)));
assert_eq!
(
range
(
Foo
,
Foo
)
.size_hint
(),
(
0
,
None
));
}
#[test]
...
...
src/libcoretest/num/int_macros.rs
浏览文件 @
e965ba85
...
...
@@ -15,6 +15,7 @@
mod
tests
{
use
core
::
$T_i
::
*
;
use
core
::
int
;
use
core
::
num
::
Int
;
use
num
;
#[test]
...
...
src/libcoretest/num/mod.rs
浏览文件 @
e965ba85
...
...
@@ -8,7 +8,10 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use
core
::
num
::
cast
;
use
core
::
cmp
::
PartialEq
;
use
core
::
fmt
::
Show
;
use
core
::
num
::{
NumCast
,
cast
};
use
core
::
ops
::{
Add
,
Sub
,
Mul
,
Div
,
Rem
};
mod
int_macros
;
mod
i8
;
...
...
@@ -24,7 +27,12 @@
mod
uint
;
/// Helper function for testing numeric operations
pub
fn
test_num
<
T
:
Int
+
::
std
::
fmt
::
Show
>
(
ten
:
T
,
two
:
T
)
{
pub
fn
test_num
<
T
>
(
ten
:
T
,
two
:
T
)
where
T
:
PartialEq
+
NumCast
+
Add
<
T
,
T
>
+
Sub
<
T
,
T
>
+
Mul
<
T
,
T
>
+
Div
<
T
,
T
>
+
Rem
<
T
,
T
>
+
Show
{
assert_eq!
(
ten
.add
(
&
two
),
cast
(
12
i
)
.unwrap
());
assert_eq!
(
ten
.sub
(
&
two
),
cast
(
8
i
)
.unwrap
());
assert_eq!
(
ten
.mul
(
&
two
),
cast
(
20
i
)
.unwrap
());
...
...
src/libcoretest/num/uint_macros.rs
浏览文件 @
e965ba85
...
...
@@ -14,6 +14,7 @@
#[cfg(test)]
mod
tests
{
use
core
::
$T_i
::
*
;
use
core
::
num
::
Int
;
use
num
;
#[test]
...
...
src/librand/chacha.rs
浏览文件 @
e965ba85
...
...
@@ -11,6 +11,7 @@
//! The ChaCha random number generator.
use
core
::
prelude
::
*
;
use
core
::
num
::
Int
;
use
{
Rng
,
SeedableRng
,
Rand
};
...
...
src/librand/distributions/mod.rs
浏览文件 @
e965ba85
...
...
@@ -23,6 +23,7 @@
#![experimental]
use
core
::
prelude
::
*
;
use
core
::
num
::
Int
;
use
{
Rng
,
Rand
};
...
...
src/librand/distributions/range.rs
浏览文件 @
e965ba85
...
...
@@ -13,6 +13,7 @@
// this is surprisingly complicated to be both generic & correct
use
core
::
prelude
::
*
;
use
core
::
num
::
Int
;
use
Rng
;
use
distributions
::{
Sample
,
IndependentSample
};
...
...
@@ -162,6 +163,7 @@ fn sample_range<R: Rng>(r: &Range<$ty>, rng: &mut R) -> $ty {
#[cfg(test)]
mod
tests
{
use
std
::
num
::
Int
;
use
std
::
prelude
::
*
;
use
distributions
::{
Sample
,
IndependentSample
};
use
super
::
Range
;
...
...
src/librbml/lib.rs
浏览文件 @
e965ba85
...
...
@@ -114,10 +114,11 @@ pub enum Error {
pub
mod
reader
{
use
std
::
char
;
use
std
::
mem
::
transmute
;
use
std
::
int
;
use
std
::
option
::{
None
,
Option
,
Some
};
use
std
::
io
::
extensions
::
u64_from_be_bytes
;
use
std
::
mem
::
transmute
;
use
std
::
num
::
Int
;
use
std
::
option
::{
None
,
Option
,
Some
};
use
serialize
;
...
...
src/librustc/back/lto.rs
浏览文件 @
e965ba85
...
...
@@ -23,6 +23,7 @@
use
std
::
iter
;
use
std
::
mem
;
use
std
::
num
::
Int
;
pub
fn
run
(
sess
:
&
session
::
Session
,
llmod
:
ModuleRef
,
tm
:
TargetMachineRef
,
reachable
:
&
[
String
])
{
...
...
src/librustc/middle/check_match.rs
浏览文件 @
e965ba85
...
...
@@ -21,6 +21,7 @@
use
std
::
fmt
;
use
std
::
iter
::
AdditiveIterator
;
use
std
::
iter
::
range_inclusive
;
use
std
::
num
::
Float
;
use
std
::
slice
;
use
syntax
::
ast
::
*
;
use
syntax
::
ast_util
::
walk_pat
;
...
...
src/librustc/middle/trans/type_of.rs
浏览文件 @
e965ba85
...
...
@@ -21,6 +21,7 @@
use
middle
::
trans
::
type_
::
Type
;
use
std
::
num
::
Int
;
use
syntax
::
abi
;
use
syntax
::
ast
;
...
...
src/librustc_back/sha2.rs
浏览文件 @
e965ba85
...
...
@@ -15,6 +15,7 @@
#![allow(deprecated)]
// to_be32
use
std
::
iter
::
range_step
;
use
std
::
num
::
Int
;
use
std
::
slice
::
bytes
::{
MutableByteVector
,
copy_memory
};
use
serialize
::
hex
::
ToHex
;
...
...
@@ -530,6 +531,7 @@ mod tests {
use
self
::
rand
::
isaac
::
IsaacRng
;
use
self
::
rand
::
Rng
;
use
serialize
::
hex
::
FromHex
;
use
std
::
num
::
Int
;
// A normal addition - no overflow occurs
#[test]
...
...
src/libserialize/json.rs
浏览文件 @
e965ba85
...
...
@@ -199,7 +199,7 @@ fn main() {
use
std
::{
char
,
f64
,
fmt
,
io
,
num
,
str
};
use
std
::
io
::
MemWriter
;
use
std
::
mem
::{
swap
,
transmute
};
use
std
::
num
::{
F
PNaN
,
FPInfinite
};
use
std
::
num
::{
F
loat
,
FPNaN
,
FPInfinite
,
Int
};
use
std
::
str
::
ScalarValue
;
use
std
::
string
;
use
std
::
vec
::
Vec
;
...
...
@@ -2455,6 +2455,7 @@ mod tests {
TrailingCharacters
,
TrailingComma
};
use
std
::{
i64
,
u64
,
f32
,
f64
,
io
};
use
std
::
collections
::
TreeMap
;
use
std
::
num
::
Float
;
use
std
::
string
;
#[deriving(Decodable,
Eq,
PartialEq,
Show)]
...
...
src/libstd/fmt.rs
浏览文件 @
e965ba85
...
...
@@ -190,6 +190,7 @@
```rust
use std::fmt;
use std::f64;
use std::num::Float;
struct Vector2D {
x: int,
...
...
src/libstd/num/f32.rs
浏览文件 @
e965ba85
...
...
@@ -20,6 +20,7 @@
use
from_str
::
FromStr
;
use
intrinsics
;
use
libc
::
c_int
;
use
num
::{
Float
,
FloatMath
};
use
num
::
strconv
;
use
num
;
...
...
src/libstd/num/f64.rs
浏览文件 @
e965ba85
...
...
@@ -19,6 +19,7 @@
use
from_str
::
FromStr
;
use
intrinsics
;
use
libc
::
c_int
;
use
num
::{
Float
,
FloatMath
};
use
num
::
strconv
;
use
num
;
...
...
src/libstd/num/mod.rs
浏览文件 @
e965ba85
...
...
@@ -18,7 +18,9 @@
use
option
::
Option
;
#[cfg(test)]
use
cmp
::
PartialEq
;
#[cfg(test)]
use
fmt
::
Show
;
#[cfg(test)]
use
ops
::{
Add
,
Sub
,
Mul
,
Div
,
Rem
};
pub
use
core
::
num
::{
Num
,
div_rem
,
Zero
,
zero
,
One
,
one
};
pub
use
core
::
num
::{
Signed
,
abs
,
signum
};
...
...
@@ -135,7 +137,12 @@ pub fn abs_sub<T: FloatMath>(x: T, y: T) -> T {
/// Helper function for testing numeric operations
#[cfg(test)]
pub
fn
test_num
<
T
:
Int
+
Show
>
(
ten
:
T
,
two
:
T
)
{
pub
fn
test_num
<
T
>
(
ten
:
T
,
two
:
T
)
where
T
:
PartialEq
+
NumCast
+
Add
<
T
,
T
>
+
Sub
<
T
,
T
>
+
Mul
<
T
,
T
>
+
Div
<
T
,
T
>
+
Rem
<
T
,
T
>
+
Show
{
assert_eq!
(
ten
.add
(
&
two
),
cast
(
12
i
)
.unwrap
());
assert_eq!
(
ten
.sub
(
&
two
),
cast
(
8
i
)
.unwrap
());
assert_eq!
(
ten
.mul
(
&
two
),
cast
(
20
i
)
.unwrap
());
...
...
src/libstd/prelude.rs
浏览文件 @
e965ba85
...
...
@@ -67,9 +67,7 @@
#[doc(no_inline)]
pub
use
iter
::{
Iterator
,
DoubleEndedIterator
};
#[doc(no_inline)]
pub
use
iter
::{
RandomAccessIterator
,
CloneableIterator
};
#[doc(no_inline)]
pub
use
iter
::{
OrdIterator
,
MutableDoubleEndedIterator
};
#[doc(no_inline)]
pub
use
num
::{
Num
,
NumCast
};
#[doc(no_inline)]
pub
use
num
::{
Signed
,
Unsigned
,
Primitive
,
Int
,
Float
};
#[doc(no_inline)]
pub
use
num
::{
FloatMath
,
ToPrimitive
,
FromPrimitive
};
#[doc(no_inline)]
pub
use
num
::{
Signed
,
ToPrimitive
,
FromPrimitive
};
#[doc(no_inline)]
pub
use
boxed
::
Box
;
#[doc(no_inline)]
pub
use
option
::{
Option
,
Some
,
None
};
#[doc(no_inline)]
pub
use
path
::{
GenericPath
,
Path
,
PosixPath
,
WindowsPath
};
...
...
src/libstd/rand/reader.rs
浏览文件 @
e965ba85
...
...
@@ -78,6 +78,7 @@ mod test {
use
super
::
ReaderRng
;
use
io
::
MemReader
;
use
num
::
Int
;
use
rand
::
Rng
;
#[test]
...
...
src/libstd/sys/common/mod.rs
浏览文件 @
e965ba85
...
...
@@ -15,6 +15,7 @@
use
prelude
::
*
;
use
sys
::{
last_error
,
retry
,
fs
};
use
c_str
::
CString
;
use
num
::
Int
;
use
path
::
BytesContainer
;
use
collections
;
...
...
src/libstd/sys/common/net.rs
浏览文件 @
e965ba85
...
...
@@ -11,6 +11,7 @@
use
alloc
::
arc
::
Arc
;
use
libc
::{
mod
,
c_char
,
c_int
};
use
mem
;
use
num
::
Int
;
use
ptr
::{
mod
,
null
,
null_mut
};
use
rt
::
mutex
;
use
io
::
net
::
ip
::{
SocketAddr
,
IpAddr
,
Ipv4Addr
,
Ipv6Addr
};
...
...
src/libstd/sys/unix/mod.rs
浏览文件 @
e965ba85
...
...
@@ -18,6 +18,7 @@
extern
crate
libc
;
use
num
;
use
num
::
Int
;
use
prelude
::
*
;
use
io
::{
mod
,
IoResult
,
IoError
};
use
sys_common
::
mkerr_libc
;
...
...
src/libsyntax/ast.rs
浏览文件 @
e965ba85
...
...
@@ -20,6 +20,7 @@
use
std
::
fmt
;
use
std
::
fmt
::
Show
;
use
std
::
num
::
Int
;
use
std
::
rc
::
Rc
;
use
serialize
::{
Encodable
,
Decodable
,
Encoder
,
Decoder
};
...
...
src/libsyntax/parse/mod.rs
浏览文件 @
e965ba85
...
...
@@ -20,6 +20,7 @@
use
std
::
cell
::{
Cell
,
RefCell
};
use
std
::
io
::
File
;
use
std
::
rc
::
Rc
;
use
std
::
num
::
Int
;
use
std
::
str
;
use
std
::
iter
;
...
...
src/libsyntax/parse/parser.rs
浏览文件 @
e965ba85
...
...
@@ -87,6 +87,7 @@
use
std
::
io
::
fs
::
PathExtensions
;
use
std
::
mem
::
replace
;
use
std
::
mem
;
use
std
::
num
::
Float
;
use
std
::
rc
::
Rc
;
use
std
::
iter
;
...
...
src/libtest/lib.rs
浏览文件 @
e965ba85
...
...
@@ -60,6 +60,7 @@
use
std
::
io
::
stdio
::
StdWriter
;
use
std
::
io
::{
File
,
ChanReader
,
ChanWriter
};
use
std
::
io
;
use
std
::
num
::{
Int
,
FloatMath
};
use
std
::
os
;
use
std
::
string
::
String
;
use
std
::
task
::
TaskBuilder
;
...
...
src/libtest/stats.rs
浏览文件 @
e965ba85
...
...
@@ -16,6 +16,7 @@
use
std
::
hash
::
Hash
;
use
std
::
io
;
use
std
::
mem
;
use
std
::
num
::{
Float
,
FloatMath
};
fn
local_cmp
<
T
:
Float
>
(
x
:
T
,
y
:
T
)
->
Ordering
{
// arbitrarily decide that NaNs are larger than everything.
...
...
@@ -1042,11 +1043,11 @@ fn t(s: &Summary<f64>, expected: String) {
}
#[test]
fn
test_sum_f64s
()
{
assert_eq!
([
0.5f64
,
3.2321f64
,
1.5678f64
]
.sum
(
0.0
),
5.2999
);
assert_eq!
([
0.5f64
,
3.2321f64
,
1.5678f64
]
.sum
(),
5.2999
);
}
#[test]
fn
test_sum_f64_between_ints_that_sum_to_0
()
{
assert_eq!
([
1e30f64
,
1.2f64
,
-
1e30f64
]
.sum
(
0.0
),
1.2
);
assert_eq!
([
1e30f64
,
1.2f64
,
-
1e30f64
]
.sum
(),
1.2
);
}
}
...
...
@@ -1058,7 +1059,7 @@ mod bench {
#[bench]
pub
fn
sum_three_items
(
b
:
&
mut
Bencher
)
{
b
.iter
(||
{
[
1e20f64
,
1.5f64
,
-
1e20f64
]
.sum
(
0.0
);
[
1e20f64
,
1.5f64
,
-
1e20f64
]
.sum
();
})
}
#[bench]
...
...
@@ -1067,7 +1068,7 @@ pub fn sum_many_f64(b: &mut Bencher) {
let
v
=
Vec
::
from_fn
(
500
,
|
i
|
nums
[
i
%
5
]);
b
.iter
(||
{
v
.as_slice
()
.sum
(
0.0
);
v
.as_slice
()
.sum
();
})
}
}
src/test/bench/noise.rs
浏览文件 @
e965ba85
...
...
@@ -13,6 +13,7 @@
// ignore-lexer-test FIXME #15679
use
std
::
f32
::
consts
::
PI
;
use
std
::
num
::{
Float
,
FloatMath
};
use
std
::
rand
::{
Rng
,
StdRng
};
struct
Vec2
{
...
...
src/test/bench/shootout-fasta.rs
浏览文件 @
e965ba85
...
...
@@ -43,6 +43,7 @@
use
std
::
io
;
use
std
::
io
::{
BufferedWriter
,
File
};
use
std
::
cmp
::
min
;
use
std
::
num
::
Float
;
use
std
::
os
;
const
LINE_LENGTH
:
uint
=
60
;
...
...
src/test/bench/shootout-k-nucleotide-pipes.rs
浏览文件 @
e965ba85
...
...
@@ -19,6 +19,7 @@
use
std
::
collections
::
HashMap
;
use
std
::
mem
::
replace
;
use
std
::
num
::
Float
;
use
std
::
option
;
use
std
::
os
;
use
std
::
string
::
String
;
...
...
src/test/bench/shootout-nbody.rs
浏览文件 @
e965ba85
...
...
@@ -38,6 +38,8 @@
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
// OF THE POSSIBILITY OF SUCH DAMAGE.
use
std
::
num
::
Float
;
const
PI
:
f64
=
3.141592653589793
;
const
SOLAR_MASS
:
f64
=
4.0
*
PI
*
PI
;
const
YEAR
:
f64
=
365.24
;
...
...
src/test/bench/shootout-spectralnorm.rs
浏览文件 @
e965ba85
...
...
@@ -45,6 +45,7 @@
use
std
::
iter
::
AdditiveIterator
;
use
std
::
mem
;
use
std
::
num
::
Float
;
use
std
::
os
;
use
std
::
raw
::
Repr
;
use
std
::
simd
::
f64x2
;
...
...
src/test/bench/sudoku.rs
浏览文件 @
e965ba85
...
...
@@ -15,6 +15,7 @@
use
std
::
io
;
use
std
::
io
::
stdio
::
StdReader
;
use
std
::
io
::
BufferedReader
;
use
std
::
num
::
Int
;
use
std
::
os
;
// Computes a single solution to a given 9x9 sudoku
...
...
src/test/run-pass/generic-extern-mangle.rs
浏览文件 @
e965ba85
...
...
@@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use
std
::
num
::
Int
;
extern
"C"
fn
foo
<
T
:
Int
>
(
a
:
T
,
b
:
T
)
->
T
{
a
+
b
}
fn
main
()
{
...
...
src/test/run-pass/issue-11736.rs
浏览文件 @
e965ba85
...
...
@@ -11,6 +11,7 @@
extern
crate
collections
;
use
std
::
collections
::
Bitv
;
use
std
::
num
::
Float
;
fn
main
()
{
// Generate sieve of Eratosthenes for n up to 1e6
...
...
src/test/run-pass/trait-inheritance-num2.rs
浏览文件 @
e965ba85
...
...
@@ -12,6 +12,7 @@
// A more complex example of numeric extensions
use
std
::
cmp
::{
PartialEq
,
PartialOrd
};
use
std
::
num
::
NumCast
;
pub
trait
TypeExt
{}
...
...
src/test/run-pass/trait-inheritance-num3.rs
浏览文件 @
e965ba85
...
...
@@ -11,11 +11,11 @@
use
std
::
cmp
::{
PartialEq
,
PartialOrd
};
use
std
::
num
::
NumCast
;
pub
trait
NumExt
:
PartialEq
+
PartialOrd
+
Num
+
Num
Cast
{}
pub
trait
NumExt
:
PartialEq
+
PartialOrd
+
NumCast
{}
impl
NumExt
for
f32
{}
fn
num_eq_one
<
T
:
NumExt
>
(
n
:
T
)
{
fn
num_eq_one
<
T
:
NumExt
>
(
n
:
T
)
{
println!
(
"{}"
,
n
==
NumCast
::
from
(
1
i
)
.unwrap
())
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录