Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
c2da923f
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,发现更多精彩内容 >>
提交
c2da923f
编写于
11月 27, 2014
作者:
J
Jorge Aparicio
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
libstd: remove unnecessary `to_string()` calls
上级
ba01ea37
变更
17
隐藏空白更改
内联
并排
Showing
17 changed file
with
96 addition
and
96 deletion
+96
-96
src/libstd/ascii.rs
src/libstd/ascii.rs
+21
-21
src/libstd/collections/hash/map.rs
src/libstd/collections/hash/map.rs
+2
-2
src/libstd/collections/hash/set.rs
src/libstd/collections/hash/set.rs
+2
-2
src/libstd/collections/lru_cache.rs
src/libstd/collections/lru_cache.rs
+6
-6
src/libstd/io/mem.rs
src/libstd/io/mem.rs
+2
-2
src/libstd/io/mod.rs
src/libstd/io/mod.rs
+8
-8
src/libstd/io/net/ip.rs
src/libstd/io/net/ip.rs
+3
-3
src/libstd/io/process.rs
src/libstd/io/process.rs
+5
-5
src/libstd/io/stdio.rs
src/libstd/io/stdio.rs
+1
-1
src/libstd/num/strconv.rs
src/libstd/num/strconv.rs
+8
-8
src/libstd/num/uint_macros.rs
src/libstd/num/uint_macros.rs
+8
-8
src/libstd/path/windows.rs
src/libstd/path/windows.rs
+2
-2
src/libstd/rt/backtrace.rs
src/libstd/rt/backtrace.rs
+1
-1
src/libstd/sync/future.rs
src/libstd/sync/future.rs
+6
-6
src/libstd/sys/windows/process.rs
src/libstd/sys/windows/process.rs
+5
-5
src/libstd/task.rs
src/libstd/task.rs
+5
-5
src/libstd/time/duration.rs
src/libstd/time/duration.rs
+11
-11
未找到文件。
src/libstd/ascii.rs
浏览文件 @
c2da923f
...
...
@@ -680,13 +680,13 @@ fn test_ascii_vec() {
assert_eq!
(
v
.to_ascii
(),
b
);
assert_eq!
(
"( ;"
.to_string
()
.to_ascii
(),
b
);
assert_eq!
(
"abCDef&?#"
.to_ascii
()
.to_lowercase
()
.into_string
(),
"abcdef&?#"
.to_string
()
);
assert_eq!
(
"abCDef&?#"
.to_ascii
()
.to_uppercase
()
.into_string
(),
"ABCDEF&?#"
.to_string
()
);
assert_eq!
(
"abCDef&?#"
.to_ascii
()
.to_lowercase
()
.into_string
(),
"abcdef&?#"
);
assert_eq!
(
"abCDef&?#"
.to_ascii
()
.to_uppercase
()
.into_string
(),
"ABCDEF&?#"
);
assert_eq!
(
""
.to_ascii
()
.to_lowercase
()
.into_string
(),
""
.to_string
()
);
assert_eq!
(
"YMCA"
.to_ascii
()
.to_lowercase
()
.into_string
(),
"ymca"
.to_string
()
);
assert_eq!
(
""
.to_ascii
()
.to_lowercase
()
.into_string
(),
""
);
assert_eq!
(
"YMCA"
.to_ascii
()
.to_lowercase
()
.into_string
(),
"ymca"
);
let
mixed
=
"abcDEFxyz:.;"
.to_ascii
();
assert_eq!
(
mixed
.to_uppercase
()
.into_string
(),
"ABCDEFXYZ:.;"
.to_string
()
);
assert_eq!
(
mixed
.to_uppercase
()
.into_string
(),
"ABCDEFXYZ:.;"
);
assert
!
(
"aBcDeF&?#"
.to_ascii
()
.eq_ignore_case
(
"AbCdEf&?#"
.to_ascii
()));
...
...
@@ -698,12 +698,12 @@ fn test_ascii_vec() {
#[test]
fn
test_ascii_vec_ng
()
{
assert_eq!
(
"abCDef&?#"
.to_ascii
()
.to_lowercase
()
.into_string
(),
"abcdef&?#"
.to_string
()
);
assert_eq!
(
"abCDef&?#"
.to_ascii
()
.to_uppercase
()
.into_string
(),
"ABCDEF&?#"
.to_string
()
);
assert_eq!
(
""
.to_ascii
()
.to_lowercase
()
.into_string
(),
""
.to_string
()
);
assert_eq!
(
"YMCA"
.to_ascii
()
.to_lowercase
()
.into_string
(),
"ymca"
.to_string
()
);
assert_eq!
(
"abCDef&?#"
.to_ascii
()
.to_lowercase
()
.into_string
(),
"abcdef&?#"
);
assert_eq!
(
"abCDef&?#"
.to_ascii
()
.to_uppercase
()
.into_string
(),
"ABCDEF&?#"
);
assert_eq!
(
""
.to_ascii
()
.to_lowercase
()
.into_string
(),
""
);
assert_eq!
(
"YMCA"
.to_ascii
()
.to_lowercase
()
.into_string
(),
"ymca"
);
let
mixed
=
"abcDEFxyz:.;"
.to_ascii
();
assert_eq!
(
mixed
.to_uppercase
()
.into_string
(),
"ABCDEFXYZ:.;"
.to_string
()
);
assert_eq!
(
mixed
.to_uppercase
()
.into_string
(),
"ABCDEFXYZ:.;"
);
}
#[test]
...
...
@@ -720,8 +720,8 @@ fn test_ascii_as_str() {
#[test]
fn
test_ascii_into_string
()
{
assert_eq!
(
vec2ascii!
[
40
,
32
,
59
]
.into_string
(),
"( ;"
.to_string
()
);
assert_eq!
(
vec2ascii!
(
40
,
32
,
59
)
.into_string
(),
"( ;"
.to_string
()
);
assert_eq!
(
vec2ascii!
[
40
,
32
,
59
]
.into_string
(),
"( ;"
);
assert_eq!
(
vec2ascii!
(
40
,
32
,
59
)
.into_string
(),
"( ;"
);
}
#[test]
...
...
@@ -773,8 +773,8 @@ fn test_opt() {
#[test]
fn
test_to_ascii_upper
()
{
assert_eq!
(
"url()URL()uRl()ürl"
.to_ascii_upper
(),
"URL()URL()URL()üRL"
.to_string
()
);
assert_eq!
(
"hıKß"
.to_ascii_upper
(),
"HıKß"
.to_string
()
);
assert_eq!
(
"url()URL()uRl()ürl"
.to_ascii_upper
(),
"URL()URL()URL()üRL"
);
assert_eq!
(
"hıKß"
.to_ascii_upper
(),
"HıKß"
);
let
mut
i
=
0
;
while
i
<=
500
{
...
...
@@ -788,9 +788,9 @@ fn test_to_ascii_upper() {
#[test]
fn
test_to_ascii_lower
()
{
assert_eq!
(
"url()URL()uRl()Ürl"
.to_ascii_lower
(),
"url()url()url()Ürl"
.to_string
()
);
assert_eq!
(
"url()URL()uRl()Ürl"
.to_ascii_lower
(),
"url()url()url()Ürl"
);
// Dotted capital I, Kelvin sign, Sharp S.
assert_eq!
(
"HİKß"
.to_ascii_lower
(),
"hİKß"
.to_string
()
);
assert_eq!
(
"HİKß"
.to_ascii_lower
(),
"hİKß"
);
let
mut
i
=
0
;
while
i
<=
500
{
...
...
@@ -806,7 +806,7 @@ fn test_to_ascii_lower() {
fn
test_into_ascii_upper
()
{
assert_eq!
((
"url()URL()uRl()ürl"
.to_string
())
.into_ascii_upper
(),
"URL()URL()URL()üRL"
.to_string
());
assert_eq!
((
"hıKß"
.to_string
())
.into_ascii_upper
(),
"HıKß"
.to_string
()
);
assert_eq!
((
"hıKß"
.to_string
())
.into_ascii_upper
(),
"HıKß"
);
let
mut
i
=
0
;
while
i
<=
500
{
...
...
@@ -821,9 +821,9 @@ fn test_into_ascii_upper() {
#[test]
fn
test_into_ascii_lower
()
{
assert_eq!
((
"url()URL()uRl()Ürl"
.to_string
())
.into_ascii_lower
(),
"url()url()url()Ürl"
.to_string
()
);
"url()url()url()Ürl"
);
// Dotted capital I, Kelvin sign, Sharp S.
assert_eq!
((
"HİKß"
.to_string
())
.into_ascii_lower
(),
"hİKß"
.to_string
()
);
assert_eq!
((
"HİKß"
.to_string
())
.into_ascii_lower
(),
"hİKß"
);
let
mut
i
=
0
;
while
i
<=
500
{
...
...
@@ -859,12 +859,12 @@ fn test_eq_ignore_ascii_case() {
#[test]
fn
test_to_string
()
{
let
s
=
Ascii
{
chr
:
b
't'
}
.to_string
();
assert_eq!
(
s
,
"t"
.to_string
()
);
assert_eq!
(
s
,
"t"
);
}
#[test]
fn
test_show
()
{
let
c
=
Ascii
{
chr
:
b
't'
};
assert_eq!
(
format!
(
"{}"
,
c
),
"t"
.to_string
()
);
assert_eq!
(
format!
(
"{}"
,
c
),
"t"
);
}
}
src/libstd/collections/hash/map.rs
浏览文件 @
c2da923f
...
...
@@ -1903,8 +1903,8 @@ fn test_show() {
let
map_str
=
format!
(
"{}"
,
map
);
assert
!
(
map_str
==
"{1: 2, 3: 4}"
.to_string
()
||
map_str
==
"{3: 4, 1: 2}"
.to_string
()
);
assert_eq!
(
format!
(
"{}"
,
empty
),
"{}"
.to_string
()
);
assert
!
(
map_str
==
"{1: 2, 3: 4}"
||
map_str
==
"{3: 4, 1: 2}"
);
assert_eq!
(
format!
(
"{}"
,
empty
),
"{}"
);
}
#[test]
...
...
src/libstd/collections/hash/set.rs
浏览文件 @
c2da923f
...
...
@@ -862,7 +862,7 @@ fn test_show() {
let
set_str
=
format!
(
"{}"
,
set
);
assert
!
(
set_str
==
"{1, 2}"
.to_string
()
||
set_str
==
"{2, 1}"
.to_string
()
);
assert_eq!
(
format!
(
"{}"
,
empty
),
"{}"
.to_string
()
);
assert
!
(
set_str
==
"{1, 2}"
||
set_str
==
"{2, 1}"
);
assert_eq!
(
format!
(
"{}"
,
empty
),
"{}"
);
}
}
src/libstd/collections/lru_cache.rs
浏览文件 @
c2da923f
...
...
@@ -446,15 +446,15 @@ fn test_to_string() {
cache
.insert
(
1
,
10
);
cache
.insert
(
2
,
20
);
cache
.insert
(
3
,
30
);
assert_eq!
(
cache
.to_string
(),
"{3: 30, 2: 20, 1: 10}"
.to_string
()
);
assert_eq!
(
cache
.to_string
(),
"{3: 30, 2: 20, 1: 10}"
);
cache
.insert
(
2
,
22
);
assert_eq!
(
cache
.to_string
(),
"{2: 22, 3: 30, 1: 10}"
.to_string
()
);
assert_eq!
(
cache
.to_string
(),
"{2: 22, 3: 30, 1: 10}"
);
cache
.insert
(
6
,
60
);
assert_eq!
(
cache
.to_string
(),
"{6: 60, 2: 22, 3: 30}"
.to_string
()
);
assert_eq!
(
cache
.to_string
(),
"{6: 60, 2: 22, 3: 30}"
);
cache
.get
(
&
3
);
assert_eq!
(
cache
.to_string
(),
"{3: 30, 6: 60, 2: 22}"
.to_string
()
);
assert_eq!
(
cache
.to_string
(),
"{3: 30, 6: 60, 2: 22}"
);
cache
.set_capacity
(
2
);
assert_eq!
(
cache
.to_string
(),
"{3: 30, 6: 60}"
.to_string
()
);
assert_eq!
(
cache
.to_string
(),
"{3: 30, 6: 60}"
);
}
#[test]
...
...
@@ -465,6 +465,6 @@ fn test_clear() {
cache
.clear
();
assert
!
(
cache
.get
(
&
1
)
.is_none
());
assert
!
(
cache
.get
(
&
2
)
.is_none
());
assert_eq!
(
cache
.to_string
(),
"{}"
.to_string
()
);
assert_eq!
(
cache
.to_string
(),
"{}"
);
}
}
src/libstd/io/mem.rs
浏览文件 @
c2da923f
...
...
@@ -592,7 +592,7 @@ fn test_write_strings() {
writer
.write_line
(
"testing"
)
.unwrap
();
writer
.write_str
(
"testing"
)
.unwrap
();
let
mut
r
=
BufReader
::
new
(
writer
.get_ref
());
assert_eq!
(
r
.read_to_string
()
.unwrap
(),
"testingtesting
\n
testing"
.to_string
()
);
assert_eq!
(
r
.read_to_string
()
.unwrap
(),
"testingtesting
\n
testing"
);
}
#[test]
...
...
@@ -602,7 +602,7 @@ fn test_write_char() {
writer
.write_char
(
'\n'
)
.unwrap
();
writer
.write_char
(
'ệ'
)
.unwrap
();
let
mut
r
=
BufReader
::
new
(
writer
.get_ref
());
assert_eq!
(
r
.read_to_string
()
.unwrap
(),
"a
\n
ệ"
.to_string
()
);
assert_eq!
(
r
.read_to_string
()
.unwrap
(),
"a
\n
ệ"
);
}
#[test]
...
...
src/libstd/io/mod.rs
浏览文件 @
c2da923f
...
...
@@ -2005,14 +2005,14 @@ fn test_push_at_least() {
fn
test_show
()
{
use
super
::
*
;
assert_eq!
(
format!
(
"{}"
,
USER_READ
),
"0400"
.to_string
()
);
assert_eq!
(
format!
(
"{}"
,
USER_FILE
),
"0644"
.to_string
()
);
assert_eq!
(
format!
(
"{}"
,
USER_EXEC
),
"0755"
.to_string
()
);
assert_eq!
(
format!
(
"{}"
,
USER_RWX
),
"0700"
.to_string
()
);
assert_eq!
(
format!
(
"{}"
,
GROUP_RWX
),
"0070"
.to_string
()
);
assert_eq!
(
format!
(
"{}"
,
OTHER_RWX
),
"0007"
.to_string
()
);
assert_eq!
(
format!
(
"{}"
,
ALL_PERMISSIONS
),
"0777"
.to_string
()
);
assert_eq!
(
format!
(
"{}"
,
USER_READ
|
USER_WRITE
|
OTHER_WRITE
),
"0602"
.to_string
()
);
assert_eq!
(
format!
(
"{}"
,
USER_READ
),
"0400"
);
assert_eq!
(
format!
(
"{}"
,
USER_FILE
),
"0644"
);
assert_eq!
(
format!
(
"{}"
,
USER_EXEC
),
"0755"
);
assert_eq!
(
format!
(
"{}"
,
USER_RWX
),
"0700"
);
assert_eq!
(
format!
(
"{}"
,
GROUP_RWX
),
"0070"
);
assert_eq!
(
format!
(
"{}"
,
OTHER_RWX
),
"0007"
);
assert_eq!
(
format!
(
"{}"
,
ALL_PERMISSIONS
),
"0777"
);
assert_eq!
(
format!
(
"{}"
,
USER_READ
|
USER_WRITE
|
OTHER_WRITE
),
"0602"
);
}
fn
_
ensure_buffer_is_object_safe
<
T
:
Buffer
>
(
x
:
&
T
)
->
&
Buffer
{
...
...
src/libstd/io/net/ip.rs
浏览文件 @
c2da923f
...
...
@@ -640,10 +640,10 @@ fn test_from_str_socket_addr() {
#[test]
fn
ipv6_addr_to_string
()
{
let
a1
=
Ipv6Addr
(
0
,
0
,
0
,
0
,
0
,
0xffff
,
0xc000
,
0x280
);
assert
!
(
a1
.to_string
()
==
"::ffff:192.0.2.128"
.to_string
()
||
a1
.to_string
()
==
"::FFFF:192.0.2.128"
.to_string
()
);
assert
!
(
a1
.to_string
()
==
"::ffff:192.0.2.128"
||
a1
.to_string
()
==
"::FFFF:192.0.2.128"
);
assert_eq!
(
Ipv6Addr
(
8
,
9
,
10
,
11
,
12
,
13
,
14
,
15
)
.to_string
(),
"8:9:a:b:c:d:e:f"
.to_string
()
);
"8:9:a:b:c:d:e:f"
);
}
#[test]
...
...
src/libstd/io/process.rs
浏览文件 @
c2da923f
...
...
@@ -810,7 +810,7 @@ pub fn run_output(cmd: Command) -> String {
fn
stdout_works
()
{
let
mut
cmd
=
Command
::
new
(
"echo"
);
cmd
.arg
(
"foobar"
)
.stdout
(
CreatePipe
(
false
,
true
));
assert_eq!
(
run_output
(
cmd
),
"foobar
\n
"
.to_string
()
);
assert_eq!
(
run_output
(
cmd
),
"foobar
\n
"
);
}
#[cfg(all(unix,
not(target_os=
"android"
)))]
...
...
@@ -820,7 +820,7 @@ fn set_cwd_works() {
cmd
.arg
(
"-c"
)
.arg
(
"pwd"
)
.cwd
(
&
Path
::
new
(
"/"
))
.stdout
(
CreatePipe
(
false
,
true
));
assert_eq!
(
run_output
(
cmd
),
"/
\n
"
.to_string
()
);
assert_eq!
(
run_output
(
cmd
),
"/
\n
"
);
}
#[cfg(all(unix,
not(target_os=
"android"
)))]
...
...
@@ -835,7 +835,7 @@ fn stdin_works() {
drop
(
p
.stdin
.take
());
let
out
=
read_all
(
p
.stdout
.as_mut
()
.unwrap
()
as
&
mut
Reader
);
assert
!
(
p
.wait
()
.unwrap
()
.success
());
assert_eq!
(
out
,
"foobar
\n
"
.to_string
()
);
assert_eq!
(
out
,
"foobar
\n
"
);
}
#[cfg(not(target_os=
"android"
))]
...
...
@@ -900,7 +900,7 @@ fn test_process_output_output() {
let
output_str
=
str
::
from_utf8
(
output
.as_slice
())
.unwrap
();
assert
!
(
status
.success
());
assert_eq!
(
output_str
.trim
()
.to_string
(),
"hello"
.to_string
()
);
assert_eq!
(
output_str
.trim
()
.to_string
(),
"hello"
);
// FIXME #7224
if
!
running_on_valgrind
()
{
assert_eq!
(
error
,
Vec
::
new
());
...
...
@@ -941,7 +941,7 @@ fn test_wait_with_output_once() {
let
output_str
=
str
::
from_utf8
(
output
.as_slice
())
.unwrap
();
assert
!
(
status
.success
());
assert_eq!
(
output_str
.trim
()
.to_string
(),
"hello"
.to_string
()
);
assert_eq!
(
output_str
.trim
()
.to_string
(),
"hello"
);
// FIXME #7224
if
!
running_on_valgrind
()
{
assert_eq!
(
error
,
Vec
::
new
());
...
...
src/libstd/io/stdio.rs
浏览文件 @
c2da923f
...
...
@@ -527,7 +527,7 @@ fn capture_stdout() {
set_stdout
(
box
w
);
println!
(
"hello!"
);
});
assert_eq!
(
r
.read_to_string
()
.unwrap
(),
"hello!
\n
"
.to_string
()
);
assert_eq!
(
r
.read_to_string
()
.unwrap
(),
"hello!
\n
"
);
}
#[test]
...
...
src/libstd/num/strconv.rs
浏览文件 @
c2da923f
...
...
@@ -428,28 +428,28 @@ mod tests {
#[test]
fn
test_int_to_str_overflow
()
{
let
mut
i8_val
:
i8
=
127_i8
;
assert_eq!
(
i8_val
.to_string
(),
"127"
.to_string
()
);
assert_eq!
(
i8_val
.to_string
(),
"127"
);
i8_val
+=
1
as
i8
;
assert_eq!
(
i8_val
.to_string
(),
"-128"
.to_string
()
);
assert_eq!
(
i8_val
.to_string
(),
"-128"
);
let
mut
i16_val
:
i16
=
32_767_i16
;
assert_eq!
(
i16_val
.to_string
(),
"32767"
.to_string
()
);
assert_eq!
(
i16_val
.to_string
(),
"32767"
);
i16_val
+=
1
as
i16
;
assert_eq!
(
i16_val
.to_string
(),
"-32768"
.to_string
()
);
assert_eq!
(
i16_val
.to_string
(),
"-32768"
);
let
mut
i32_val
:
i32
=
2_147_483_647_i32
;
assert_eq!
(
i32_val
.to_string
(),
"2147483647"
.to_string
()
);
assert_eq!
(
i32_val
.to_string
(),
"2147483647"
);
i32_val
+=
1
as
i32
;
assert_eq!
(
i32_val
.to_string
(),
"-2147483648"
.to_string
()
);
assert_eq!
(
i32_val
.to_string
(),
"-2147483648"
);
let
mut
i64_val
:
i64
=
9_223_372_036_854_775_807_i64
;
assert_eq!
(
i64_val
.to_string
(),
"9223372036854775807"
.to_string
()
);
assert_eq!
(
i64_val
.to_string
(),
"9223372036854775807"
);
i64_val
+=
1
as
i64
;
assert_eq!
(
i64_val
.to_string
(),
"-9223372036854775808"
.to_string
()
);
assert_eq!
(
i64_val
.to_string
(),
"-9223372036854775808"
);
}
}
...
...
src/libstd/num/uint_macros.rs
浏览文件 @
c2da923f
...
...
@@ -79,28 +79,28 @@ pub fn test_parse_bytes() {
#[test]
fn
test_uint_to_str_overflow
()
{
let
mut
u8_val
:
u8
=
255_u8
;
assert_eq!
(
u8_val
.to_string
(),
"255"
.to_string
()
);
assert_eq!
(
u8_val
.to_string
(),
"255"
);
u8_val
+=
1
as
u8
;
assert_eq!
(
u8_val
.to_string
(),
"0"
.to_string
()
);
assert_eq!
(
u8_val
.to_string
(),
"0"
);
let
mut
u16_val
:
u16
=
65_535_u16
;
assert_eq!
(
u16_val
.to_string
(),
"65535"
.to_string
()
);
assert_eq!
(
u16_val
.to_string
(),
"65535"
);
u16_val
+=
1
as
u16
;
assert_eq!
(
u16_val
.to_string
(),
"0"
.to_string
()
);
assert_eq!
(
u16_val
.to_string
(),
"0"
);
let
mut
u32_val
:
u32
=
4_294_967_295_u32
;
assert_eq!
(
u32_val
.to_string
(),
"4294967295"
.to_string
()
);
assert_eq!
(
u32_val
.to_string
(),
"4294967295"
);
u32_val
+=
1
as
u32
;
assert_eq!
(
u32_val
.to_string
(),
"0"
.to_string
()
);
assert_eq!
(
u32_val
.to_string
(),
"0"
);
let
mut
u64_val
:
u64
=
18_446_744_073_709_551_615_u64
;
assert_eq!
(
u64_val
.to_string
(),
"18446744073709551615"
.to_string
()
);
assert_eq!
(
u64_val
.to_string
(),
"18446744073709551615"
);
u64_val
+=
1
as
u64
;
assert_eq!
(
u64_val
.to_string
(),
"0"
.to_string
()
);
assert_eq!
(
u64_val
.to_string
(),
"0"
);
}
#[test]
...
...
src/libstd/path/windows.rs
浏览文件 @
c2da923f
...
...
@@ -1321,9 +1321,9 @@ fn test_not_utf8_panics() {
#[test]
fn
test_display_str
()
{
let
path
=
Path
::
new
(
"foo"
);
assert_eq!
(
path
.display
()
.to_string
(),
"foo"
.to_string
()
);
assert_eq!
(
path
.display
()
.to_string
(),
"foo"
);
let
path
=
Path
::
new
(
b
"
\\
"
);
assert_eq!
(
path
.filename_display
()
.to_string
(),
""
.to_string
()
);
assert_eq!
(
path
.filename_display
()
.to_string
(),
""
);
let
path
=
Path
::
new
(
"foo"
);
let
mo
=
path
.display
()
.as_cow
();
...
...
src/libstd/rt/backtrace.rs
浏览文件 @
c2da923f
...
...
@@ -1012,7 +1012,7 @@ mod test {
macro_rules!
t
(
(
$a:expr
,
$b:expr
)
=>
({
let
mut
m
=
Vec
::
new
();
super
::
demangle
(
&
mut
m
,
$a
)
.unwrap
();
assert_eq!
(
String
::
from_utf8
(
m
)
.unwrap
(),
$b
.to_string
()
);
assert_eq!
(
String
::
from_utf8
(
m
)
.unwrap
(),
$b
);
})
)
#[test]
...
...
src/libstd/sync/future.rs
浏览文件 @
c2da923f
...
...
@@ -153,7 +153,7 @@ mod test {
#[test]
fn
test_from_value
()
{
let
mut
f
=
Future
::
from_value
(
"snail"
.to_string
());
assert_eq!
(
f
.get
(),
"snail"
.to_string
()
);
assert_eq!
(
f
.get
(),
"snail"
);
}
#[test]
...
...
@@ -161,25 +161,25 @@ fn test_from_receiver() {
let
(
tx
,
rx
)
=
channel
();
tx
.send
(
"whale"
.to_string
());
let
mut
f
=
Future
::
from_receiver
(
rx
);
assert_eq!
(
f
.get
(),
"whale"
.to_string
()
);
assert_eq!
(
f
.get
(),
"whale"
);
}
#[test]
fn
test_from_fn
()
{
let
mut
f
=
Future
::
from_fn
(
proc
()
"brail"
.to_string
());
assert_eq!
(
f
.get
(),
"brail"
.to_string
()
);
assert_eq!
(
f
.get
(),
"brail"
);
}
#[test]
fn
test_interface_get
()
{
let
mut
f
=
Future
::
from_value
(
"fail"
.to_string
());
assert_eq!
(
f
.get
(),
"fail"
.to_string
()
);
assert_eq!
(
f
.get
(),
"fail"
);
}
#[test]
fn
test_interface_unwrap
()
{
let
f
=
Future
::
from_value
(
"fail"
.to_string
());
assert_eq!
(
f
.unwrap
(),
"fail"
.to_string
()
);
assert_eq!
(
f
.unwrap
(),
"fail"
);
}
#[test]
...
...
@@ -191,7 +191,7 @@ fn test_get_ref_method() {
#[test]
fn
test_spawn
()
{
let
mut
f
=
Future
::
spawn
(
proc
()
"bale"
.to_string
());
assert_eq!
(
f
.get
(),
"bale"
.to_string
()
);
assert_eq!
(
f
.get
(),
"bale"
);
}
#[test]
...
...
src/libstd/sys/windows/process.rs
浏览文件 @
c2da923f
...
...
@@ -484,24 +484,24 @@ fn test_wrapper(prog: &str, args: &[&str]) -> String {
assert_eq!
(
test_wrapper
(
"prog"
,
&
[
"aaa"
,
"bbb"
,
"ccc"
]),
"prog aaa bbb ccc"
.to_string
()
"prog aaa bbb ccc"
);
assert_eq!
(
test_wrapper
(
"C:
\\
Program Files
\\
blah
\\
blah.exe"
,
&
[
"aaa"
]),
"
\"
C:
\\
Program Files
\\
blah
\\
blah.exe
\"
aaa"
.to_string
()
"
\"
C:
\\
Program Files
\\
blah
\\
blah.exe
\"
aaa"
);
assert_eq!
(
test_wrapper
(
"C:
\\
Program Files
\\
test"
,
&
[
"aa
\"
bb"
]),
"
\"
C:
\\
Program Files
\\
test
\"
aa
\\\"
bb"
.to_string
()
"
\"
C:
\\
Program Files
\\
test
\"
aa
\\\"
bb"
);
assert_eq!
(
test_wrapper
(
"echo"
,
&
[
"a b c"
]),
"echo
\"
a b c
\"
"
.to_string
()
"echo
\"
a b c
\"
"
);
assert_eq!
(
test_wrapper
(
"
\u03c0\u042f\u97f3\u00e6\u221e
"
,
&
[]),
"
\u03c0\u042f\u97f3\u00e6\u221e
"
.to_string
()
"
\u03c0\u042f\u97f3\u00e6\u221e
"
);
}
}
src/libstd/task.rs
浏览文件 @
c2da923f
...
...
@@ -287,21 +287,21 @@ fn test_unnamed_task() {
#[test]
fn
test_owned_named_task
()
{
TaskBuilder
::
new
()
.named
(
"ada lovelace"
.to_string
())
.try
(
proc
()
{
assert
!
(
name
()
.unwrap
()
==
"ada lovelace"
.to_string
()
);
assert
!
(
name
()
.unwrap
()
==
"ada lovelace"
);
})
.map_err
(|
_
|
())
.unwrap
();
}
#[test]
fn
test_static_named_task
()
{
TaskBuilder
::
new
()
.named
(
"ada lovelace"
)
.try
(
proc
()
{
assert
!
(
name
()
.unwrap
()
==
"ada lovelace"
.to_string
()
);
assert
!
(
name
()
.unwrap
()
==
"ada lovelace"
);
})
.map_err
(|
_
|
())
.unwrap
();
}
#[test]
fn
test_send_named_task
()
{
TaskBuilder
::
new
()
.named
(
"ada lovelace"
.into_cow
())
.try
(
proc
()
{
assert
!
(
name
()
.unwrap
()
==
"ada lovelace"
.to_string
()
);
assert
!
(
name
()
.unwrap
()
==
"ada lovelace"
);
})
.map_err
(|
_
|
())
.unwrap
();
}
...
...
@@ -462,7 +462,7 @@ fn test_try_panic_message_owned_str() {
Err
(
e
)
=>
{
type
T
=
String
;
assert
!
(
e
.is
::
<
T
>
());
assert_eq!
(
*
e
.downcast
::
<
T
>
()
.unwrap
(),
"owned string"
.to_string
()
);
assert_eq!
(
*
e
.downcast
::
<
T
>
()
.unwrap
(),
"owned string"
);
}
Ok
(())
=>
panic!
()
}
...
...
@@ -509,7 +509,7 @@ fn test_stdout() {
assert
!
(
r
.is_ok
());
let
output
=
reader
.read_to_string
()
.unwrap
();
assert_eq!
(
output
,
"Hello, world!"
.to_string
()
);
assert_eq!
(
output
,
"Hello, world!"
);
}
// NOTE: the corresponding test for stderr is in run-pass/task-stderr, due
...
...
src/libstd/time/duration.rs
浏览文件 @
c2da923f
...
...
@@ -538,20 +538,20 @@ fn test_duration_div() {
#[test]
fn
test_duration_fmt
()
{
assert_eq!
(
Duration
::
zero
()
.to_string
(),
"PT0S"
.to_string
()
);
assert_eq!
(
Duration
::
days
(
42
)
.to_string
(),
"P42D"
.to_string
()
);
assert_eq!
(
Duration
::
days
(
-
42
)
.to_string
(),
"-P42D"
.to_string
()
);
assert_eq!
(
Duration
::
seconds
(
42
)
.to_string
(),
"PT42S"
.to_string
()
);
assert_eq!
(
Duration
::
milliseconds
(
42
)
.to_string
(),
"PT0.042S"
.to_string
()
);
assert_eq!
(
Duration
::
microseconds
(
42
)
.to_string
(),
"PT0.000042S"
.to_string
()
);
assert_eq!
(
Duration
::
nanoseconds
(
42
)
.to_string
(),
"PT0.000000042S"
.to_string
()
);
assert_eq!
(
Duration
::
zero
()
.to_string
(),
"PT0S"
);
assert_eq!
(
Duration
::
days
(
42
)
.to_string
(),
"P42D"
);
assert_eq!
(
Duration
::
days
(
-
42
)
.to_string
(),
"-P42D"
);
assert_eq!
(
Duration
::
seconds
(
42
)
.to_string
(),
"PT42S"
);
assert_eq!
(
Duration
::
milliseconds
(
42
)
.to_string
(),
"PT0.042S"
);
assert_eq!
(
Duration
::
microseconds
(
42
)
.to_string
(),
"PT0.000042S"
);
assert_eq!
(
Duration
::
nanoseconds
(
42
)
.to_string
(),
"PT0.000000042S"
);
assert_eq!
((
Duration
::
days
(
7
)
+
Duration
::
milliseconds
(
6543
))
.to_string
(),
"P7DT6.543S"
.to_string
()
);
assert_eq!
(
Duration
::
seconds
(
-
86401
)
.to_string
(),
"-P1DT1S"
.to_string
()
);
assert_eq!
(
Duration
::
nanoseconds
(
-
1
)
.to_string
(),
"-PT0.000000001S"
.to_string
()
);
"P7DT6.543S"
);
assert_eq!
(
Duration
::
seconds
(
-
86401
)
.to_string
(),
"-P1DT1S"
);
assert_eq!
(
Duration
::
nanoseconds
(
-
1
)
.to_string
(),
"-PT0.000000001S"
);
// the format specifier should have no effect on `Duration`
assert_eq!
(
format!
(
"{:30}"
,
Duration
::
days
(
1
)
+
Duration
::
milliseconds
(
2345
)),
"P1DT2.345S"
.to_string
()
);
"P1DT2.345S"
);
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录