Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
d46dca66
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,发现更多精彩内容 >>
提交
d46dca66
编写于
8月 04, 2018
作者:
L
ljedrz
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Remove redundant field names in structs
上级
579adf8c
变更
11
隐藏空白更改
内联
并排
Showing
11 changed file
with
50 addition
and
50 deletion
+50
-50
src/libcore/cell.rs
src/libcore/cell.rs
+3
-3
src/libcore/iter/iterator.rs
src/libcore/iter/iterator.rs
+9
-9
src/libcore/num/dec2flt/parse.rs
src/libcore/num/dec2flt/parse.rs
+1
-1
src/libcore/num/dec2flt/rawfp.rs
src/libcore/num/dec2flt/rawfp.rs
+3
-3
src/libcore/num/diy_float.rs
src/libcore/num/diy_float.rs
+2
-2
src/libcore/num/flt2dec/decoder.rs
src/libcore/num/flt2dec/decoder.rs
+2
-2
src/libcore/num/flt2dec/mod.rs
src/libcore/num/flt2dec/mod.rs
+18
-18
src/libcore/num/flt2dec/strategy/grisu.rs
src/libcore/num/flt2dec/strategy/grisu.rs
+1
-1
src/libcore/slice/mod.rs
src/libcore/slice/mod.rs
+6
-6
src/libcore/task/context.rs
src/libcore/task/context.rs
+1
-1
src/libcore/time.rs
src/libcore/time.rs
+4
-4
未找到文件。
src/libcore/cell.rs
浏览文件 @
d46dca66
...
...
@@ -1258,7 +1258,7 @@ pub fn map<U: ?Sized, F>(orig: RefMut<'b, T>, f: F) -> RefMut<'b, U>
let
RefMut
{
value
,
borrow
}
=
orig
;
RefMut
{
value
:
f
(
value
),
borrow
:
borrow
,
borrow
,
}
}
...
...
@@ -1324,7 +1324,7 @@ fn new(borrow: &'b Cell<BorrowFlag>) -> Option<BorrowRefMut<'b>> {
match
borrow
.get
()
{
UNUSED
=>
{
borrow
.set
(
UNUSED
-
1
);
Some
(
BorrowRefMut
{
borrow
:
borrow
})
Some
(
BorrowRefMut
{
borrow
})
},
_
=>
None
,
}
...
...
@@ -1467,7 +1467,7 @@ impl<T> UnsafeCell<T> {
#[stable(feature
=
"rust1"
,
since
=
"1.0.0"
)]
#[inline]
pub
const
fn
new
(
value
:
T
)
->
UnsafeCell
<
T
>
{
UnsafeCell
{
value
:
value
}
UnsafeCell
{
value
}
}
/// Unwraps the value.
...
...
src/libcore/iter/iterator.rs
浏览文件 @
d46dca66
...
...
@@ -507,7 +507,7 @@ fn zip<U>(self, other: U) -> Zip<Self, U::IntoIter> where
fn
map
<
B
,
F
>
(
self
,
f
:
F
)
->
Map
<
Self
,
F
>
where
Self
:
Sized
,
F
:
FnMut
(
Self
::
Item
)
->
B
,
{
Map
{
iter
:
self
,
f
:
f
}
Map
{
iter
:
self
,
f
}
}
/// Calls a closure on each element of an iterator.
...
...
@@ -618,7 +618,7 @@ fn for_each<F>(self, mut f: F) where
fn
filter
<
P
>
(
self
,
predicate
:
P
)
->
Filter
<
Self
,
P
>
where
Self
:
Sized
,
P
:
FnMut
(
&
Self
::
Item
)
->
bool
,
{
Filter
{
iter
:
self
,
predicate
:
predicate
}
Filter
{
iter
:
self
,
predicate
}
}
/// Creates an iterator that both filters and maps.
...
...
@@ -675,7 +675,7 @@ fn filter<P>(self, predicate: P) -> Filter<Self, P> where
fn
filter_map
<
B
,
F
>
(
self
,
f
:
F
)
->
FilterMap
<
Self
,
F
>
where
Self
:
Sized
,
F
:
FnMut
(
Self
::
Item
)
->
Option
<
B
>
,
{
FilterMap
{
iter
:
self
,
f
:
f
}
FilterMap
{
iter
:
self
,
f
}
}
/// Creates an iterator which gives the current iteration count as well as
...
...
@@ -828,7 +828,7 @@ fn peekable(self) -> Peekable<Self> where Self: Sized {
fn
skip_while
<
P
>
(
self
,
predicate
:
P
)
->
SkipWhile
<
Self
,
P
>
where
Self
:
Sized
,
P
:
FnMut
(
&
Self
::
Item
)
->
bool
,
{
SkipWhile
{
iter
:
self
,
flag
:
false
,
predicate
:
predicate
}
SkipWhile
{
iter
:
self
,
flag
:
false
,
predicate
}
}
/// Creates an iterator that yields elements based on a predicate.
...
...
@@ -908,7 +908,7 @@ fn skip_while<P>(self, predicate: P) -> SkipWhile<Self, P> where
fn
take_while
<
P
>
(
self
,
predicate
:
P
)
->
TakeWhile
<
Self
,
P
>
where
Self
:
Sized
,
P
:
FnMut
(
&
Self
::
Item
)
->
bool
,
{
TakeWhile
{
iter
:
self
,
flag
:
false
,
predicate
:
predicate
}
TakeWhile
{
iter
:
self
,
flag
:
false
,
predicate
}
}
/// Creates an iterator that skips the first `n` elements.
...
...
@@ -930,7 +930,7 @@ fn take_while<P>(self, predicate: P) -> TakeWhile<Self, P> where
#[inline]
#[stable(feature
=
"rust1"
,
since
=
"1.0.0"
)]
fn
skip
(
self
,
n
:
usize
)
->
Skip
<
Self
>
where
Self
:
Sized
{
Skip
{
iter
:
self
,
n
:
n
}
Skip
{
iter
:
self
,
n
}
}
/// Creates an iterator that yields its first `n` elements.
...
...
@@ -962,7 +962,7 @@ fn skip(self, n: usize) -> Skip<Self> where Self: Sized {
#[inline]
#[stable(feature
=
"rust1"
,
since
=
"1.0.0"
)]
fn
take
(
self
,
n
:
usize
)
->
Take
<
Self
>
where
Self
:
Sized
,
{
Take
{
iter
:
self
,
n
:
n
}
Take
{
iter
:
self
,
n
}
}
/// An iterator adaptor similar to [`fold`] that holds internal state and
...
...
@@ -1007,7 +1007,7 @@ fn take(self, n: usize) -> Take<Self> where Self: Sized, {
fn
scan
<
St
,
B
,
F
>
(
self
,
initial_state
:
St
,
f
:
F
)
->
Scan
<
Self
,
St
,
F
>
where
Self
:
Sized
,
F
:
FnMut
(
&
mut
St
,
Self
::
Item
)
->
Option
<
B
>
,
{
Scan
{
iter
:
self
,
f
:
f
,
state
:
initial_state
}
Scan
{
iter
:
self
,
f
,
state
:
initial_state
}
}
/// Creates an iterator that works like map, but flattens nested structure.
...
...
@@ -1256,7 +1256,7 @@ fn fuse(self) -> Fuse<Self> where Self: Sized {
fn
inspect
<
F
>
(
self
,
f
:
F
)
->
Inspect
<
Self
,
F
>
where
Self
:
Sized
,
F
:
FnMut
(
&
Self
::
Item
),
{
Inspect
{
iter
:
self
,
f
:
f
}
Inspect
{
iter
:
self
,
f
}
}
/// Borrows an iterator, rather than consuming it.
...
...
src/libcore/num/dec2flt/parse.rs
浏览文件 @
d46dca66
...
...
@@ -40,7 +40,7 @@ pub struct Decimal<'a> {
impl
<
'a
>
Decimal
<
'a
>
{
pub
fn
new
(
integral
:
&
'a
[
u8
],
fractional
:
&
'a
[
u8
],
exp
:
i64
)
->
Decimal
<
'a
>
{
Decimal
{
integral
:
integral
,
fractional
:
fractional
,
exp
:
exp
}
Decimal
{
integral
,
fractional
,
exp
}
}
}
...
...
src/libcore/num/dec2flt/rawfp.rs
浏览文件 @
d46dca66
...
...
@@ -45,7 +45,7 @@ pub struct Unpacked {
impl
Unpacked
{
pub
fn
new
(
sig
:
u64
,
k
:
i16
)
->
Self
{
Unpacked
{
sig
:
sig
,
k
:
k
}
Unpacked
{
sig
,
k
}
}
}
...
...
@@ -317,13 +317,13 @@ pub fn big_to_fp(f: &Big) -> Fp {
// We cut off all bits prior to the index `start`, i.e., we effectively right-shift by
// an amount of `start`, so this is also the exponent we need.
let
e
=
start
as
i16
;
let
rounded_down
=
Fp
{
f
:
leading
,
e
:
e
}
.normalize
();
let
rounded_down
=
Fp
{
f
:
leading
,
e
}
.normalize
();
// Round (half-to-even) depending on the truncated bits.
match
num
::
compare_with_half_ulp
(
f
,
start
)
{
Less
=>
rounded_down
,
Equal
if
leading
%
2
==
0
=>
rounded_down
,
Equal
|
Greater
=>
match
leading
.checked_add
(
1
)
{
Some
(
f
)
=>
Fp
{
f
:
f
,
e
:
e
}
.normalize
(),
Some
(
f
)
=>
Fp
{
f
,
e
}
.normalize
(),
None
=>
Fp
{
f
:
1
<<
63
,
e
:
e
+
1
},
}
}
...
...
src/libcore/num/diy_float.rs
浏览文件 @
d46dca66
...
...
@@ -42,7 +42,7 @@ pub fn mul(&self, other: &Fp) -> Fp {
let
tmp
=
(
bd
>>
32
)
+
(
ad
&
MASK
)
+
(
bc
&
MASK
)
+
(
1
<<
31
)
/* round */
;
let
f
=
ac
+
(
ad
>>
32
)
+
(
bc
>>
32
)
+
(
tmp
>>
32
);
let
e
=
self
.e
+
other
.e
+
64
;
Fp
{
f
:
f
,
e
:
e
}
Fp
{
f
,
e
}
}
/// Normalizes itself so that the resulting mantissa is at least `2^63`.
...
...
@@ -74,7 +74,7 @@ pub fn normalize(&self) -> Fp {
e
-=
1
;
}
debug_assert!
(
f
>=
(
1
>>
63
));
Fp
{
f
:
f
,
e
:
e
}
Fp
{
f
,
e
}
}
/// Normalizes itself to have the shared exponent.
...
...
src/libcore/num/flt2dec/decoder.rs
浏览文件 @
d46dca66
...
...
@@ -77,8 +77,8 @@ pub fn decode<T: DecodableFloat>(v: T) -> (/*negative?*/ bool, FullDecoded) {
// neighbors: (mant - 2, exp) -- (mant, exp) -- (mant + 2, exp)
// Float::integer_decode always preserves the exponent,
// so the mantissa is scaled for subnormals.
FullDecoded
::
Finite
(
Decoded
{
mant
:
mant
,
minus
:
1
,
plus
:
1
,
exp
:
exp
,
inclusive
:
even
})
FullDecoded
::
Finite
(
Decoded
{
mant
,
minus
:
1
,
plus
:
1
,
exp
,
inclusive
:
even
})
}
FpCategory
::
Normal
=>
{
let
minnorm
=
<
T
as
DecodableFloat
>
::
min_pos_norm_value
()
.integer_decode
();
...
...
src/libcore/num/flt2dec/mod.rs
浏览文件 @
d46dca66
...
...
@@ -424,20 +424,20 @@ pub fn to_shortest_str<'a, T, F>(mut format_shortest: F, v: T,
match
full_decoded
{
FullDecoded
::
Nan
=>
{
parts
[
0
]
=
Part
::
Copy
(
b
"NaN"
);
Formatted
{
sign
:
sign
,
parts
:
&
parts
[
..
1
]
}
Formatted
{
sign
,
parts
:
&
parts
[
..
1
]
}
}
FullDecoded
::
Infinite
=>
{
parts
[
0
]
=
Part
::
Copy
(
b
"inf"
);
Formatted
{
sign
:
sign
,
parts
:
&
parts
[
..
1
]
}
Formatted
{
sign
,
parts
:
&
parts
[
..
1
]
}
}
FullDecoded
::
Zero
=>
{
if
frac_digits
>
0
{
// [0.][0000]
parts
[
0
]
=
Part
::
Copy
(
b
"0."
);
parts
[
1
]
=
Part
::
Zero
(
frac_digits
);
Formatted
{
sign
:
sign
,
parts
:
&
parts
[
..
2
]
}
Formatted
{
sign
,
parts
:
&
parts
[
..
2
]
}
}
else
{
parts
[
0
]
=
Part
::
Copy
(
b
"0"
);
Formatted
{
sign
:
sign
,
parts
:
&
parts
[
..
1
]
}
Formatted
{
sign
,
parts
:
&
parts
[
..
1
]
}
}
}
FullDecoded
::
Finite
(
ref
decoded
)
=>
{
...
...
@@ -480,11 +480,11 @@ pub fn to_shortest_exp_str<'a, T, F>(mut format_shortest: F, v: T,
match
full_decoded
{
FullDecoded
::
Nan
=>
{
parts
[
0
]
=
Part
::
Copy
(
b
"NaN"
);
Formatted
{
sign
:
sign
,
parts
:
&
parts
[
..
1
]
}
Formatted
{
sign
,
parts
:
&
parts
[
..
1
]
}
}
FullDecoded
::
Infinite
=>
{
parts
[
0
]
=
Part
::
Copy
(
b
"inf"
);
Formatted
{
sign
:
sign
,
parts
:
&
parts
[
..
1
]
}
Formatted
{
sign
,
parts
:
&
parts
[
..
1
]
}
}
FullDecoded
::
Zero
=>
{
parts
[
0
]
=
if
dec_bounds
.0
<=
0
&&
0
<
dec_bounds
.1
{
...
...
@@ -492,7 +492,7 @@ pub fn to_shortest_exp_str<'a, T, F>(mut format_shortest: F, v: T,
}
else
{
Part
::
Copy
(
if
upper
{
b
"0E0"
}
else
{
b
"0e0"
})
};
Formatted
{
sign
:
sign
,
parts
:
&
parts
[
..
1
]
}
Formatted
{
sign
,
parts
:
&
parts
[
..
1
]
}
}
FullDecoded
::
Finite
(
ref
decoded
)
=>
{
let
(
len
,
exp
)
=
format_shortest
(
decoded
,
buf
);
...
...
@@ -502,7 +502,7 @@ pub fn to_shortest_exp_str<'a, T, F>(mut format_shortest: F, v: T,
}
else
{
digits_to_exp_str
(
&
buf
[
..
len
],
exp
,
0
,
upper
,
parts
)
};
Formatted
{
sign
:
sign
,
parts
:
parts
}
Formatted
{
sign
,
parts
}
}
}
}
...
...
@@ -558,21 +558,21 @@ pub fn to_exact_exp_str<'a, T, F>(mut format_exact: F, v: T,
match
full_decoded
{
FullDecoded
::
Nan
=>
{
parts
[
0
]
=
Part
::
Copy
(
b
"NaN"
);
Formatted
{
sign
:
sign
,
parts
:
&
parts
[
..
1
]
}
Formatted
{
sign
,
parts
:
&
parts
[
..
1
]
}
}
FullDecoded
::
Infinite
=>
{
parts
[
0
]
=
Part
::
Copy
(
b
"inf"
);
Formatted
{
sign
:
sign
,
parts
:
&
parts
[
..
1
]
}
Formatted
{
sign
,
parts
:
&
parts
[
..
1
]
}
}
FullDecoded
::
Zero
=>
{
if
ndigits
>
1
{
// [0.][0000][e0]
parts
[
0
]
=
Part
::
Copy
(
b
"0."
);
parts
[
1
]
=
Part
::
Zero
(
ndigits
-
1
);
parts
[
2
]
=
Part
::
Copy
(
if
upper
{
b
"E0"
}
else
{
b
"e0"
});
Formatted
{
sign
:
sign
,
parts
:
&
parts
[
..
3
]
}
Formatted
{
sign
,
parts
:
&
parts
[
..
3
]
}
}
else
{
parts
[
0
]
=
Part
::
Copy
(
if
upper
{
b
"0E0"
}
else
{
b
"0e0"
});
Formatted
{
sign
:
sign
,
parts
:
&
parts
[
..
1
]
}
Formatted
{
sign
,
parts
:
&
parts
[
..
1
]
}
}
}
FullDecoded
::
Finite
(
ref
decoded
)
=>
{
...
...
@@ -613,20 +613,20 @@ pub fn to_exact_fixed_str<'a, T, F>(mut format_exact: F, v: T,
match
full_decoded
{
FullDecoded
::
Nan
=>
{
parts
[
0
]
=
Part
::
Copy
(
b
"NaN"
);
Formatted
{
sign
:
sign
,
parts
:
&
parts
[
..
1
]
}
Formatted
{
sign
,
parts
:
&
parts
[
..
1
]
}
}
FullDecoded
::
Infinite
=>
{
parts
[
0
]
=
Part
::
Copy
(
b
"inf"
);
Formatted
{
sign
:
sign
,
parts
:
&
parts
[
..
1
]
}
Formatted
{
sign
,
parts
:
&
parts
[
..
1
]
}
}
FullDecoded
::
Zero
=>
{
if
frac_digits
>
0
{
// [0.][0000]
parts
[
0
]
=
Part
::
Copy
(
b
"0."
);
parts
[
1
]
=
Part
::
Zero
(
frac_digits
);
Formatted
{
sign
:
sign
,
parts
:
&
parts
[
..
2
]
}
Formatted
{
sign
,
parts
:
&
parts
[
..
2
]
}
}
else
{
parts
[
0
]
=
Part
::
Copy
(
b
"0"
);
Formatted
{
sign
:
sign
,
parts
:
&
parts
[
..
1
]
}
Formatted
{
sign
,
parts
:
&
parts
[
..
1
]
}
}
}
FullDecoded
::
Finite
(
ref
decoded
)
=>
{
...
...
@@ -646,10 +646,10 @@ pub fn to_exact_fixed_str<'a, T, F>(mut format_exact: F, v: T,
if
frac_digits
>
0
{
// [0.][0000]
parts
[
0
]
=
Part
::
Copy
(
b
"0."
);
parts
[
1
]
=
Part
::
Zero
(
frac_digits
);
Formatted
{
sign
:
sign
,
parts
:
&
parts
[
..
2
]
}
Formatted
{
sign
,
parts
:
&
parts
[
..
2
]
}
}
else
{
parts
[
0
]
=
Part
::
Copy
(
b
"0"
);
Formatted
{
sign
:
sign
,
parts
:
&
parts
[
..
1
]
}
Formatted
{
sign
,
parts
:
&
parts
[
..
1
]
}
}
}
else
{
Formatted
{
sign
,
...
...
src/libcore/num/flt2dec/strategy/grisu.rs
浏览文件 @
d46dca66
...
...
@@ -129,7 +129,7 @@ pub fn cached_power(alpha: i16, gamma: i16) -> (i16, Fp) {
let
idx
=
((
gamma
as
i32
)
-
offset
)
*
range
/
domain
;
let
(
f
,
e
,
k
)
=
CACHED_POW10
[
idx
as
usize
];
debug_assert!
(
alpha
<=
e
&&
e
<=
gamma
);
(
k
,
Fp
{
f
:
f
,
e
:
e
})
(
k
,
Fp
{
f
,
e
})
}
/// Given `x > 0`, returns `(k, 10^k)` such that `10^k <= x < 10^(k+1)`.
...
...
src/libcore/slice/mod.rs
浏览文件 @
d46dca66
...
...
@@ -621,7 +621,7 @@ pub fn iter_mut(&mut self) -> IterMut<T> {
#[inline]
pub
fn
windows
(
&
self
,
size
:
usize
)
->
Windows
<
T
>
{
assert
!
(
size
!=
0
);
Windows
{
v
:
self
,
size
:
size
}
Windows
{
v
:
self
,
size
}
}
/// Returns an iterator over `chunk_size` elements of the slice at a
...
...
@@ -652,7 +652,7 @@ pub fn windows(&self, size: usize) -> Windows<T> {
#[inline]
pub
fn
chunks
(
&
self
,
chunk_size
:
usize
)
->
Chunks
<
T
>
{
assert
!
(
chunk_size
!=
0
);
Chunks
{
v
:
self
,
chunk_size
:
chunk_size
}
Chunks
{
v
:
self
,
chunk_size
}
}
/// Returns an iterator over `chunk_size` elements of the slice at a time.
...
...
@@ -687,7 +687,7 @@ pub fn chunks(&self, chunk_size: usize) -> Chunks<T> {
#[inline]
pub
fn
chunks_mut
(
&
mut
self
,
chunk_size
:
usize
)
->
ChunksMut
<
T
>
{
assert
!
(
chunk_size
!=
0
);
ChunksMut
{
v
:
self
,
chunk_size
:
chunk_size
}
ChunksMut
{
v
:
self
,
chunk_size
}
}
/// Returns an iterator over `chunk_size` elements of the slice at a
...
...
@@ -724,7 +724,7 @@ pub fn exact_chunks(&self, chunk_size: usize) -> ExactChunks<T> {
let
rem
=
self
.len
()
%
chunk_size
;
let
len
=
self
.len
()
-
rem
;
let
(
fst
,
snd
)
=
self
.split_at
(
len
);
ExactChunks
{
v
:
fst
,
rem
:
snd
,
chunk_size
:
chunk_size
}
ExactChunks
{
v
:
fst
,
rem
:
snd
,
chunk_size
}
}
/// Returns an iterator over `chunk_size` elements of the slice at a time.
...
...
@@ -766,7 +766,7 @@ pub fn exact_chunks_mut(&mut self, chunk_size: usize) -> ExactChunksMut<T> {
let
rem
=
self
.len
()
%
chunk_size
;
let
len
=
self
.len
()
-
rem
;
let
(
fst
,
snd
)
=
self
.split_at_mut
(
len
);
ExactChunksMut
{
v
:
fst
,
rem
:
snd
,
chunk_size
:
chunk_size
}
ExactChunksMut
{
v
:
fst
,
rem
:
snd
,
chunk_size
}
}
/// Divides one slice into two at an index.
...
...
@@ -916,7 +916,7 @@ pub fn split<F>(&self, pred: F) -> Split<T, F>
pub
fn
split_mut
<
F
>
(
&
mut
self
,
pred
:
F
)
->
SplitMut
<
T
,
F
>
where
F
:
FnMut
(
&
T
)
->
bool
{
SplitMut
{
v
:
self
,
pred
:
pred
,
finished
:
false
}
SplitMut
{
v
:
self
,
pred
,
finished
:
false
}
}
/// Returns an iterator over subslices separated by elements that match
...
...
src/libcore/task/context.rs
浏览文件 @
d46dca66
...
...
@@ -86,7 +86,7 @@ pub fn with_executor<'b, E>(&'b mut self, executor: &'b mut E) -> Context<'b>
{
Context
{
local_waker
:
self
.local_waker
,
executor
:
executor
,
executor
,
}
}
}
src/libcore/time.rs
浏览文件 @
d46dca66
...
...
@@ -91,7 +91,7 @@ pub fn new(secs: u64, nanos: u32) -> Duration {
let
secs
=
secs
.checked_add
((
nanos
/
NANOS_PER_SEC
)
as
u64
)
.expect
(
"overflow in Duration::new"
);
let
nanos
=
nanos
%
NANOS_PER_SEC
;
Duration
{
secs
:
secs
,
nanos
:
nanos
}
Duration
{
secs
,
nanos
}
}
/// Creates a new `Duration` from the specified number of whole seconds.
...
...
@@ -109,7 +109,7 @@ pub fn new(secs: u64, nanos: u32) -> Duration {
#[stable(feature
=
"duration"
,
since
=
"1.3.0"
)]
#[inline]
pub
const
fn
from_secs
(
secs
:
u64
)
->
Duration
{
Duration
{
secs
:
secs
,
nanos
:
0
}
Duration
{
secs
,
nanos
:
0
}
}
/// Creates a new `Duration` from the specified number of milliseconds.
...
...
@@ -387,7 +387,7 @@ pub fn checked_sub(self, rhs: Duration) -> Option<Duration> {
}
};
debug_assert!
(
nanos
<
NANOS_PER_SEC
);
Some
(
Duration
{
secs
:
secs
,
nanos
:
nanos
})
Some
(
Duration
{
secs
,
nanos
})
}
else
{
None
}
...
...
@@ -453,7 +453,7 @@ pub fn checked_div(self, rhs: u32) -> Option<Duration> {
let
extra_nanos
=
carry
*
(
NANOS_PER_SEC
as
u64
)
/
(
rhs
as
u64
);
let
nanos
=
self
.nanos
/
rhs
+
(
extra_nanos
as
u32
);
debug_assert!
(
nanos
<
NANOS_PER_SEC
);
Some
(
Duration
{
secs
:
secs
,
nanos
:
nanos
})
Some
(
Duration
{
secs
,
nanos
})
}
else
{
None
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录