Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
8379d722
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,发现更多精彩内容 >>
提交
8379d722
编写于
11月 27, 2014
作者:
J
Jorge Aparicio
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
libgetopts: remove unnecessary `to_string()` calls
上级
98ae6375
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
39 addition
and
39 deletion
+39
-39
src/libgetopts/lib.rs
src/libgetopts/lib.rs
+39
-39
未找到文件。
src/libgetopts/lib.rs
浏览文件 @
8379d722
...
...
@@ -962,9 +962,9 @@ fn test_reqopt() {
match
rs
{
Ok
(
ref
m
)
=>
{
assert
!
(
m
.opt_present
(
"test"
));
assert_eq!
(
m
.opt_str
(
"test"
)
.unwrap
(),
"20"
.to_string
()
);
assert_eq!
(
m
.opt_str
(
"test"
)
.unwrap
(),
"20"
);
assert
!
(
m
.opt_present
(
"t"
));
assert_eq!
(
m
.opt_str
(
"t"
)
.unwrap
(),
"20"
.to_string
()
);
assert_eq!
(
m
.opt_str
(
"t"
)
.unwrap
(),
"20"
);
}
_
=>
{
panic!
(
"test_reqopt failed (long arg)"
);
}
}
...
...
@@ -972,9 +972,9 @@ fn test_reqopt() {
match
getopts
(
short_args
.as_slice
(),
opts
.as_slice
())
{
Ok
(
ref
m
)
=>
{
assert
!
((
m
.opt_present
(
"test"
)));
assert_eq!
(
m
.opt_str
(
"test"
)
.unwrap
(),
"20"
.to_string
()
);
assert_eq!
(
m
.opt_str
(
"test"
)
.unwrap
(),
"20"
);
assert
!
((
m
.opt_present
(
"t"
)));
assert_eq!
(
m
.opt_str
(
"t"
)
.unwrap
(),
"20"
.to_string
()
);
assert_eq!
(
m
.opt_str
(
"t"
)
.unwrap
(),
"20"
);
}
_
=>
{
panic!
(
"test_reqopt failed (short arg)"
);
}
}
...
...
@@ -1027,9 +1027,9 @@ fn test_optopt() {
match
rs
{
Ok
(
ref
m
)
=>
{
assert
!
(
m
.opt_present
(
"test"
));
assert_eq!
(
m
.opt_str
(
"test"
)
.unwrap
(),
"20"
.to_string
()
);
assert_eq!
(
m
.opt_str
(
"test"
)
.unwrap
(),
"20"
);
assert
!
((
m
.opt_present
(
"t"
)));
assert_eq!
(
m
.opt_str
(
"t"
)
.unwrap
(),
"20"
.to_string
()
);
assert_eq!
(
m
.opt_str
(
"t"
)
.unwrap
(),
"20"
);
}
_
=>
panic!
()
}
...
...
@@ -1037,9 +1037,9 @@ fn test_optopt() {
match
getopts
(
short_args
.as_slice
(),
opts
.as_slice
())
{
Ok
(
ref
m
)
=>
{
assert
!
((
m
.opt_present
(
"test"
)));
assert_eq!
(
m
.opt_str
(
"test"
)
.unwrap
(),
"20"
.to_string
()
);
assert_eq!
(
m
.opt_str
(
"test"
)
.unwrap
(),
"20"
);
assert
!
((
m
.opt_present
(
"t"
)));
assert_eq!
(
m
.opt_str
(
"t"
)
.unwrap
(),
"20"
.to_string
()
);
assert_eq!
(
m
.opt_str
(
"t"
)
.unwrap
(),
"20"
);
}
_
=>
panic!
()
}
...
...
@@ -1154,7 +1154,7 @@ fn test_optflag_short_arg() {
Ok
(
ref
m
)
=>
{
// The next variable after the flag is just a free argument
assert
!
(
m
.free
[
0
]
==
"20"
.to_string
()
);
assert
!
(
m
.free
[
0
]
==
"20"
);
}
_
=>
panic!
()
}
...
...
@@ -1250,9 +1250,9 @@ fn test_optmulti() {
match
rs
{
Ok
(
ref
m
)
=>
{
assert
!
((
m
.opt_present
(
"test"
)));
assert_eq!
(
m
.opt_str
(
"test"
)
.unwrap
(),
"20"
.to_string
()
);
assert_eq!
(
m
.opt_str
(
"test"
)
.unwrap
(),
"20"
);
assert
!
((
m
.opt_present
(
"t"
)));
assert_eq!
(
m
.opt_str
(
"t"
)
.unwrap
(),
"20"
.to_string
()
);
assert_eq!
(
m
.opt_str
(
"t"
)
.unwrap
(),
"20"
);
}
_
=>
panic!
()
}
...
...
@@ -1260,9 +1260,9 @@ fn test_optmulti() {
match
getopts
(
short_args
.as_slice
(),
opts
.as_slice
())
{
Ok
(
ref
m
)
=>
{
assert
!
((
m
.opt_present
(
"test"
)));
assert_eq!
(
m
.opt_str
(
"test"
)
.unwrap
(),
"20"
.to_string
()
);
assert_eq!
(
m
.opt_str
(
"test"
)
.unwrap
(),
"20"
);
assert
!
((
m
.opt_present
(
"t"
)));
assert_eq!
(
m
.opt_str
(
"t"
)
.unwrap
(),
"20"
.to_string
()
);
assert_eq!
(
m
.opt_str
(
"t"
)
.unwrap
(),
"20"
);
}
_
=>
panic!
()
}
...
...
@@ -1306,12 +1306,12 @@ fn test_optmulti_multi() {
match
rs
{
Ok
(
ref
m
)
=>
{
assert
!
(
m
.opt_present
(
"test"
));
assert_eq!
(
m
.opt_str
(
"test"
)
.unwrap
(),
"20"
.to_string
()
);
assert_eq!
(
m
.opt_str
(
"test"
)
.unwrap
(),
"20"
);
assert
!
(
m
.opt_present
(
"t"
));
assert_eq!
(
m
.opt_str
(
"t"
)
.unwrap
(),
"20"
.to_string
()
);
assert_eq!
(
m
.opt_str
(
"t"
)
.unwrap
(),
"20"
);
let
pair
=
m
.opt_strs
(
"test"
);
assert
!
(
pair
[
0
]
==
"20"
.to_string
()
);
assert
!
(
pair
[
1
]
==
"30"
.to_string
()
);
assert
!
(
pair
[
0
]
==
"20"
);
assert
!
(
pair
[
1
]
==
"30"
);
}
_
=>
panic!
()
}
...
...
@@ -1363,19 +1363,19 @@ fn test_combined() {
let
rs
=
getopts
(
args
.as_slice
(),
opts
.as_slice
());
match
rs
{
Ok
(
ref
m
)
=>
{
assert
!
(
m
.free
[
0
]
==
"prog"
.to_string
()
);
assert
!
(
m
.free
[
1
]
==
"free1"
.to_string
()
);
assert_eq!
(
m
.opt_str
(
"s"
)
.unwrap
(),
"20"
.to_string
()
);
assert
!
(
m
.free
[
2
]
==
"free2"
.to_string
()
);
assert
!
(
m
.free
[
0
]
==
"prog"
);
assert
!
(
m
.free
[
1
]
==
"free1"
);
assert_eq!
(
m
.opt_str
(
"s"
)
.unwrap
(),
"20"
);
assert
!
(
m
.free
[
2
]
==
"free2"
);
assert
!
((
m
.opt_present
(
"flag"
)));
assert_eq!
(
m
.opt_str
(
"long"
)
.unwrap
(),
"30"
.to_string
()
);
assert_eq!
(
m
.opt_str
(
"long"
)
.unwrap
(),
"30"
);
assert
!
((
m
.opt_present
(
"f"
)));
let
pair
=
m
.opt_strs
(
"m"
);
assert
!
(
pair
[
0
]
==
"40"
.to_string
()
);
assert
!
(
pair
[
1
]
==
"50"
.to_string
()
);
assert
!
(
pair
[
0
]
==
"40"
);
assert
!
(
pair
[
1
]
==
"50"
);
let
pair
=
m
.opt_strs
(
"n"
);
assert
!
(
pair
[
0
]
==
"-A B"
.to_string
()
);
assert
!
(
pair
[
1
]
==
"-60 70"
.to_string
()
);
assert
!
(
pair
[
0
]
==
"-A B"
);
assert
!
(
pair
[
1
]
==
"-60 70"
);
assert
!
((
!
m
.opt_present
(
"notpresent"
)));
}
_
=>
panic!
()
...
...
@@ -1401,11 +1401,11 @@ fn test_multi() {
assert
!
(
!
matches_single
.opts_present
(
&
[
"thing"
.to_string
()]));
assert
!
(
!
matches_single
.opts_present
(
&
[]));
assert_eq!
(
matches_single
.opts_str
(
&
[
"e"
.to_string
()])
.unwrap
(),
"foo"
.to_string
()
);
assert_eq!
(
matches_single
.opts_str
(
&
[
"e"
.to_string
()])
.unwrap
(),
"foo"
);
assert_eq!
(
matches_single
.opts_str
(
&
[
"e"
.to_string
(),
"encrypt"
.to_string
()])
.unwrap
(),
"foo"
.to_string
()
);
"foo"
);
assert_eq!
(
matches_single
.opts_str
(
&
[
"encrypt"
.to_string
(),
"e"
.to_string
()])
.unwrap
(),
"foo"
.to_string
()
);
"foo"
);
let
args_both
=
vec!
(
"-e"
.to_string
(),
"foo"
.to_string
(),
"--encrypt"
.to_string
(),
"foo"
.to_string
());
...
...
@@ -1422,12 +1422,12 @@ fn test_multi() {
assert
!
(
!
matches_both
.opts_present
(
&
[
"thing"
.to_string
()]));
assert
!
(
!
matches_both
.opts_present
(
&
[]));
assert_eq!
(
matches_both
.opts_str
(
&
[
"e"
.to_string
()])
.unwrap
(),
"foo"
.to_string
()
);
assert_eq!
(
matches_both
.opts_str
(
&
[
"encrypt"
.to_string
()])
.unwrap
(),
"foo"
.to_string
()
);
assert_eq!
(
matches_both
.opts_str
(
&
[
"e"
.to_string
()])
.unwrap
(),
"foo"
);
assert_eq!
(
matches_both
.opts_str
(
&
[
"encrypt"
.to_string
()])
.unwrap
(),
"foo"
);
assert_eq!
(
matches_both
.opts_str
(
&
[
"e"
.to_string
(),
"encrypt"
.to_string
()])
.unwrap
(),
"foo"
.to_string
()
);
"foo"
);
assert_eq!
(
matches_both
.opts_str
(
&
[
"encrypt"
.to_string
(),
"e"
.to_string
()])
.unwrap
(),
"foo"
.to_string
()
);
"foo"
);
}
#[test]
...
...
@@ -1440,9 +1440,9 @@ fn test_nospace() {
result
::
Err
(
_
)
=>
panic!
()
};
assert
!
(
matches
.opts_present
(
&
[
"L"
.to_string
()]));
assert_eq!
(
matches
.opts_str
(
&
[
"L"
.to_string
()])
.unwrap
(),
"foo"
.to_string
()
);
assert_eq!
(
matches
.opts_str
(
&
[
"L"
.to_string
()])
.unwrap
(),
"foo"
);
assert
!
(
matches
.opts_present
(
&
[
"M"
.to_string
()]));
assert_eq!
(
matches
.opts_str
(
&
[
"M"
.to_string
()])
.unwrap
(),
"."
.to_string
()
);
assert_eq!
(
matches
.opts_str
(
&
[
"M"
.to_string
()])
.unwrap
(),
"."
);
}
...
...
@@ -1456,7 +1456,7 @@ fn test_nospace_conflict() {
result
::
Err
(
e
)
=>
panic!
(
"{}"
,
e
)
};
assert
!
(
matches
.opts_present
(
&
[
"L"
.to_string
()]));
assert_eq!
(
matches
.opts_str
(
&
[
"L"
.to_string
()])
.unwrap
(),
"verbose"
.to_string
()
);
assert_eq!
(
matches
.opts_str
(
&
[
"L"
.to_string
()])
.unwrap
(),
"verbose"
);
assert
!
(
matches
.opts_present
(
&
[
"v"
.to_string
()]));
assert_eq!
(
3
,
matches
.opt_count
(
"v"
));
}
...
...
@@ -1510,7 +1510,7 @@ fn test_usage() {
-k --kiwi Desc
-p [VAL] Desc
-l VAL Desc
"
.to_string
()
;
"
;
let
generated_usage
=
usage
(
"Usage: fruits"
,
optgroups
.as_slice
());
...
...
@@ -1537,7 +1537,7 @@ fn test_usage_description_wrapping() {
-k --kiwi This is a long description which won't be wrapped..+..
-a --apple This is a long description which _will_ be
wrapped..+..
"
.to_string
()
;
"
;
let
usage
=
usage
(
"Usage: fruits"
,
optgroups
.as_slice
());
...
...
@@ -1563,7 +1563,7 @@ fn test_usage_description_multibyte_handling() {
-a --apple This “description” has some characters that could
confuse the line wrapping; an apple costs 0.51€ in
some parts of Europe.
"
.to_string
()
;
"
;
let
usage
=
usage
(
"Usage: fruits"
,
optgroups
.as_slice
());
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录