Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
ee76be54
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,发现更多精彩内容 >>
提交
ee76be54
编写于
3月 28, 2015
作者:
V
Vadim Petrochenkov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Remove unnecessary `as usize`
上级
5825c72e
变更
10
隐藏空白更改
内联
并排
Showing
10 changed file
with
76 addition
and
76 deletion
+76
-76
src/libcollections/bit.rs
src/libcollections/bit.rs
+17
-17
src/libcollections/enum_set.rs
src/libcollections/enum_set.rs
+1
-1
src/libcollectionstest/bit/set.rs
src/libcollectionstest/bit/set.rs
+1
-1
src/libcollectionstest/bit/vec.rs
src/libcollectionstest/bit/vec.rs
+40
-40
src/libcore/hash/mod.rs
src/libcore/hash/mod.rs
+1
-1
src/librustc/middle/dataflow.rs
src/librustc/middle/dataflow.rs
+4
-4
src/libstd/old_io/mod.rs
src/libstd/old_io/mod.rs
+8
-8
src/libstd/sys/unix/c.rs
src/libstd/sys/unix/c.rs
+2
-2
src/test/run-pass/issue-13763.rs
src/test/run-pass/issue-13763.rs
+1
-1
src/test/run-pass/vector-sort-panic-safe.rs
src/test/run-pass/vector-sort-panic-safe.rs
+1
-1
未找到文件。
src/libcollections/bit.rs
浏览文件 @
ee76be54
...
...
@@ -191,17 +191,17 @@ fn blocks_for_bits(bits: usize) -> usize {
//
// Note that we can technically avoid this branch with the expression
// `(nbits + u32::BITS - 1) / 32::BITS`, but if nbits is almost usize::MAX this will overflow.
if
bits
%
u32
::
BITS
as
usize
==
0
{
bits
/
u32
::
BITS
as
usize
if
bits
%
u32
::
BITS
==
0
{
bits
/
u32
::
BITS
}
else
{
bits
/
u32
::
BITS
as
usize
+
1
bits
/
u32
::
BITS
+
1
}
}
/// Computes the bitmask for the final word of the vector
fn
mask_for_bits
(
bits
:
usize
)
->
u32
{
// Note especially that a perfect multiple of u32::BITS should mask all 1s.
!
0
>>
(
u32
::
BITS
as
usize
-
bits
%
u32
::
BITS
as
usize
)
%
u32
::
BITS
as
usize
!
0
>>
(
u32
::
BITS
-
bits
%
u32
::
BITS
)
%
u32
::
BITS
}
impl
BitVec
{
...
...
@@ -239,7 +239,7 @@ fn blocks(&self) -> Blocks {
/// An operation might screw up the unused bits in the last block of the
/// `BitVec`. As per (3), it's assumed to be all 0s. This method fixes it up.
fn
fix_last_block
(
&
mut
self
)
{
let
extra_bits
=
self
.len
()
%
u32
::
BITS
as
usize
;
let
extra_bits
=
self
.len
()
%
u32
::
BITS
;
if
extra_bits
>
0
{
let
mask
=
(
1
<<
extra_bits
)
-
1
;
let
storage_len
=
self
.storage
.len
();
...
...
@@ -318,7 +318,7 @@ pub fn with_capacity(nbits: usize) -> BitVec {
/// false, false, true, false]));
/// ```
pub
fn
from_bytes
(
bytes
:
&
[
u8
])
->
BitVec
{
let
len
=
bytes
.len
()
.checked_mul
(
u8
::
BITS
as
usize
)
.expect
(
"capacity overflow"
);
let
len
=
bytes
.len
()
.checked_mul
(
u8
::
BITS
)
.expect
(
"capacity overflow"
);
let
mut
bit_vec
=
BitVec
::
with_capacity
(
len
);
let
complete_words
=
bytes
.len
()
/
4
;
let
extra_bytes
=
bytes
.len
()
%
4
;
...
...
@@ -387,8 +387,8 @@ pub fn get(&self, i: usize) -> Option<bool> {
if
i
>=
self
.nbits
{
return
None
;
}
let
w
=
i
/
u32
::
BITS
as
usize
;
let
b
=
i
%
u32
::
BITS
as
usize
;
let
w
=
i
/
u32
::
BITS
;
let
b
=
i
%
u32
::
BITS
;
self
.storage
.get
(
w
)
.map
(|
&
block
|
(
block
&
(
1
<<
b
))
!=
0
)
...
...
@@ -415,8 +415,8 @@ pub fn get(&self, i: usize) -> Option<bool> {
reason
=
"panic semantics are likely to change in the future"
)]
pub
fn
set
(
&
mut
self
,
i
:
usize
,
x
:
bool
)
{
assert
!
(
i
<
self
.nbits
);
let
w
=
i
/
u32
::
BITS
as
usize
;
let
b
=
i
%
u32
::
BITS
as
usize
;
let
w
=
i
/
u32
::
BITS
;
let
b
=
i
%
u32
::
BITS
;
let
flag
=
1
<<
b
;
let
val
=
if
x
{
self
.storage
[
w
]
|
flag
}
else
{
self
.storage
[
w
]
&
!
flag
};
...
...
@@ -812,7 +812,7 @@ pub fn reserve_exact(&mut self, additional: usize) {
#[inline]
#[stable(feature
=
"rust1"
,
since
=
"1.0.0"
)]
pub
fn
capacity
(
&
self
)
->
usize
{
self
.storage
.capacity
()
.checked_mul
(
u32
::
BITS
as
usize
)
.unwrap_or
(
usize
::
MAX
)
self
.storage
.capacity
()
.checked_mul
(
u32
::
BITS
)
.unwrap_or
(
usize
::
MAX
)
}
/// Grows the `BitVec` in-place, adding `n` copies of `value` to the `BitVec`.
...
...
@@ -843,7 +843,7 @@ pub fn grow(&mut self, n: usize, value: bool) {
// Correct the old tail word, setting or clearing formerly unused bits
let
num_cur_blocks
=
blocks_for_bits
(
self
.nbits
);
if
self
.nbits
%
u32
::
BITS
as
usize
>
0
{
if
self
.nbits
%
u32
::
BITS
>
0
{
let
mask
=
mask_for_bits
(
self
.nbits
);
if
value
{
self
.storage
[
num_cur_blocks
-
1
]
|
=
!
mask
;
...
...
@@ -893,7 +893,7 @@ pub fn pop(&mut self) -> Option<bool> {
// (3)
self
.set
(
i
,
false
);
self
.nbits
=
i
;
if
self
.nbits
%
u32
::
BITS
as
usize
==
0
{
if
self
.nbits
%
u32
::
BITS
==
0
{
// (2)
self
.storage
.pop
();
}
...
...
@@ -916,7 +916,7 @@ pub fn pop(&mut self) -> Option<bool> {
/// ```
#[stable(feature
=
"rust1"
,
since
=
"1.0.0"
)]
pub
fn
push
(
&
mut
self
,
elem
:
bool
)
{
if
self
.nbits
%
u32
::
BITS
as
usize
==
0
{
if
self
.nbits
%
u32
::
BITS
==
0
{
self
.storage
.push
(
0
);
}
let
insert_pos
=
self
.nbits
;
...
...
@@ -1442,7 +1442,7 @@ pub fn shrink_to_fit(&mut self) {
// Truncate
let
trunc_len
=
cmp
::
max
(
old_len
-
n
,
1
);
bit_vec
.storage
.truncate
(
trunc_len
);
bit_vec
.nbits
=
trunc_len
*
u32
::
BITS
as
usize
;
bit_vec
.nbits
=
trunc_len
*
u32
::
BITS
;
}
/// Iterator over each u32 stored in the `BitSet`.
...
...
@@ -1880,13 +1880,13 @@ impl<'a> Iterator for TwoBitPositions<'a> {
fn
next
(
&
mut
self
)
->
Option
<
usize
>
{
while
self
.next_idx
<
self
.set.bit_vec
.len
()
||
self
.next_idx
<
self
.other.bit_vec
.len
()
{
let
bit_idx
=
self
.next_idx
%
u32
::
BITS
as
usize
;
let
bit_idx
=
self
.next_idx
%
u32
::
BITS
;
if
bit_idx
==
0
{
let
s_bit_vec
=
&
self
.set.bit_vec
;
let
o_bit_vec
=
&
self
.other.bit_vec
;
// Merging the two words is a bit of an awkward dance since
// one BitVec might be longer than the other
let
word_idx
=
self
.next_idx
/
u32
::
BITS
as
usize
;
let
word_idx
=
self
.next_idx
/
u32
::
BITS
;
let
w1
=
if
word_idx
<
s_bit_vec
.storage
.len
()
{
s_bit_vec
.storage
[
word_idx
]
}
else
{
0
};
...
...
src/libcollections/enum_set.rs
浏览文件 @
ee76be54
...
...
@@ -83,7 +83,7 @@ pub trait CLike {
fn
bit
<
E
:
CLike
>
(
e
:
&
E
)
->
usize
{
use
core
::
usize
;
let
value
=
e
.to_usize
();
assert
!
(
value
<
usize
::
BITS
as
usize
,
assert
!
(
value
<
usize
::
BITS
,
"EnumSet only supports up to {} variants."
,
usize
::
BITS
-
1
);
1
<<
value
}
...
...
src/libcollectionstest/bit/set.rs
浏览文件 @
ee76be54
...
...
@@ -408,7 +408,7 @@ fn bench_bit_vecset_small(b: &mut Bencher) {
let
mut
bit_vec
=
BitSet
::
new
();
b
.iter
(||
{
for
_
in
0
..
100
{
bit_vec
.insert
((
r
.next_u32
()
as
usize
)
%
u32
::
BITS
as
usize
);
bit_vec
.insert
((
r
.next_u32
()
as
usize
)
%
u32
::
BITS
);
}
black_box
(
&
bit_vec
);
});
...
...
src/libcollectionstest/bit/vec.rs
浏览文件 @
ee76be54
...
...
@@ -541,43 +541,43 @@ fn test_big_bit_vec_tests() {
#[test]
fn
test_bit_vec_push_pop
()
{
let
mut
s
=
BitVec
::
from_elem
(
5
*
u32
::
BITS
as
usize
-
2
,
false
);
assert_eq!
(
s
.len
(),
5
*
u32
::
BITS
as
usize
-
2
);
assert_eq!
(
s
[
5
*
u32
::
BITS
as
usize
-
3
],
false
);
let
mut
s
=
BitVec
::
from_elem
(
5
*
u32
::
BITS
-
2
,
false
);
assert_eq!
(
s
.len
(),
5
*
u32
::
BITS
-
2
);
assert_eq!
(
s
[
5
*
u32
::
BITS
-
3
],
false
);
s
.push
(
true
);
s
.push
(
true
);
assert_eq!
(
s
[
5
*
u32
::
BITS
as
usize
-
2
],
true
);
assert_eq!
(
s
[
5
*
u32
::
BITS
as
usize
-
1
],
true
);
assert_eq!
(
s
[
5
*
u32
::
BITS
-
2
],
true
);
assert_eq!
(
s
[
5
*
u32
::
BITS
-
1
],
true
);
// Here the internal vector will need to be extended
s
.push
(
false
);
assert_eq!
(
s
[
5
*
u32
::
BITS
as
usize
],
false
);
assert_eq!
(
s
[
5
*
u32
::
BITS
],
false
);
s
.push
(
false
);
assert_eq!
(
s
[
5
*
u32
::
BITS
as
usize
+
1
],
false
);
assert_eq!
(
s
.len
(),
5
*
u32
::
BITS
as
usize
+
2
);
assert_eq!
(
s
[
5
*
u32
::
BITS
+
1
],
false
);
assert_eq!
(
s
.len
(),
5
*
u32
::
BITS
+
2
);
// Pop it all off
assert_eq!
(
s
.pop
(),
Some
(
false
));
assert_eq!
(
s
.pop
(),
Some
(
false
));
assert_eq!
(
s
.pop
(),
Some
(
true
));
assert_eq!
(
s
.pop
(),
Some
(
true
));
assert_eq!
(
s
.len
(),
5
*
u32
::
BITS
as
usize
-
2
);
assert_eq!
(
s
.len
(),
5
*
u32
::
BITS
-
2
);
}
#[test]
fn
test_bit_vec_truncate
()
{
let
mut
s
=
BitVec
::
from_elem
(
5
*
u32
::
BITS
as
usize
,
true
);
let
mut
s
=
BitVec
::
from_elem
(
5
*
u32
::
BITS
,
true
);
assert_eq!
(
s
,
BitVec
::
from_elem
(
5
*
u32
::
BITS
as
usize
,
true
));
assert_eq!
(
s
.len
(),
5
*
u32
::
BITS
as
usize
);
s
.truncate
(
4
*
u32
::
BITS
as
usize
);
assert_eq!
(
s
,
BitVec
::
from_elem
(
4
*
u32
::
BITS
as
usize
,
true
));
assert_eq!
(
s
.len
(),
4
*
u32
::
BITS
as
usize
);
assert_eq!
(
s
,
BitVec
::
from_elem
(
5
*
u32
::
BITS
,
true
));
assert_eq!
(
s
.len
(),
5
*
u32
::
BITS
);
s
.truncate
(
4
*
u32
::
BITS
);
assert_eq!
(
s
,
BitVec
::
from_elem
(
4
*
u32
::
BITS
,
true
));
assert_eq!
(
s
.len
(),
4
*
u32
::
BITS
);
// Truncating to a size > s.len() should be a noop
s
.truncate
(
5
*
u32
::
BITS
as
usize
);
assert_eq!
(
s
,
BitVec
::
from_elem
(
4
*
u32
::
BITS
as
usize
,
true
));
assert_eq!
(
s
.len
(),
4
*
u32
::
BITS
as
usize
);
s
.truncate
(
3
*
u32
::
BITS
as
usize
-
10
);
assert_eq!
(
s
,
BitVec
::
from_elem
(
3
*
u32
::
BITS
as
usize
-
10
,
true
));
assert_eq!
(
s
.len
(),
3
*
u32
::
BITS
as
usize
-
10
);
s
.truncate
(
5
*
u32
::
BITS
);
assert_eq!
(
s
,
BitVec
::
from_elem
(
4
*
u32
::
BITS
,
true
));
assert_eq!
(
s
.len
(),
4
*
u32
::
BITS
);
s
.truncate
(
3
*
u32
::
BITS
-
10
);
assert_eq!
(
s
,
BitVec
::
from_elem
(
3
*
u32
::
BITS
-
10
,
true
));
assert_eq!
(
s
.len
(),
3
*
u32
::
BITS
-
10
);
s
.truncate
(
0
);
assert_eq!
(
s
,
BitVec
::
from_elem
(
0
,
true
));
assert_eq!
(
s
.len
(),
0
);
...
...
@@ -585,26 +585,26 @@ fn test_bit_vec_truncate() {
#[test]
fn
test_bit_vec_reserve
()
{
let
mut
s
=
BitVec
::
from_elem
(
5
*
u32
::
BITS
as
usize
,
true
);
let
mut
s
=
BitVec
::
from_elem
(
5
*
u32
::
BITS
,
true
);
// Check capacity
assert
!
(
s
.capacity
()
>=
5
*
u32
::
BITS
as
usize
);
s
.reserve
(
2
*
u32
::
BITS
as
usize
);
assert
!
(
s
.capacity
()
>=
7
*
u32
::
BITS
as
usize
);
s
.reserve
(
7
*
u32
::
BITS
as
usize
);
assert
!
(
s
.capacity
()
>=
12
*
u32
::
BITS
as
usize
);
s
.reserve_exact
(
7
*
u32
::
BITS
as
usize
);
assert
!
(
s
.capacity
()
>=
12
*
u32
::
BITS
as
usize
);
s
.reserve
(
7
*
u32
::
BITS
as
usize
+
1
);
assert
!
(
s
.capacity
()
>=
12
*
u32
::
BITS
as
usize
+
1
);
assert
!
(
s
.capacity
()
>=
5
*
u32
::
BITS
);
s
.reserve
(
2
*
u32
::
BITS
);
assert
!
(
s
.capacity
()
>=
7
*
u32
::
BITS
);
s
.reserve
(
7
*
u32
::
BITS
);
assert
!
(
s
.capacity
()
>=
12
*
u32
::
BITS
);
s
.reserve_exact
(
7
*
u32
::
BITS
);
assert
!
(
s
.capacity
()
>=
12
*
u32
::
BITS
);
s
.reserve
(
7
*
u32
::
BITS
+
1
);
assert
!
(
s
.capacity
()
>=
12
*
u32
::
BITS
+
1
);
// Check that length hasn't changed
assert_eq!
(
s
.len
(),
5
*
u32
::
BITS
as
usize
);
assert_eq!
(
s
.len
(),
5
*
u32
::
BITS
);
s
.push
(
true
);
s
.push
(
false
);
s
.push
(
true
);
assert_eq!
(
s
[
5
*
u32
::
BITS
as
usize
-
1
],
true
);
assert_eq!
(
s
[
5
*
u32
::
BITS
as
usize
-
0
],
true
);
assert_eq!
(
s
[
5
*
u32
::
BITS
as
usize
+
1
],
false
);
assert_eq!
(
s
[
5
*
u32
::
BITS
as
usize
+
2
],
true
);
assert_eq!
(
s
[
5
*
u32
::
BITS
-
1
],
true
);
assert_eq!
(
s
[
5
*
u32
::
BITS
-
0
],
true
);
assert_eq!
(
s
[
5
*
u32
::
BITS
+
1
],
false
);
assert_eq!
(
s
[
5
*
u32
::
BITS
+
2
],
true
);
}
#[test]
...
...
@@ -650,7 +650,7 @@ fn bench_usize_small(b: &mut Bencher) {
let
mut
bit_vec
=
0
as
usize
;
b
.iter
(||
{
for
_
in
0
..
100
{
bit_vec
|
=
1
<<
((
r
.next_u32
()
as
usize
)
%
u32
::
BITS
as
usize
);
bit_vec
|
=
1
<<
((
r
.next_u32
()
as
usize
)
%
u32
::
BITS
);
}
black_box
(
&
bit_vec
);
});
...
...
@@ -683,10 +683,10 @@ fn bench_bit_set_big_variable(b: &mut Bencher) {
#[bench]
fn
bench_bit_set_small
(
b
:
&
mut
Bencher
)
{
let
mut
r
=
rng
();
let
mut
bit_vec
=
BitVec
::
from_elem
(
u32
::
BITS
as
usize
,
false
);
let
mut
bit_vec
=
BitVec
::
from_elem
(
u32
::
BITS
,
false
);
b
.iter
(||
{
for
_
in
0
..
100
{
bit_vec
.set
((
r
.next_u32
()
as
usize
)
%
u32
::
BITS
as
usize
,
true
);
bit_vec
.set
((
r
.next_u32
()
as
usize
)
%
u32
::
BITS
,
true
);
}
black_box
(
&
bit_vec
);
});
...
...
@@ -703,7 +703,7 @@ fn bench_bit_vec_big_union(b: &mut Bencher) {
#[bench]
fn
bench_bit_vec_small_iter
(
b
:
&
mut
Bencher
)
{
let
bit_vec
=
BitVec
::
from_elem
(
u32
::
BITS
as
usize
,
false
);
let
bit_vec
=
BitVec
::
from_elem
(
u32
::
BITS
,
false
);
b
.iter
(||
{
let
mut
sum
=
0
;
for
_
in
0
..
10
{
...
...
src/libcore/hash/mod.rs
浏览文件 @
ee76be54
...
...
@@ -194,7 +194,7 @@ fn hash<H: Hasher>(&self, state: &mut H) {
fn
hash_slice
<
H
:
Hasher
>
(
data
:
&
[
$ty
],
state
:
&
mut
H
)
{
// FIXME(#23542) Replace with type ascription.
#![allow(trivial_casts)]
let
newlen
=
data
.len
()
*
::
$ty
::
BYTES
as
usize
;
let
newlen
=
data
.len
()
*
::
$ty
::
BYTES
;
let
ptr
=
data
.as_ptr
()
as
*
const
u8
;
state
.write
(
unsafe
{
slice
::
from_raw_parts
(
ptr
,
newlen
)
})
}
...
...
src/librustc/middle/dataflow.rs
浏览文件 @
ee76be54
...
...
@@ -195,7 +195,7 @@ pub fn new(tcx: &'a ty::ctxt<'tcx>,
oper
:
O
,
id_range
:
IdRange
,
bits_per_id
:
usize
)
->
DataFlowContext
<
'a
,
'tcx
,
O
>
{
let
words_per_id
=
(
bits_per_id
+
usize
::
BITS
as
usize
-
1
)
/
usize
::
BITS
as
usize
;
let
words_per_id
=
(
bits_per_id
+
usize
::
BITS
-
1
)
/
usize
::
BITS
;
let
num_nodes
=
cfg
.graph
.all_nodes
()
.len
();
debug!
(
"DataFlowContext::new(analysis_name: {}, id_range={:?},
\
...
...
@@ -367,7 +367,7 @@ fn each_bit<F>(&self, words: &[usize], mut f: F) -> bool where
for
(
word_index
,
&
word
)
in
words
.iter
()
.enumerate
()
{
if
word
!=
0
{
let
base_index
=
word_index
*
usize
::
BITS
as
usize
;
let
base_index
=
word_index
*
usize
::
BITS
;
for
offset
in
0
..
usize
::
BITS
{
let
bit
=
1
<<
offset
;
if
(
word
&
bit
)
!=
0
{
...
...
@@ -601,8 +601,8 @@ fn bitwise<Op:BitwiseOperator>(out_vec: &mut [usize],
fn
set_bit
(
words
:
&
mut
[
usize
],
bit
:
usize
)
->
bool
{
debug!
(
"set_bit: words={} bit={}"
,
mut_bits_to_string
(
words
),
bit_str
(
bit
));
let
word
=
bit
/
usize
::
BITS
as
usize
;
let
bit_in_word
=
bit
%
usize
::
BITS
as
usize
;
let
word
=
bit
/
usize
::
BITS
;
let
bit_in_word
=
bit
%
usize
::
BITS
;
let
bit_mask
=
1
<<
bit_in_word
;
debug!
(
"word={} bit_in_word={} bit_mask={}"
,
word
,
bit_in_word
,
word
);
let
oldv
=
words
[
word
];
...
...
src/libstd/old_io/mod.rs
浏览文件 @
ee76be54
...
...
@@ -726,28 +726,28 @@ fn read_be_int_n(&mut self, nbytes: usize) -> IoResult<i64> {
///
/// The number of bytes returned is system-dependent.
fn
read_le_uint
(
&
mut
self
)
->
IoResult
<
usize
>
{
self
.read_le_uint_n
(
usize
::
BYTES
as
usize
)
.map
(|
i
|
i
as
usize
)
self
.read_le_uint_n
(
usize
::
BYTES
)
.map
(|
i
|
i
as
usize
)
}
/// Reads a little-endian integer.
///
/// The number of bytes returned is system-dependent.
fn
read_le_int
(
&
mut
self
)
->
IoResult
<
isize
>
{
self
.read_le_int_n
(
isize
::
BYTES
as
usize
)
.map
(|
i
|
i
as
isize
)
self
.read_le_int_n
(
isize
::
BYTES
)
.map
(|
i
|
i
as
isize
)
}
/// Reads a big-endian unsigned integer.
///
/// The number of bytes returned is system-dependent.
fn
read_be_uint
(
&
mut
self
)
->
IoResult
<
usize
>
{
self
.read_be_uint_n
(
usize
::
BYTES
as
usize
)
.map
(|
i
|
i
as
usize
)
self
.read_be_uint_n
(
usize
::
BYTES
)
.map
(|
i
|
i
as
usize
)
}
/// Reads a big-endian integer.
///
/// The number of bytes returned is system-dependent.
fn
read_be_int
(
&
mut
self
)
->
IoResult
<
isize
>
{
self
.read_be_int_n
(
isize
::
BYTES
as
usize
)
.map
(|
i
|
i
as
isize
)
self
.read_be_int_n
(
isize
::
BYTES
)
.map
(|
i
|
i
as
isize
)
}
/// Reads a big-endian `u64`.
...
...
@@ -1110,25 +1110,25 @@ fn write_uint(&mut self, n: usize) -> IoResult<()> {
/// Write a little-endian usize (number of bytes depends on system).
#[inline]
fn
write_le_uint
(
&
mut
self
,
n
:
usize
)
->
IoResult
<
()
>
{
extensions
::
u64_to_le_bytes
(
n
as
u64
,
usize
::
BYTES
as
usize
,
|
v
|
self
.write_all
(
v
))
extensions
::
u64_to_le_bytes
(
n
as
u64
,
usize
::
BYTES
,
|
v
|
self
.write_all
(
v
))
}
/// Write a little-endian isize (number of bytes depends on system).
#[inline]
fn
write_le_int
(
&
mut
self
,
n
:
isize
)
->
IoResult
<
()
>
{
extensions
::
u64_to_le_bytes
(
n
as
u64
,
isize
::
BYTES
as
usize
,
|
v
|
self
.write_all
(
v
))
extensions
::
u64_to_le_bytes
(
n
as
u64
,
isize
::
BYTES
,
|
v
|
self
.write_all
(
v
))
}
/// Write a big-endian usize (number of bytes depends on system).
#[inline]
fn
write_be_uint
(
&
mut
self
,
n
:
usize
)
->
IoResult
<
()
>
{
extensions
::
u64_to_be_bytes
(
n
as
u64
,
usize
::
BYTES
as
usize
,
|
v
|
self
.write_all
(
v
))
extensions
::
u64_to_be_bytes
(
n
as
u64
,
usize
::
BYTES
,
|
v
|
self
.write_all
(
v
))
}
/// Write a big-endian isize (number of bytes depends on system).
#[inline]
fn
write_be_int
(
&
mut
self
,
n
:
isize
)
->
IoResult
<
()
>
{
extensions
::
u64_to_be_bytes
(
n
as
u64
,
isize
::
BYTES
as
usize
,
|
v
|
self
.write_all
(
v
))
extensions
::
u64_to_be_bytes
(
n
as
u64
,
isize
::
BYTES
,
|
v
|
self
.write_all
(
v
))
}
/// Write a big-endian u64 (8 bytes).
...
...
src/libstd/sys/unix/c.rs
浏览文件 @
ee76be54
...
...
@@ -194,12 +194,12 @@ mod select {
#[repr(C)]
pub
struct
fd_set
{
// FIXME: shouldn't this be a c_ulong?
fds_bits
:
[
libc
::
uintptr_t
;
(
FD_SETSIZE
/
usize
::
BITS
as
usize
)]
fds_bits
:
[
libc
::
uintptr_t
;
(
FD_SETSIZE
/
usize
::
BITS
)]
}
pub
fn
fd_set
(
set
:
&
mut
fd_set
,
fd
:
i32
)
{
let
fd
=
fd
as
usize
;
set
.fds_bits
[
fd
/
usize
::
BITS
as
usize
]
|
=
1
<<
(
fd
%
usize
::
BITS
as
usize
);
set
.fds_bits
[
fd
/
usize
::
BITS
]
|
=
1
<<
(
fd
%
usize
::
BITS
);
}
}
...
...
src/test/run-pass/issue-13763.rs
浏览文件 @
ee76be54
...
...
@@ -14,7 +14,7 @@
use
std
::
u8
;
const
NUM
:
usize
=
u8
::
BITS
as
usize
;
const
NUM
:
usize
=
u8
::
BITS
;
struct
MyStruct
{
nums
:
[
usize
;
8
]
}
...
...
src/test/run-pass/vector-sort-panic-safe.rs
浏览文件 @
ee76be54
...
...
@@ -57,7 +57,7 @@ fn drop(&mut self) {
}
pub
fn
main
()
{
assert
!
(
MAX_LEN
<=
std
::
usize
::
BITS
as
usize
);
assert
!
(
MAX_LEN
<=
std
::
usize
::
BITS
);
// len can't go above 64.
for
len
in
2
..
MAX_LEN
{
for
_
in
0
..
REPEATS
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录