Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
72f59732
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,发现更多精彩内容 >>
提交
72f59732
编写于
3月 31, 2015
作者:
A
Alex Crichton
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Test fixes and rebase conflicts, round 3
上级
50b3ecf3
变更
18
隐藏空白更改
内联
并排
Showing
18 changed file
with
156 addition
and
153 deletion
+156
-153
src/liballoc/lib.rs
src/liballoc/lib.rs
+0
-1
src/libcollections/str.rs
src/libcollections/str.rs
+13
-11
src/libcore/iter.rs
src/libcore/iter.rs
+2
-1
src/librbml/lib.rs
src/librbml/lib.rs
+0
-1
src/librustc/middle/ty.rs
src/librustc/middle/ty.rs
+0
-1
src/libstd/io/buffered.rs
src/libstd/io/buffered.rs
+22
-22
src/libstd/io/cursor.rs
src/libstd/io/cursor.rs
+61
-61
src/libstd/io/mod.rs
src/libstd/io/mod.rs
+24
-24
src/libstd/io/util.rs
src/libstd/io/util.rs
+12
-12
src/libstd/net/addr.rs
src/libstd/net/addr.rs
+5
-2
src/libstd/net/tcp.rs
src/libstd/net/tcp.rs
+7
-7
src/libstd/net/udp.rs
src/libstd/net/udp.rs
+2
-2
src/libstd/process.rs
src/libstd/process.rs
+1
-1
src/libstd/sys/unix/fs2.rs
src/libstd/sys/unix/fs2.rs
+1
-1
src/libstd/sys/windows/c.rs
src/libstd/sys/windows/c.rs
+1
-1
src/libstd/sys/windows/os.rs
src/libstd/sys/windows/os.rs
+1
-1
src/libstd/sys/windows/stdio.rs
src/libstd/sys/windows/stdio.rs
+2
-3
src/test/run-pass/issue-22577.rs
src/test/run-pass/issue-22577.rs
+2
-1
未找到文件。
src/liballoc/lib.rs
浏览文件 @
72f59732
...
...
@@ -78,7 +78,6 @@
#![feature(unsafe_no_drop_flag,
filling_drop)]
#![feature(core)]
#![feature(unique)]
#![feature(convert)]
#![cfg_attr(test,
feature(test,
alloc,
rustc_private))]
#![cfg_attr(all(not(feature
=
"external_funcs"
),
not(feature
=
"external_crate"
)),
feature(libc))]
...
...
src/libcollections/str.rs
浏览文件 @
72f59732
...
...
@@ -12,10 +12,10 @@
//! Unicode string manipulation (the `str` type).
//!
//! Rust's `str` type is one of the core primitive types of the language. `&str`
is the borrowed
//!
string type. This type of string can only be created from other strings, unless it is a
//!
`&'static str` (see below). It is not possible to move out of borrowed strings because they ar
e
//! owned elsewhere.
//! Rust's `str` type is one of the core primitive types of the language. `&str`
//!
is the borrowed string type. This type of string can only be created from
//!
other strings, unless it is a `&'static str` (see below). It is not possibl
e
//!
to move out of borrowed strings because they are
owned elsewhere.
//!
//! # Examples
//!
...
...
@@ -25,8 +25,9 @@
//! let s = "Hello, world.";
//! ```
//!
//! This `&str` is a `&'static str`, which is the type of string literals. They're `'static`
//! because literals are available for the entire lifetime of the program.
//! This `&str` is a `&'static str`, which is the type of string literals.
//! They're `'static` because literals are available for the entire lifetime of
//! the program.
//!
//! You can get a non-`'static` `&str` by taking a slice of a `String`:
//!
...
...
@@ -37,12 +38,13 @@
//!
//! # Representation
//!
//! Rust's string type, `str`, is a sequence of Unicode scalar values encoded as a stream of UTF-8
//! bytes. All [strings](../../reference.html#literals) are guaranteed to be validly encoded UTF-8
//! sequences. Additionally, strings are not null-terminated and can thus contain null bytes.
//! Rust's string type, `str`, is a sequence of Unicode scalar values encoded as
//! a stream of UTF-8 bytes. All [strings](../../reference.html#literals) are
//! guaranteed to be validly encoded UTF-8 sequences. Additionally, strings are
//! not null-terminated and can thus contain null bytes.
//!
//! The actual representation of `str`s have direct mappings to slices: `&str`
is the same as
//! `&[u8]`.
//! The actual representation of `str`s have direct mappings to slices: `&str`
//!
is the same as
`&[u8]`.
#![doc(primitive
=
"str"
)]
#![stable(feature
=
"rust1"
,
since
=
"1.0.0"
)]
...
...
src/libcore/iter.rs
浏览文件 @
72f59732
...
...
@@ -41,10 +41,11 @@
//! }
//!
//! // Rough translation of the iteration without a `for` iterator.
//! # let values = vec![1, 2, 3];
//! let mut it = values.into_iter();
//! loop {
//! match it.next() {
//! Some(
&
x) => {
//! Some(x) => {
//! println!("{}", x);
//! }
//! None => { break }
...
...
src/librbml/lib.rs
浏览文件 @
72f59732
...
...
@@ -123,7 +123,6 @@
html_root_url
=
"http://doc.rust-lang.org/nightly/"
,
html_playground_url
=
"http://play.rust-lang.org/"
)]
#![feature(io)]
#![feature(core)]
#![feature(rustc_private)]
#![feature(staged_api)]
...
...
src/librustc/middle/ty.rs
浏览文件 @
72f59732
...
...
@@ -73,7 +73,6 @@
use
std
::
fmt
;
use
std
::
hash
::{
Hash
,
SipHasher
,
Hasher
};
use
std
::
mem
;
use
std
::
num
::
ToPrimitive
;
use
std
::
ops
;
use
std
::
rc
::
Rc
;
use
std
::
vec
::
IntoIter
;
...
...
src/libstd/io/buffered.rs
浏览文件 @
72f59732
...
...
@@ -503,34 +503,34 @@ fn test_buffered_reader() {
let
mut
buf
=
[
0
,
0
,
0
];
let
nread
=
reader
.read
(
&
mut
buf
);
assert_eq!
(
Ok
(
3
),
nread
);
assert_eq!
(
nread
.unwrap
(),
3
);
let
b
:
&
[
_
]
=
&
[
5
,
6
,
7
];
assert_eq!
(
buf
,
b
);
let
mut
buf
=
[
0
,
0
];
let
nread
=
reader
.read
(
&
mut
buf
);
assert_eq!
(
Ok
(
2
),
nread
);
assert_eq!
(
nread
.unwrap
(),
2
);
let
b
:
&
[
_
]
=
&
[
0
,
1
];
assert_eq!
(
buf
,
b
);
let
mut
buf
=
[
0
];
let
nread
=
reader
.read
(
&
mut
buf
);
assert_eq!
(
Ok
(
1
),
nread
);
assert_eq!
(
nread
.unwrap
(),
1
);
let
b
:
&
[
_
]
=
&
[
2
];
assert_eq!
(
buf
,
b
);
let
mut
buf
=
[
0
,
0
,
0
];
let
nread
=
reader
.read
(
&
mut
buf
);
assert_eq!
(
Ok
(
1
),
nread
);
assert_eq!
(
nread
.unwrap
(),
1
);
let
b
:
&
[
_
]
=
&
[
3
,
0
,
0
];
assert_eq!
(
buf
,
b
);
let
nread
=
reader
.read
(
&
mut
buf
);
assert_eq!
(
Ok
(
1
),
nread
);
assert_eq!
(
nread
.unwrap
(),
1
);
let
b
:
&
[
_
]
=
&
[
4
,
0
,
0
];
assert_eq!
(
buf
,
b
);
assert_eq!
(
reader
.read
(
&
mut
buf
)
,
Ok
(
0
)
);
assert_eq!
(
reader
.read
(
&
mut
buf
)
.unwrap
(),
0
);
}
#[test]
...
...
@@ -592,7 +592,7 @@ fn read(&mut self, _: &mut [u8]) -> io::Result<usize> { Ok(0) }
}
let
mut
stream
=
BufStream
::
new
(
S
);
assert_eq!
(
stream
.read
(
&
mut
[
0
;
10
])
,
Ok
(
0
)
);
assert_eq!
(
stream
.read
(
&
mut
[
0
;
10
])
.unwrap
(),
0
);
stream
.write
(
&
[
0
;
10
])
.unwrap
();
stream
.flush
()
.unwrap
();
}
...
...
@@ -658,10 +658,10 @@ fn test_lines() {
let
in_buf
:
&
[
u8
]
=
b
"a
\n
b
\n
c"
;
let
reader
=
BufReader
::
with_capacity
(
2
,
in_buf
);
let
mut
it
=
reader
.lines
();
assert_eq!
(
it
.next
()
,
Some
(
Ok
(
"a"
.to_string
())
));
assert_eq!
(
it
.next
()
,
Some
(
Ok
(
"b"
.to_string
())
));
assert_eq!
(
it
.next
()
,
Some
(
Ok
(
"c"
.to_string
())
));
assert
_eq!
(
it
.next
(),
None
);
assert_eq!
(
it
.next
()
.unwrap
()
.unwrap
(),
"a"
.to_string
(
));
assert_eq!
(
it
.next
()
.unwrap
()
.unwrap
(),
"b"
.to_string
(
));
assert_eq!
(
it
.next
()
.unwrap
()
.unwrap
(),
"c"
.to_string
(
));
assert
!
(
it
.next
()
.is_none
()
);
}
#[test]
...
...
@@ -669,20 +669,20 @@ fn test_short_reads() {
let
inner
=
ShortReader
{
lengths
:
vec!
[
0
,
1
,
2
,
0
,
1
,
0
]};
let
mut
reader
=
BufReader
::
new
(
inner
);
let
mut
buf
=
[
0
,
0
];
assert_eq!
(
reader
.read
(
&
mut
buf
)
,
Ok
(
0
)
);
assert_eq!
(
reader
.read
(
&
mut
buf
)
,
Ok
(
1
)
);
assert_eq!
(
reader
.read
(
&
mut
buf
)
,
Ok
(
2
)
);
assert_eq!
(
reader
.read
(
&
mut
buf
)
,
Ok
(
0
)
);
assert_eq!
(
reader
.read
(
&
mut
buf
)
,
Ok
(
1
)
);
assert_eq!
(
reader
.read
(
&
mut
buf
)
,
Ok
(
0
)
);
assert_eq!
(
reader
.read
(
&
mut
buf
)
,
Ok
(
0
)
);
assert_eq!
(
reader
.read
(
&
mut
buf
)
.unwrap
(),
0
);
assert_eq!
(
reader
.read
(
&
mut
buf
)
.unwrap
(),
1
);
assert_eq!
(
reader
.read
(
&
mut
buf
)
.unwrap
(),
2
);
assert_eq!
(
reader
.read
(
&
mut
buf
)
.unwrap
(),
0
);
assert_eq!
(
reader
.read
(
&
mut
buf
)
.unwrap
(),
1
);
assert_eq!
(
reader
.read
(
&
mut
buf
)
.unwrap
(),
0
);
assert_eq!
(
reader
.read
(
&
mut
buf
)
.unwrap
(),
0
);
}
#[test]
fn
read_char_buffered
()
{
let
buf
=
[
195
,
159
];
let
reader
=
BufReader
::
with_capacity
(
1
,
&
buf
[
..
]);
assert_eq!
(
reader
.chars
()
.next
()
,
Some
(
Ok
(
'ß'
))
);
assert_eq!
(
reader
.chars
()
.next
()
.unwrap
()
.unwrap
(),
'ß'
);
}
#[test]
...
...
@@ -690,9 +690,9 @@ fn test_chars() {
let
buf
=
[
195
,
159
,
b
'a'
];
let
reader
=
BufReader
::
with_capacity
(
1
,
&
buf
[
..
]);
let
mut
it
=
reader
.chars
();
assert_eq!
(
it
.next
()
,
Some
(
Ok
(
'ß'
))
);
assert_eq!
(
it
.next
()
,
Some
(
Ok
(
'a'
))
);
assert
_eq!
(
it
.next
(),
None
);
assert_eq!
(
it
.next
()
.unwrap
()
.unwrap
(),
'ß'
);
assert_eq!
(
it
.next
()
.unwrap
()
.unwrap
(),
'a'
);
assert
!
(
it
.next
()
.is_none
()
);
}
#[test]
...
...
src/libstd/io/cursor.rs
浏览文件 @
72f59732
...
...
@@ -171,9 +171,9 @@ mod tests {
#[test]
fn
test_vec_writer
()
{
let
mut
writer
=
Vec
::
new
();
assert_eq!
(
writer
.write
(
&
[
0
])
,
Ok
(
1
)
);
assert_eq!
(
writer
.write
(
&
[
1
,
2
,
3
])
,
Ok
(
3
)
);
assert_eq!
(
writer
.write
(
&
[
4
,
5
,
6
,
7
])
,
Ok
(
4
)
);
assert_eq!
(
writer
.write
(
&
[
0
])
.unwrap
(),
1
);
assert_eq!
(
writer
.write
(
&
[
1
,
2
,
3
])
.unwrap
(),
3
);
assert_eq!
(
writer
.write
(
&
[
4
,
5
,
6
,
7
])
.unwrap
(),
4
);
let
b
:
&
[
_
]
=
&
[
0
,
1
,
2
,
3
,
4
,
5
,
6
,
7
];
assert_eq!
(
writer
,
b
);
}
...
...
@@ -181,9 +181,9 @@ fn test_vec_writer() {
#[test]
fn
test_mem_writer
()
{
let
mut
writer
=
Cursor
::
new
(
Vec
::
new
());
assert_eq!
(
writer
.write
(
&
[
0
])
,
Ok
(
1
)
);
assert_eq!
(
writer
.write
(
&
[
1
,
2
,
3
])
,
Ok
(
3
)
);
assert_eq!
(
writer
.write
(
&
[
4
,
5
,
6
,
7
])
,
Ok
(
4
)
);
assert_eq!
(
writer
.write
(
&
[
0
])
.unwrap
(),
1
);
assert_eq!
(
writer
.write
(
&
[
1
,
2
,
3
])
.unwrap
(),
3
);
assert_eq!
(
writer
.write
(
&
[
4
,
5
,
6
,
7
])
.unwrap
(),
4
);
let
b
:
&
[
_
]
=
&
[
0
,
1
,
2
,
3
,
4
,
5
,
6
,
7
];
assert_eq!
(
&
writer
.get_ref
()[
..
],
b
);
}
...
...
@@ -194,16 +194,16 @@ fn test_buf_writer() {
{
let
mut
writer
=
Cursor
::
new
(
&
mut
buf
[
..
]);
assert_eq!
(
writer
.position
(),
0
);
assert_eq!
(
writer
.write
(
&
[
0
])
,
Ok
(
1
)
);
assert_eq!
(
writer
.write
(
&
[
0
])
.unwrap
(),
1
);
assert_eq!
(
writer
.position
(),
1
);
assert_eq!
(
writer
.write
(
&
[
1
,
2
,
3
])
,
Ok
(
3
)
);
assert_eq!
(
writer
.write
(
&
[
4
,
5
,
6
,
7
])
,
Ok
(
4
)
);
assert_eq!
(
writer
.write
(
&
[
1
,
2
,
3
])
.unwrap
(),
3
);
assert_eq!
(
writer
.write
(
&
[
4
,
5
,
6
,
7
])
.unwrap
(),
4
);
assert_eq!
(
writer
.position
(),
8
);
assert_eq!
(
writer
.write
(
&
[])
,
Ok
(
0
)
);
assert_eq!
(
writer
.write
(
&
[])
.unwrap
(),
0
);
assert_eq!
(
writer
.position
(),
8
);
assert_eq!
(
writer
.write
(
&
[
8
,
9
])
,
Ok
(
1
)
);
assert_eq!
(
writer
.write
(
&
[
10
])
,
Ok
(
0
)
);
assert_eq!
(
writer
.write
(
&
[
8
,
9
])
.unwrap
(),
1
);
assert_eq!
(
writer
.write
(
&
[
10
])
.unwrap
(),
0
);
}
let
b
:
&
[
_
]
=
&
[
0
,
1
,
2
,
3
,
4
,
5
,
6
,
7
,
8
];
assert_eq!
(
buf
,
b
);
...
...
@@ -215,22 +215,22 @@ fn test_buf_writer_seek() {
{
let
mut
writer
=
Cursor
::
new
(
&
mut
buf
[
..
]);
assert_eq!
(
writer
.position
(),
0
);
assert_eq!
(
writer
.write
(
&
[
1
])
,
Ok
(
1
)
);
assert_eq!
(
writer
.write
(
&
[
1
])
.unwrap
(),
1
);
assert_eq!
(
writer
.position
(),
1
);
assert_eq!
(
writer
.seek
(
SeekFrom
::
Start
(
2
))
,
Ok
(
2
)
);
assert_eq!
(
writer
.seek
(
SeekFrom
::
Start
(
2
))
.unwrap
(),
2
);
assert_eq!
(
writer
.position
(),
2
);
assert_eq!
(
writer
.write
(
&
[
2
])
,
Ok
(
1
)
);
assert_eq!
(
writer
.write
(
&
[
2
])
.unwrap
(),
1
);
assert_eq!
(
writer
.position
(),
3
);
assert_eq!
(
writer
.seek
(
SeekFrom
::
Current
(
-
2
))
,
Ok
(
1
)
);
assert_eq!
(
writer
.seek
(
SeekFrom
::
Current
(
-
2
))
.unwrap
(),
1
);
assert_eq!
(
writer
.position
(),
1
);
assert_eq!
(
writer
.write
(
&
[
3
])
,
Ok
(
1
)
);
assert_eq!
(
writer
.write
(
&
[
3
])
.unwrap
(),
1
);
assert_eq!
(
writer
.position
(),
2
);
assert_eq!
(
writer
.seek
(
SeekFrom
::
End
(
-
1
))
,
Ok
(
7
)
);
assert_eq!
(
writer
.seek
(
SeekFrom
::
End
(
-
1
))
.unwrap
(),
7
);
assert_eq!
(
writer
.position
(),
7
);
assert_eq!
(
writer
.write
(
&
[
4
])
,
Ok
(
1
)
);
assert_eq!
(
writer
.write
(
&
[
4
])
.unwrap
(),
1
);
assert_eq!
(
writer
.position
(),
8
);
}
...
...
@@ -242,31 +242,31 @@ fn test_buf_writer_seek() {
fn
test_buf_writer_error
()
{
let
mut
buf
=
[
0
as
u8
;
2
];
let
mut
writer
=
Cursor
::
new
(
&
mut
buf
[
..
]);
assert_eq!
(
writer
.write
(
&
[
0
])
,
Ok
(
1
)
);
assert_eq!
(
writer
.write
(
&
[
0
,
0
])
,
Ok
(
1
)
);
assert_eq!
(
writer
.write
(
&
[
0
,
0
])
,
Ok
(
0
)
);
assert_eq!
(
writer
.write
(
&
[
0
])
.unwrap
(),
1
);
assert_eq!
(
writer
.write
(
&
[
0
,
0
])
.unwrap
(),
1
);
assert_eq!
(
writer
.write
(
&
[
0
,
0
])
.unwrap
(),
0
);
}
#[test]
fn
test_mem_reader
()
{
let
mut
reader
=
Cursor
::
new
(
vec!
(
0
,
1
,
2
,
3
,
4
,
5
,
6
,
7
));
let
mut
buf
=
[];
assert_eq!
(
reader
.read
(
&
mut
buf
)
,
Ok
(
0
)
);
assert_eq!
(
reader
.read
(
&
mut
buf
)
.unwrap
(),
0
);
assert_eq!
(
reader
.position
(),
0
);
let
mut
buf
=
[
0
];
assert_eq!
(
reader
.read
(
&
mut
buf
)
,
Ok
(
1
)
);
assert_eq!
(
reader
.read
(
&
mut
buf
)
.unwrap
(),
1
);
assert_eq!
(
reader
.position
(),
1
);
let
b
:
&
[
_
]
=
&
[
0
];
assert_eq!
(
buf
,
b
);
let
mut
buf
=
[
0
;
4
];
assert_eq!
(
reader
.read
(
&
mut
buf
)
,
Ok
(
4
)
);
assert_eq!
(
reader
.read
(
&
mut
buf
)
.unwrap
(),
4
);
assert_eq!
(
reader
.position
(),
5
);
let
b
:
&
[
_
]
=
&
[
1
,
2
,
3
,
4
];
assert_eq!
(
buf
,
b
);
assert_eq!
(
reader
.read
(
&
mut
buf
)
,
Ok
(
3
)
);
assert_eq!
(
reader
.read
(
&
mut
buf
)
.unwrap
(),
3
);
let
b
:
&
[
_
]
=
&
[
5
,
6
,
7
];
assert_eq!
(
&
buf
[
..
3
],
b
);
assert_eq!
(
reader
.read
(
&
mut
buf
)
,
Ok
(
0
)
);
assert_eq!
(
reader
.read
(
&
mut
buf
)
.unwrap
(),
0
);
}
#[test]
...
...
@@ -282,21 +282,21 @@ fn test_slice_reader() {
let
in_buf
=
vec!
[
0
,
1
,
2
,
3
,
4
,
5
,
6
,
7
];
let
mut
reader
=
&
mut
&
in_buf
[
..
];
let
mut
buf
=
[];
assert_eq!
(
reader
.read
(
&
mut
buf
)
,
Ok
(
0
)
);
assert_eq!
(
reader
.read
(
&
mut
buf
)
.unwrap
(),
0
);
let
mut
buf
=
[
0
];
assert_eq!
(
reader
.read
(
&
mut
buf
)
,
Ok
(
1
)
);
assert_eq!
(
reader
.read
(
&
mut
buf
)
.unwrap
(),
1
);
assert_eq!
(
reader
.len
(),
7
);
let
b
:
&
[
_
]
=
&
[
0
];
assert_eq!
(
&
buf
[
..
],
b
);
let
mut
buf
=
[
0
;
4
];
assert_eq!
(
reader
.read
(
&
mut
buf
)
,
Ok
(
4
)
);
assert_eq!
(
reader
.read
(
&
mut
buf
)
.unwrap
(),
4
);
assert_eq!
(
reader
.len
(),
3
);
let
b
:
&
[
_
]
=
&
[
1
,
2
,
3
,
4
];
assert_eq!
(
&
buf
[
..
],
b
);
assert_eq!
(
reader
.read
(
&
mut
buf
)
,
Ok
(
3
)
);
assert_eq!
(
reader
.read
(
&
mut
buf
)
.unwrap
(),
3
);
let
b
:
&
[
_
]
=
&
[
5
,
6
,
7
];
assert_eq!
(
&
buf
[
..
3
],
b
);
assert_eq!
(
reader
.read
(
&
mut
buf
)
,
Ok
(
0
)
);
assert_eq!
(
reader
.read
(
&
mut
buf
)
.unwrap
(),
0
);
}
#[test]
...
...
@@ -304,33 +304,33 @@ fn test_buf_reader() {
let
in_buf
=
vec!
[
0
,
1
,
2
,
3
,
4
,
5
,
6
,
7
];
let
mut
reader
=
Cursor
::
new
(
&
in_buf
[
..
]);
let
mut
buf
=
[];
assert_eq!
(
reader
.read
(
&
mut
buf
)
,
Ok
(
0
)
);
assert_eq!
(
reader
.read
(
&
mut
buf
)
.unwrap
(),
0
);
assert_eq!
(
reader
.position
(),
0
);
let
mut
buf
=
[
0
];
assert_eq!
(
reader
.read
(
&
mut
buf
)
,
Ok
(
1
)
);
assert_eq!
(
reader
.read
(
&
mut
buf
)
.unwrap
(),
1
);
assert_eq!
(
reader
.position
(),
1
);
let
b
:
&
[
_
]
=
&
[
0
];
assert_eq!
(
buf
,
b
);
let
mut
buf
=
[
0
;
4
];
assert_eq!
(
reader
.read
(
&
mut
buf
)
,
Ok
(
4
)
);
assert_eq!
(
reader
.read
(
&
mut
buf
)
.unwrap
(),
4
);
assert_eq!
(
reader
.position
(),
5
);
let
b
:
&
[
_
]
=
&
[
1
,
2
,
3
,
4
];
assert_eq!
(
buf
,
b
);
assert_eq!
(
reader
.read
(
&
mut
buf
)
,
Ok
(
3
)
);
assert_eq!
(
reader
.read
(
&
mut
buf
)
.unwrap
(),
3
);
let
b
:
&
[
_
]
=
&
[
5
,
6
,
7
];
assert_eq!
(
&
buf
[
..
3
],
b
);
assert_eq!
(
reader
.read
(
&
mut
buf
)
,
Ok
(
0
)
);
assert_eq!
(
reader
.read
(
&
mut
buf
)
.unwrap
(),
0
);
}
#[test]
fn
test_read_char
()
{
let
b
=
&
b
"Vi
\xE1\xBB\x87
t"
[
..
];
let
mut
c
=
Cursor
::
new
(
b
)
.chars
();
assert_eq!
(
c
.next
()
,
Some
(
Ok
(
'V'
))
);
assert_eq!
(
c
.next
()
,
Some
(
Ok
(
'i'
))
);
assert_eq!
(
c
.next
()
,
Some
(
Ok
(
'ệ'
))
);
assert_eq!
(
c
.next
()
,
Some
(
Ok
(
't'
))
);
assert
_eq!
(
c
.next
(),
None
);
assert_eq!
(
c
.next
()
.unwrap
()
.unwrap
(),
'V'
);
assert_eq!
(
c
.next
()
.unwrap
()
.unwrap
(),
'i'
);
assert_eq!
(
c
.next
()
.unwrap
()
.unwrap
(),
'ệ'
);
assert_eq!
(
c
.next
()
.unwrap
()
.unwrap
(),
't'
);
assert
!
(
c
.next
()
.is_none
()
);
}
#[test]
...
...
@@ -344,17 +344,17 @@ fn test_read_bad_char() {
fn
seek_past_end
()
{
let
buf
=
[
0xff
];
let
mut
r
=
Cursor
::
new
(
&
buf
[
..
]);
assert_eq!
(
r
.seek
(
SeekFrom
::
Start
(
10
))
,
Ok
(
10
)
);
assert_eq!
(
r
.read
(
&
mut
[
0
])
,
Ok
(
0
)
);
assert_eq!
(
r
.seek
(
SeekFrom
::
Start
(
10
))
.unwrap
(),
10
);
assert_eq!
(
r
.read
(
&
mut
[
0
])
.unwrap
(),
0
);
let
mut
r
=
Cursor
::
new
(
vec!
(
10
));
assert_eq!
(
r
.seek
(
SeekFrom
::
Start
(
10
))
,
Ok
(
10
)
);
assert_eq!
(
r
.read
(
&
mut
[
0
])
,
Ok
(
0
)
);
assert_eq!
(
r
.seek
(
SeekFrom
::
Start
(
10
))
.unwrap
(),
10
);
assert_eq!
(
r
.read
(
&
mut
[
0
])
.unwrap
(),
0
);
let
mut
buf
=
[
0
];
let
mut
r
=
Cursor
::
new
(
&
mut
buf
[
..
]);
assert_eq!
(
r
.seek
(
SeekFrom
::
Start
(
10
))
,
Ok
(
10
)
);
assert_eq!
(
r
.write
(
&
[
3
])
,
Ok
(
0
)
);
assert_eq!
(
r
.seek
(
SeekFrom
::
Start
(
10
))
.unwrap
(),
10
);
assert_eq!
(
r
.write
(
&
[
3
])
.unwrap
(),
0
);
}
#[test]
...
...
@@ -375,32 +375,32 @@ fn seek_before_0() {
fn
test_seekable_mem_writer
()
{
let
mut
writer
=
Cursor
::
new
(
Vec
::
<
u8
>
::
new
());
assert_eq!
(
writer
.position
(),
0
);
assert_eq!
(
writer
.write
(
&
[
0
])
,
Ok
(
1
)
);
assert_eq!
(
writer
.write
(
&
[
0
])
.unwrap
(),
1
);
assert_eq!
(
writer
.position
(),
1
);
assert_eq!
(
writer
.write
(
&
[
1
,
2
,
3
])
,
Ok
(
3
)
);
assert_eq!
(
writer
.write
(
&
[
4
,
5
,
6
,
7
])
,
Ok
(
4
)
);
assert_eq!
(
writer
.write
(
&
[
1
,
2
,
3
])
.unwrap
(),
3
);
assert_eq!
(
writer
.write
(
&
[
4
,
5
,
6
,
7
])
.unwrap
(),
4
);
assert_eq!
(
writer
.position
(),
8
);
let
b
:
&
[
_
]
=
&
[
0
,
1
,
2
,
3
,
4
,
5
,
6
,
7
];
assert_eq!
(
&
writer
.get_ref
()[
..
],
b
);
assert_eq!
(
writer
.seek
(
SeekFrom
::
Start
(
0
))
,
Ok
(
0
)
);
assert_eq!
(
writer
.seek
(
SeekFrom
::
Start
(
0
))
.unwrap
(),
0
);
assert_eq!
(
writer
.position
(),
0
);
assert_eq!
(
writer
.write
(
&
[
3
,
4
])
,
Ok
(
2
)
);
assert_eq!
(
writer
.write
(
&
[
3
,
4
])
.unwrap
(),
2
);
let
b
:
&
[
_
]
=
&
[
3
,
4
,
2
,
3
,
4
,
5
,
6
,
7
];
assert_eq!
(
&
writer
.get_ref
()[
..
],
b
);
assert_eq!
(
writer
.seek
(
SeekFrom
::
Current
(
1
))
,
Ok
(
3
)
);
assert_eq!
(
writer
.write
(
&
[
0
,
1
])
,
Ok
(
2
)
);
assert_eq!
(
writer
.seek
(
SeekFrom
::
Current
(
1
))
.unwrap
(),
3
);
assert_eq!
(
writer
.write
(
&
[
0
,
1
])
.unwrap
(),
2
);
let
b
:
&
[
_
]
=
&
[
3
,
4
,
2
,
0
,
1
,
5
,
6
,
7
];
assert_eq!
(
&
writer
.get_ref
()[
..
],
b
);
assert_eq!
(
writer
.seek
(
SeekFrom
::
End
(
-
1
))
,
Ok
(
7
)
);
assert_eq!
(
writer
.write
(
&
[
1
,
2
])
,
Ok
(
2
)
);
assert_eq!
(
writer
.seek
(
SeekFrom
::
End
(
-
1
))
.unwrap
(),
7
);
assert_eq!
(
writer
.write
(
&
[
1
,
2
])
.unwrap
(),
2
);
let
b
:
&
[
_
]
=
&
[
3
,
4
,
2
,
0
,
1
,
5
,
6
,
1
,
2
];
assert_eq!
(
&
writer
.get_ref
()[
..
],
b
);
assert_eq!
(
writer
.seek
(
SeekFrom
::
End
(
1
))
,
Ok
(
10
)
);
assert_eq!
(
writer
.write
(
&
[
1
])
,
Ok
(
1
)
);
assert_eq!
(
writer
.seek
(
SeekFrom
::
End
(
1
))
.unwrap
(),
10
);
assert_eq!
(
writer
.write
(
&
[
1
])
.unwrap
(),
1
);
let
b
:
&
[
_
]
=
&
[
3
,
4
,
2
,
0
,
1
,
5
,
6
,
1
,
2
,
0
,
1
];
assert_eq!
(
&
writer
.get_ref
()[
..
],
b
);
}
...
...
@@ -408,8 +408,8 @@ fn test_seekable_mem_writer() {
#[test]
fn
vec_seek_past_end
()
{
let
mut
r
=
Cursor
::
new
(
Vec
::
new
());
assert_eq!
(
r
.seek
(
SeekFrom
::
Start
(
10
))
,
Ok
(
10
)
);
assert_eq!
(
r
.write
(
&
[
3
])
,
Ok
(
1
)
);
assert_eq!
(
r
.seek
(
SeekFrom
::
Start
(
10
))
.unwrap
(),
10
);
assert_eq!
(
r
.write
(
&
[
3
])
.unwrap
(),
1
);
}
#[test]
...
...
src/libstd/io/mod.rs
浏览文件 @
72f59732
...
...
@@ -920,18 +920,18 @@ mod tests {
fn
read_until
()
{
let
mut
buf
=
Cursor
::
new
(
&
b
"12"
[
..
]);
let
mut
v
=
Vec
::
new
();
assert_eq!
(
buf
.read_until
(
b
'3'
,
&
mut
v
)
,
Ok
(
2
)
);
assert_eq!
(
buf
.read_until
(
b
'3'
,
&
mut
v
)
.unwrap
(),
2
);
assert_eq!
(
v
,
b
"12"
);
let
mut
buf
=
Cursor
::
new
(
&
b
"1233"
[
..
]);
let
mut
v
=
Vec
::
new
();
assert_eq!
(
buf
.read_until
(
b
'3'
,
&
mut
v
)
,
Ok
(
3
)
);
assert_eq!
(
buf
.read_until
(
b
'3'
,
&
mut
v
)
.unwrap
(),
3
);
assert_eq!
(
v
,
b
"123"
);
v
.truncate
(
0
);
assert_eq!
(
buf
.read_until
(
b
'3'
,
&
mut
v
)
,
Ok
(
1
)
);
assert_eq!
(
buf
.read_until
(
b
'3'
,
&
mut
v
)
.unwrap
(),
1
);
assert_eq!
(
v
,
b
"3"
);
v
.truncate
(
0
);
assert_eq!
(
buf
.read_until
(
b
'3'
,
&
mut
v
)
,
Ok
(
0
)
);
assert_eq!
(
buf
.read_until
(
b
'3'
,
&
mut
v
)
.unwrap
(),
0
);
assert_eq!
(
v
,
[]);
}
...
...
@@ -939,32 +939,32 @@ fn read_until() {
fn
split
()
{
let
buf
=
Cursor
::
new
(
&
b
"12"
[
..
]);
let
mut
s
=
buf
.split
(
b
'3'
);
assert_eq!
(
s
.next
()
,
Some
(
Ok
(
vec!
[
b
'1'
,
b
'2'
]))
);
assert
_eq!
(
s
.next
(),
None
);
assert_eq!
(
s
.next
()
.unwrap
()
.unwrap
(),
vec!
[
b
'1'
,
b
'2'
]
);
assert
!
(
s
.next
()
.is_none
()
);
let
buf
=
Cursor
::
new
(
&
b
"1233"
[
..
]);
let
mut
s
=
buf
.split
(
b
'3'
);
assert_eq!
(
s
.next
()
,
Some
(
Ok
(
vec!
[
b
'1'
,
b
'2'
]))
);
assert_eq!
(
s
.next
()
,
Some
(
Ok
(
vec!
[]))
);
assert
_eq!
(
s
.next
(),
None
);
assert_eq!
(
s
.next
()
.unwrap
()
.unwrap
(),
vec!
[
b
'1'
,
b
'2'
]
);
assert_eq!
(
s
.next
()
.unwrap
()
.unwrap
(),
vec!
[]
);
assert
!
(
s
.next
()
.is_none
()
);
}
#[test]
fn
read_line
()
{
let
mut
buf
=
Cursor
::
new
(
&
b
"12"
[
..
]);
let
mut
v
=
String
::
new
();
assert_eq!
(
buf
.read_line
(
&
mut
v
)
,
Ok
(
2
)
);
assert_eq!
(
buf
.read_line
(
&
mut
v
)
.unwrap
(),
2
);
assert_eq!
(
v
,
"12"
);
let
mut
buf
=
Cursor
::
new
(
&
b
"12
\n\n
"
[
..
]);
let
mut
v
=
String
::
new
();
assert_eq!
(
buf
.read_line
(
&
mut
v
)
,
Ok
(
3
)
);
assert_eq!
(
buf
.read_line
(
&
mut
v
)
.unwrap
(),
3
);
assert_eq!
(
v
,
"12
\n
"
);
v
.truncate
(
0
);
assert_eq!
(
buf
.read_line
(
&
mut
v
)
,
Ok
(
1
)
);
assert_eq!
(
buf
.read_line
(
&
mut
v
)
.unwrap
(),
1
);
assert_eq!
(
v
,
"
\n
"
);
v
.truncate
(
0
);
assert_eq!
(
buf
.read_line
(
&
mut
v
)
,
Ok
(
0
)
);
assert_eq!
(
buf
.read_line
(
&
mut
v
)
.unwrap
(),
0
);
assert_eq!
(
v
,
""
);
}
...
...
@@ -972,26 +972,26 @@ fn read_line() {
fn
lines
()
{
let
buf
=
Cursor
::
new
(
&
b
"12"
[
..
]);
let
mut
s
=
buf
.lines
();
assert_eq!
(
s
.next
()
,
Some
(
Ok
(
"12"
.to_string
())
));
assert
_eq!
(
s
.next
(),
None
);
assert_eq!
(
s
.next
()
.unwrap
()
.unwrap
(),
"12"
.to_string
(
));
assert
!
(
s
.next
()
.is_none
()
);
let
buf
=
Cursor
::
new
(
&
b
"12
\n\n
"
[
..
]);
let
mut
s
=
buf
.lines
();
assert_eq!
(
s
.next
()
,
Some
(
Ok
(
"12"
.to_string
())
));
assert_eq!
(
s
.next
()
,
Some
(
Ok
(
String
::
new
())
));
assert
_eq!
(
s
.next
(),
None
);
assert_eq!
(
s
.next
()
.unwrap
()
.unwrap
(),
"12"
.to_string
(
));
assert_eq!
(
s
.next
()
.unwrap
()
.unwrap
(),
""
.to_string
(
));
assert
!
(
s
.next
()
.is_none
()
);
}
#[test]
fn
read_to_end
()
{
let
mut
c
=
Cursor
::
new
(
&
b
""
[
..
]);
let
mut
v
=
Vec
::
new
();
assert_eq!
(
c
.read_to_end
(
&
mut
v
)
,
Ok
(
0
)
);
assert_eq!
(
c
.read_to_end
(
&
mut
v
)
.unwrap
(),
0
);
assert_eq!
(
v
,
[]);
let
mut
c
=
Cursor
::
new
(
&
b
"1"
[
..
]);
let
mut
v
=
Vec
::
new
();
assert_eq!
(
c
.read_to_end
(
&
mut
v
)
,
Ok
(
1
)
);
assert_eq!
(
c
.read_to_end
(
&
mut
v
)
.unwrap
(),
1
);
assert_eq!
(
v
,
b
"1"
);
}
...
...
@@ -999,12 +999,12 @@ fn read_to_end() {
fn
read_to_string
()
{
let
mut
c
=
Cursor
::
new
(
&
b
""
[
..
]);
let
mut
v
=
String
::
new
();
assert_eq!
(
c
.read_to_string
(
&
mut
v
)
,
Ok
(
0
)
);
assert_eq!
(
c
.read_to_string
(
&
mut
v
)
.unwrap
(),
0
);
assert_eq!
(
v
,
""
);
let
mut
c
=
Cursor
::
new
(
&
b
"1"
[
..
]);
let
mut
v
=
String
::
new
();
assert_eq!
(
c
.read_to_string
(
&
mut
v
)
,
Ok
(
1
)
);
assert_eq!
(
c
.read_to_string
(
&
mut
v
)
.unwrap
(),
1
);
assert_eq!
(
v
,
"1"
);
let
mut
c
=
Cursor
::
new
(
&
b
"
\xff
"
[
..
]);
...
...
@@ -1018,11 +1018,11 @@ fn take_eof() {
impl
Read
for
R
{
fn
read
(
&
mut
self
,
_
:
&
mut
[
u8
])
->
io
::
Result
<
usize
>
{
Err
(
io
::
Error
::
new
(
io
::
ErrorKind
::
Other
,
""
,
None
))
Err
(
io
::
Error
::
new
(
io
::
ErrorKind
::
Other
,
""
))
}
}
let
mut
buf
=
[
0
;
1
];
assert_eq!
(
Ok
(
0
),
R
.take
(
0
)
.read
(
&
mut
buf
));
assert_eq!
(
0
,
R
.take
(
0
)
.read
(
&
mut
buf
)
.unwrap
(
));
}
}
src/libstd/io/util.rs
浏览文件 @
72f59732
...
...
@@ -111,33 +111,33 @@ mod test {
#[test]
fn
sink_sinks
()
{
let
mut
s
=
sink
();
assert_eq!
(
s
.write
(
&
[])
,
Ok
(
0
)
);
assert_eq!
(
s
.write
(
&
[
0
])
,
Ok
(
1
)
);
assert_eq!
(
s
.write
(
&
[
0
;
1024
])
,
Ok
(
1024
)
);
assert_eq!
(
s
.by_ref
()
.write
(
&
[
0
;
1024
])
,
Ok
(
1024
)
);
assert_eq!
(
s
.write
(
&
[])
.unwrap
(),
0
);
assert_eq!
(
s
.write
(
&
[
0
])
.unwrap
(),
1
);
assert_eq!
(
s
.write
(
&
[
0
;
1024
])
.unwrap
(),
1024
);
assert_eq!
(
s
.by_ref
()
.write
(
&
[
0
;
1024
])
.unwrap
(),
1024
);
}
#[test]
fn
empty_reads
()
{
let
mut
e
=
empty
();
assert_eq!
(
e
.read
(
&
mut
[])
,
Ok
(
0
)
);
assert_eq!
(
e
.read
(
&
mut
[
0
])
,
Ok
(
0
)
);
assert_eq!
(
e
.read
(
&
mut
[
0
;
1024
])
,
Ok
(
0
)
);
assert_eq!
(
e
.by_ref
()
.read
(
&
mut
[
0
;
1024
])
,
Ok
(
0
)
);
assert_eq!
(
e
.read
(
&
mut
[])
.unwrap
(),
0
);
assert_eq!
(
e
.read
(
&
mut
[
0
])
.unwrap
(),
0
);
assert_eq!
(
e
.read
(
&
mut
[
0
;
1024
])
.unwrap
(),
0
);
assert_eq!
(
e
.by_ref
()
.read
(
&
mut
[
0
;
1024
])
.unwrap
(),
0
);
}
#[test]
fn
repeat_repeats
()
{
let
mut
r
=
repeat
(
4
);
let
mut
b
=
[
0
;
1024
];
assert_eq!
(
r
.read
(
&
mut
b
)
,
Ok
(
1024
)
);
assert_eq!
(
r
.read
(
&
mut
b
)
.unwrap
(),
1024
);
assert
!
(
b
.iter
()
.all
(|
b
|
*
b
==
4
));
}
#[test]
fn
take_some_bytes
()
{
assert_eq!
(
repeat
(
4
)
.take
(
100
)
.bytes
()
.count
(),
100
);
assert_eq!
(
repeat
(
4
)
.take
(
100
)
.bytes
()
.next
()
,
Some
(
Ok
(
4
))
);
assert_eq!
(
repeat
(
4
)
.take
(
100
)
.bytes
()
.next
()
.unwrap
()
.unwrap
(),
4
);
assert_eq!
(
repeat
(
1
)
.take
(
10
)
.chain
(
repeat
(
2
)
.take
(
10
))
.bytes
()
.count
(),
20
);
}
...
...
@@ -146,7 +146,7 @@ fn tee() {
let
mut
buf
=
[
0
;
10
];
{
let
mut
ptr
:
&
mut
[
u8
]
=
&
mut
buf
;
assert_eq!
(
repeat
(
4
)
.tee
(
&
mut
ptr
)
.take
(
5
)
.read
(
&
mut
[
0
;
10
])
,
Ok
(
5
)
);
assert_eq!
(
repeat
(
4
)
.tee
(
&
mut
ptr
)
.take
(
5
)
.read
(
&
mut
[
0
;
10
])
.unwrap
(),
5
);
}
assert_eq!
(
buf
,
[
4
,
4
,
4
,
4
,
4
,
0
,
0
,
0
,
0
,
0
]);
}
...
...
@@ -160,7 +160,7 @@ fn broadcast() {
let
mut
ptr2
:
&
mut
[
u8
]
=
&
mut
buf2
;
assert_eq!
((
&
mut
ptr1
)
.broadcast
(
&
mut
ptr2
)
.write
(
&
[
1
,
2
,
3
])
,
Ok
(
3
)
);
.write
(
&
[
1
,
2
,
3
])
.unwrap
(),
3
);
}
assert_eq!
(
buf1
,
buf2
);
assert_eq!
(
buf1
,
[
1
,
2
,
3
,
0
,
0
,
0
,
0
,
0
,
0
,
0
]);
...
...
src/libstd/net/addr.rs
浏览文件 @
72f59732
...
...
@@ -697,8 +697,11 @@ fn check(str_addr: &str, unspec: bool, loopback: bool,
false
,
false
,
false
,
true
,
false
,
false
,
false
,
Some
(
Global
));
}
fn
tsa
<
A
:
ToSocketAddrs
>
(
a
:
A
)
->
io
::
Result
<
Vec
<
SocketAddr
>>
{
Ok
(
try!
(
a
.to_socket_addrs
())
.collect
())
fn
tsa
<
A
:
ToSocketAddrs
>
(
a
:
A
)
->
Result
<
Vec
<
SocketAddr
>
,
String
>
{
match
a
.to_socket_addrs
()
{
Ok
(
a
)
=>
Ok
(
a
.collect
()),
Err
(
e
)
=>
Err
(
e
.to_string
()),
}
}
#[test]
...
...
src/libstd/net/tcp.rs
浏览文件 @
72f59732
...
...
@@ -521,7 +521,7 @@ fn partial_read() {
let
mut
c
=
t!
(
TcpStream
::
connect
(
&
addr
));
let
mut
b
=
[
0
;
10
];
assert_eq!
(
c
.read
(
&
mut
b
)
,
Ok
(
1
)
);
assert_eq!
(
c
.read
(
&
mut
b
)
.unwrap
(),
1
);
t!
(
c
.write
(
&
[
1
]));
rx
.recv
()
.unwrap
();
})
...
...
@@ -566,7 +566,7 @@ fn tcp_clone_smoke() {
let
_
t
=
thread
::
spawn
(
move
||
{
let
mut
s
=
t!
(
TcpStream
::
connect
(
&
addr
));
let
mut
buf
=
[
0
,
0
];
assert_eq!
(
s
.read
(
&
mut
buf
)
,
Ok
(
1
)
);
assert_eq!
(
s
.read
(
&
mut
buf
)
.unwrap
(),
1
);
assert_eq!
(
buf
[
0
],
1
);
t!
(
s
.write
(
&
[
2
]));
});
...
...
@@ -584,7 +584,7 @@ fn tcp_clone_smoke() {
});
tx1
.send
(())
.unwrap
();
let
mut
buf
=
[
0
,
0
];
assert_eq!
(
s1
.read
(
&
mut
buf
)
,
Ok
(
1
)
);
assert_eq!
(
s1
.read
(
&
mut
buf
)
.unwrap
(),
1
);
rx2
.recv
()
.unwrap
();
})
}
...
...
@@ -657,7 +657,7 @@ fn shutdown_smoke() {
let
_
t
=
thread
::
spawn
(
move
||
{
let
mut
c
=
t!
(
a
.accept
())
.0
;
let
mut
b
=
[
0
];
assert_eq!
(
c
.read
(
&
mut
b
)
,
Ok
(
0
)
);
assert_eq!
(
c
.read
(
&
mut
b
)
.unwrap
(),
0
);
t!
(
c
.write
(
&
[
1
]));
});
...
...
@@ -688,16 +688,16 @@ fn close_readwrite_smoke() {
t!
(
s
.shutdown
(
Shutdown
::
Write
));
assert
!
(
s
.write
(
&
[
0
])
.is_err
());
t!
(
s
.shutdown
(
Shutdown
::
Read
));
assert_eq!
(
s
.read
(
&
mut
b
)
,
Ok
(
0
)
);
assert_eq!
(
s
.read
(
&
mut
b
)
.unwrap
(),
0
);
// closing should affect previous handles
assert
!
(
s2
.write
(
&
[
0
])
.is_err
());
assert_eq!
(
s2
.read
(
&
mut
b
)
,
Ok
(
0
)
);
assert_eq!
(
s2
.read
(
&
mut
b
)
.unwrap
(),
0
);
// closing should affect new handles
let
mut
s3
=
t!
(
s
.try_clone
());
assert
!
(
s3
.write
(
&
[
0
])
.is_err
());
assert_eq!
(
s3
.read
(
&
mut
b
)
,
Ok
(
0
)
);
assert_eq!
(
s3
.read
(
&
mut
b
)
.unwrap
(),
0
);
// make sure these don't die
let
_
=
s2
.shutdown
(
Shutdown
::
Read
);
...
...
src/libstd/net/udp.rs
浏览文件 @
72f59732
...
...
@@ -212,7 +212,7 @@ fn udp_clone_smoke() {
let
_
t
=
thread
::
spawn
(
move
||
{
let
mut
buf
=
[
0
,
0
];
assert_eq!
(
sock2
.recv_from
(
&
mut
buf
)
,
Ok
((
1
,
addr1
)
));
assert_eq!
(
sock2
.recv_from
(
&
mut
buf
)
.unwrap
(),
(
1
,
addr1
));
assert_eq!
(
buf
[
0
],
1
);
t!
(
sock2
.send_to
(
&
[
2
],
&
addr1
));
});
...
...
@@ -228,7 +228,7 @@ fn udp_clone_smoke() {
});
tx1
.send
(())
.unwrap
();
let
mut
buf
=
[
0
,
0
];
assert_eq!
(
sock1
.recv_from
(
&
mut
buf
)
,
Ok
((
1
,
addr2
)
));
assert_eq!
(
sock1
.recv_from
(
&
mut
buf
)
.unwrap
(),
(
1
,
addr2
));
rx2
.recv
()
.unwrap
();
})
}
...
...
src/libstd/process.rs
浏览文件 @
72f59732
...
...
@@ -576,7 +576,7 @@ fn exit_reported_right() {
assert
!
(
p
.is_ok
());
let
mut
p
=
p
.unwrap
();
assert
!
(
p
.wait
()
.unwrap
()
.code
()
==
Some
(
1
));
drop
(
p
.wait
()
.clone
()
);
drop
(
p
.wait
());
}
#[cfg(all(unix,
not(target_os=
"android"
)))]
...
...
src/libstd/sys/unix/fs2.rs
浏览文件 @
72f59732
...
...
@@ -277,7 +277,7 @@ pub fn fd(&self) -> &FileDesc { &self.0 }
fn
cstr
(
path
:
&
Path
)
->
io
::
Result
<
CString
>
{
path
.as_os_str
()
.to_cstring
()
.ok_or
(
io
::
Error
::
new
(
io
::
ErrorKind
::
InvalidInput
,
"path contained a null"
,
None
))
io
::
Error
::
new
(
io
::
ErrorKind
::
InvalidInput
,
"path contained a null"
))
}
impl
FromInner
<
c_int
>
for
File
{
...
...
src/libstd/sys/windows/c.rs
浏览文件 @
72f59732
...
...
@@ -433,7 +433,7 @@ pub fn OpenProcessToken(ProcessHandle: libc::HANDLE,
TokenHandle
:
*
mut
libc
::
HANDLE
)
->
libc
::
BOOL
;
pub
fn
GetCurrentProcess
()
->
libc
::
HANDLE
;
pub
fn
GetStdHandle
(
which
:
libc
::
DWORD
)
->
libc
::
HANDLE
;
pub
fn
ExitProcess
(
uExitCode
:
libc
::
UINT
)
->
!
;
pub
fn
ExitProcess
(
uExitCode
:
libc
::
c_uint
)
->
!
;
}
#[link(name
=
"userenv"
)]
...
...
src/libstd/sys/windows/os.rs
浏览文件 @
72f59732
...
...
@@ -382,5 +382,5 @@ pub fn home_dir() -> Option<PathBuf> {
}
pub
fn
exit
(
code
:
i32
)
->
!
{
unsafe
{
libc
::
ExitProcess
(
code
as
libc
::
UINT
)
}
unsafe
{
c
::
ExitProcess
(
code
as
libc
::
c_uint
)
}
}
src/libstd/sys/windows/stdio.rs
浏览文件 @
72f59732
...
...
@@ -41,7 +41,7 @@ fn get(handle: libc::DWORD) -> io::Result<Output> {
Err
(
io
::
Error
::
last_os_error
())
}
else
if
handle
.is_null
()
{
Err
(
io
::
Error
::
new
(
io
::
ErrorKind
::
Other
,
"no stdio handle available for this process"
,
None
))
"no stdio handle available for this process"
))
}
else
{
let
ret
=
NoClose
::
new
(
handle
);
let
mut
out
=
0
;
...
...
@@ -160,6 +160,5 @@ fn drop(&mut self) {
}
fn
invalid_encoding
()
->
io
::
Error
{
io
::
Error
::
new
(
io
::
ErrorKind
::
InvalidInput
,
"text was not valid unicode"
,
None
)
io
::
Error
::
new
(
io
::
ErrorKind
::
InvalidInput
,
"text was not valid unicode"
)
}
src/test/run-pass/issue-22577.rs
浏览文件 @
72f59732
...
...
@@ -15,13 +15,14 @@
use
std
::{
fs
,
net
};
fn
assert_both
<
T
:
Send
+
Sync
>
()
{}
fn
assert_send
<
T
:
Send
>
()
{}
fn
main
()
{
assert_both
::
<
fs
::
File
>
();
assert_both
::
<
fs
::
Metadata
>
();
assert_both
::
<
fs
::
ReadDir
>
();
assert_both
::
<
fs
::
DirEntry
>
();
assert_
both
::
<
fs
::
WalkDir
>
();
assert_
send
::
<
fs
::
WalkDir
>
();
assert_both
::
<
fs
::
OpenOptions
>
();
assert_both
::
<
fs
::
Permissions
>
();
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录