Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
2ed42bfb
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,发现更多精彩内容 >>
提交
2ed42bfb
编写于
11月 27, 2014
作者:
J
Jorge Aparicio
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
libtime: remove unnecessary `to_string()` calls
上级
66f52f4c
变更
1
显示空白变更内容
内联
并排
Showing
1 changed file
with
58 addition
and
58 deletion
+58
-58
src/libtime/lib.rs
src/libtime/lib.rs
+58
-58
未找到文件。
src/libtime/lib.rs
浏览文件 @
2ed42bfb
...
@@ -1564,8 +1564,8 @@ fn test_asctime() {
...
@@ -1564,8 +1564,8 @@ fn test_asctime() {
debug!
(
"test_ctime: {} {}"
,
utc
.asctime
(),
local
.asctime
());
debug!
(
"test_ctime: {} {}"
,
utc
.asctime
(),
local
.asctime
());
assert_eq!
(
utc
.asctime
()
.to_string
(),
"Fri Feb 13 23:31:30 2009"
.to_string
()
);
assert_eq!
(
utc
.asctime
()
.to_string
(),
"Fri Feb 13 23:31:30 2009"
);
assert_eq!
(
local
.asctime
()
.to_string
(),
"Fri Feb 13 15:31:30 2009"
.to_string
()
);
assert_eq!
(
local
.asctime
()
.to_string
(),
"Fri Feb 13 15:31:30 2009"
);
}
}
fn
test_ctime
()
{
fn
test_ctime
()
{
...
@@ -1577,8 +1577,8 @@ fn test_ctime() {
...
@@ -1577,8 +1577,8 @@ fn test_ctime() {
debug!
(
"test_ctime: {} {}"
,
utc
.ctime
(),
local
.ctime
());
debug!
(
"test_ctime: {} {}"
,
utc
.ctime
(),
local
.ctime
());
assert_eq!
(
utc
.ctime
()
.to_string
(),
"Fri Feb 13 15:31:30 2009"
.to_string
()
);
assert_eq!
(
utc
.ctime
()
.to_string
(),
"Fri Feb 13 15:31:30 2009"
);
assert_eq!
(
local
.ctime
()
.to_string
(),
"Fri Feb 13 15:31:30 2009"
.to_string
()
);
assert_eq!
(
local
.ctime
()
.to_string
(),
"Fri Feb 13 15:31:30 2009"
);
}
}
fn
test_strftime
()
{
fn
test_strftime
()
{
...
@@ -1588,56 +1588,56 @@ fn test_strftime() {
...
@@ -1588,56 +1588,56 @@ fn test_strftime() {
let
utc
=
at_utc
(
time
);
let
utc
=
at_utc
(
time
);
let
local
=
at
(
time
);
let
local
=
at
(
time
);
assert_eq!
(
local
.strftime
(
""
)
.unwrap
()
.to_string
(),
""
.to_string
()
);
assert_eq!
(
local
.strftime
(
""
)
.unwrap
()
.to_string
(),
""
);
assert_eq!
(
local
.strftime
(
"%A"
)
.unwrap
()
.to_string
(),
"Friday"
.to_string
()
);
assert_eq!
(
local
.strftime
(
"%A"
)
.unwrap
()
.to_string
(),
"Friday"
);
assert_eq!
(
local
.strftime
(
"%a"
)
.unwrap
()
.to_string
(),
"Fri"
.to_string
()
);
assert_eq!
(
local
.strftime
(
"%a"
)
.unwrap
()
.to_string
(),
"Fri"
);
assert_eq!
(
local
.strftime
(
"%B"
)
.unwrap
()
.to_string
(),
"February"
.to_string
()
);
assert_eq!
(
local
.strftime
(
"%B"
)
.unwrap
()
.to_string
(),
"February"
);
assert_eq!
(
local
.strftime
(
"%b"
)
.unwrap
()
.to_string
(),
"Feb"
.to_string
()
);
assert_eq!
(
local
.strftime
(
"%b"
)
.unwrap
()
.to_string
(),
"Feb"
);
assert_eq!
(
local
.strftime
(
"%C"
)
.unwrap
()
.to_string
(),
"20"
.to_string
()
);
assert_eq!
(
local
.strftime
(
"%C"
)
.unwrap
()
.to_string
(),
"20"
);
assert_eq!
(
local
.strftime
(
"%c"
)
.unwrap
()
.to_string
(),
assert_eq!
(
local
.strftime
(
"%c"
)
.unwrap
()
.to_string
(),
"Fri Feb 13 15:31:30 2009"
.to_string
()
);
"Fri Feb 13 15:31:30 2009"
);
assert_eq!
(
local
.strftime
(
"%D"
)
.unwrap
()
.to_string
(),
"02/13/09"
.to_string
()
);
assert_eq!
(
local
.strftime
(
"%D"
)
.unwrap
()
.to_string
(),
"02/13/09"
);
assert_eq!
(
local
.strftime
(
"%d"
)
.unwrap
()
.to_string
(),
"13"
.to_string
()
);
assert_eq!
(
local
.strftime
(
"%d"
)
.unwrap
()
.to_string
(),
"13"
);
assert_eq!
(
local
.strftime
(
"%e"
)
.unwrap
()
.to_string
(),
"13"
.to_string
()
);
assert_eq!
(
local
.strftime
(
"%e"
)
.unwrap
()
.to_string
(),
"13"
);
assert_eq!
(
local
.strftime
(
"%F"
)
.unwrap
()
.to_string
(),
"2009-02-13"
.to_string
()
);
assert_eq!
(
local
.strftime
(
"%F"
)
.unwrap
()
.to_string
(),
"2009-02-13"
);
assert_eq!
(
local
.strftime
(
"%f"
)
.unwrap
()
.to_string
(),
"000054321"
.to_string
()
);
assert_eq!
(
local
.strftime
(
"%f"
)
.unwrap
()
.to_string
(),
"000054321"
);
assert_eq!
(
local
.strftime
(
"%G"
)
.unwrap
()
.to_string
(),
"2009"
.to_string
()
);
assert_eq!
(
local
.strftime
(
"%G"
)
.unwrap
()
.to_string
(),
"2009"
);
assert_eq!
(
local
.strftime
(
"%g"
)
.unwrap
()
.to_string
(),
"09"
.to_string
()
);
assert_eq!
(
local
.strftime
(
"%g"
)
.unwrap
()
.to_string
(),
"09"
);
assert_eq!
(
local
.strftime
(
"%H"
)
.unwrap
()
.to_string
(),
"15"
.to_string
()
);
assert_eq!
(
local
.strftime
(
"%H"
)
.unwrap
()
.to_string
(),
"15"
);
assert_eq!
(
local
.strftime
(
"%h"
)
.unwrap
()
.to_string
(),
"Feb"
.to_string
()
);
assert_eq!
(
local
.strftime
(
"%h"
)
.unwrap
()
.to_string
(),
"Feb"
);
assert_eq!
(
local
.strftime
(
"%I"
)
.unwrap
()
.to_string
(),
"03"
.to_string
()
);
assert_eq!
(
local
.strftime
(
"%I"
)
.unwrap
()
.to_string
(),
"03"
);
assert_eq!
(
local
.strftime
(
"%j"
)
.unwrap
()
.to_string
(),
"044"
.to_string
()
);
assert_eq!
(
local
.strftime
(
"%j"
)
.unwrap
()
.to_string
(),
"044"
);
assert_eq!
(
local
.strftime
(
"%k"
)
.unwrap
()
.to_string
(),
"15"
.to_string
()
);
assert_eq!
(
local
.strftime
(
"%k"
)
.unwrap
()
.to_string
(),
"15"
);
assert_eq!
(
local
.strftime
(
"%l"
)
.unwrap
()
.to_string
(),
" 3"
.to_string
()
);
assert_eq!
(
local
.strftime
(
"%l"
)
.unwrap
()
.to_string
(),
" 3"
);
assert_eq!
(
local
.strftime
(
"%M"
)
.unwrap
()
.to_string
(),
"31"
.to_string
()
);
assert_eq!
(
local
.strftime
(
"%M"
)
.unwrap
()
.to_string
(),
"31"
);
assert_eq!
(
local
.strftime
(
"%m"
)
.unwrap
()
.to_string
(),
"02"
.to_string
()
);
assert_eq!
(
local
.strftime
(
"%m"
)
.unwrap
()
.to_string
(),
"02"
);
assert_eq!
(
local
.strftime
(
"%n"
)
.unwrap
()
.to_string
(),
"
\n
"
.to_string
()
);
assert_eq!
(
local
.strftime
(
"%n"
)
.unwrap
()
.to_string
(),
"
\n
"
);
assert_eq!
(
local
.strftime
(
"%P"
)
.unwrap
()
.to_string
(),
"pm"
.to_string
()
);
assert_eq!
(
local
.strftime
(
"%P"
)
.unwrap
()
.to_string
(),
"pm"
);
assert_eq!
(
local
.strftime
(
"%p"
)
.unwrap
()
.to_string
(),
"PM"
.to_string
()
);
assert_eq!
(
local
.strftime
(
"%p"
)
.unwrap
()
.to_string
(),
"PM"
);
assert_eq!
(
local
.strftime
(
"%R"
)
.unwrap
()
.to_string
(),
"15:31"
.to_string
()
);
assert_eq!
(
local
.strftime
(
"%R"
)
.unwrap
()
.to_string
(),
"15:31"
);
assert_eq!
(
local
.strftime
(
"%r"
)
.unwrap
()
.to_string
(),
"03:31:30 PM"
.to_string
()
);
assert_eq!
(
local
.strftime
(
"%r"
)
.unwrap
()
.to_string
(),
"03:31:30 PM"
);
assert_eq!
(
local
.strftime
(
"%S"
)
.unwrap
()
.to_string
(),
"30"
.to_string
()
);
assert_eq!
(
local
.strftime
(
"%S"
)
.unwrap
()
.to_string
(),
"30"
);
assert_eq!
(
local
.strftime
(
"%s"
)
.unwrap
()
.to_string
(),
"1234567890"
.to_string
()
);
assert_eq!
(
local
.strftime
(
"%s"
)
.unwrap
()
.to_string
(),
"1234567890"
);
assert_eq!
(
local
.strftime
(
"%T"
)
.unwrap
()
.to_string
(),
"15:31:30"
.to_string
()
);
assert_eq!
(
local
.strftime
(
"%T"
)
.unwrap
()
.to_string
(),
"15:31:30"
);
assert_eq!
(
local
.strftime
(
"%t"
)
.unwrap
()
.to_string
(),
"
\t
"
.to_string
()
);
assert_eq!
(
local
.strftime
(
"%t"
)
.unwrap
()
.to_string
(),
"
\t
"
);
assert_eq!
(
local
.strftime
(
"%U"
)
.unwrap
()
.to_string
(),
"06"
.to_string
()
);
assert_eq!
(
local
.strftime
(
"%U"
)
.unwrap
()
.to_string
(),
"06"
);
assert_eq!
(
local
.strftime
(
"%u"
)
.unwrap
()
.to_string
(),
"5"
.to_string
()
);
assert_eq!
(
local
.strftime
(
"%u"
)
.unwrap
()
.to_string
(),
"5"
);
assert_eq!
(
local
.strftime
(
"%V"
)
.unwrap
()
.to_string
(),
"07"
.to_string
()
);
assert_eq!
(
local
.strftime
(
"%V"
)
.unwrap
()
.to_string
(),
"07"
);
assert_eq!
(
local
.strftime
(
"%v"
)
.unwrap
()
.to_string
(),
"13-Feb-2009"
.to_string
()
);
assert_eq!
(
local
.strftime
(
"%v"
)
.unwrap
()
.to_string
(),
"13-Feb-2009"
);
assert_eq!
(
local
.strftime
(
"%W"
)
.unwrap
()
.to_string
(),
"06"
.to_string
()
);
assert_eq!
(
local
.strftime
(
"%W"
)
.unwrap
()
.to_string
(),
"06"
);
assert_eq!
(
local
.strftime
(
"%w"
)
.unwrap
()
.to_string
(),
"5"
.to_string
()
);
assert_eq!
(
local
.strftime
(
"%w"
)
.unwrap
()
.to_string
(),
"5"
);
// FIXME (#2350): support locale
// FIXME (#2350): support locale
assert_eq!
(
local
.strftime
(
"%X"
)
.unwrap
()
.to_string
(),
"15:31:30"
.to_string
()
);
assert_eq!
(
local
.strftime
(
"%X"
)
.unwrap
()
.to_string
(),
"15:31:30"
);
// FIXME (#2350): support locale
// FIXME (#2350): support locale
assert_eq!
(
local
.strftime
(
"%x"
)
.unwrap
()
.to_string
(),
"02/13/09"
.to_string
()
);
assert_eq!
(
local
.strftime
(
"%x"
)
.unwrap
()
.to_string
(),
"02/13/09"
);
assert_eq!
(
local
.strftime
(
"%Y"
)
.unwrap
()
.to_string
(),
"2009"
.to_string
()
);
assert_eq!
(
local
.strftime
(
"%Y"
)
.unwrap
()
.to_string
(),
"2009"
);
assert_eq!
(
local
.strftime
(
"%y"
)
.unwrap
()
.to_string
(),
"09"
.to_string
()
);
assert_eq!
(
local
.strftime
(
"%y"
)
.unwrap
()
.to_string
(),
"09"
);
// FIXME (#2350): support locale
// FIXME (#2350): support locale
assert_eq!
(
local
.strftime
(
"%Z"
)
.unwrap
()
.to_string
(),
""
.to_string
()
);
assert_eq!
(
local
.strftime
(
"%Z"
)
.unwrap
()
.to_string
(),
""
);
assert_eq!
(
local
.strftime
(
"%z"
)
.unwrap
()
.to_string
(),
"-0800"
.to_string
()
);
assert_eq!
(
local
.strftime
(
"%z"
)
.unwrap
()
.to_string
(),
"-0800"
);
assert_eq!
(
local
.strftime
(
"%+"
)
.unwrap
()
.to_string
(),
assert_eq!
(
local
.strftime
(
"%+"
)
.unwrap
()
.to_string
(),
"2009-02-13T15:31:30-08:00"
.to_string
()
);
"2009-02-13T15:31:30-08:00"
);
assert_eq!
(
local
.strftime
(
"%%"
)
.unwrap
()
.to_string
(),
"%"
.to_string
()
);
assert_eq!
(
local
.strftime
(
"%%"
)
.unwrap
()
.to_string
(),
"%"
);
let
invalid_specifiers
=
[
"%E"
,
"%J"
,
"%K"
,
"%L"
,
"%N"
,
"%O"
,
"%o"
,
"%Q"
,
"%q"
];
let
invalid_specifiers
=
[
"%E"
,
"%J"
,
"%K"
,
"%L"
,
"%N"
,
"%O"
,
"%o"
,
"%Q"
,
"%q"
];
for
&
sp
in
invalid_specifiers
.iter
()
{
for
&
sp
in
invalid_specifiers
.iter
()
{
...
@@ -1646,16 +1646,16 @@ fn test_strftime() {
...
@@ -1646,16 +1646,16 @@ fn test_strftime() {
assert_eq!
(
local
.strftime
(
"%"
)
.unwrap_err
(),
MissingFormatConverter
);
assert_eq!
(
local
.strftime
(
"%"
)
.unwrap_err
(),
MissingFormatConverter
);
assert_eq!
(
local
.strftime
(
"%A %"
)
.unwrap_err
(),
MissingFormatConverter
);
assert_eq!
(
local
.strftime
(
"%A %"
)
.unwrap_err
(),
MissingFormatConverter
);
assert_eq!
(
local
.asctime
()
.to_string
(),
"Fri Feb 13 15:31:30 2009"
.to_string
()
);
assert_eq!
(
local
.asctime
()
.to_string
(),
"Fri Feb 13 15:31:30 2009"
);
assert_eq!
(
local
.ctime
()
.to_string
(),
"Fri Feb 13 15:31:30 2009"
.to_string
()
);
assert_eq!
(
local
.ctime
()
.to_string
(),
"Fri Feb 13 15:31:30 2009"
);
assert_eq!
(
local
.rfc822z
()
.to_string
(),
"Fri, 13 Feb 2009 15:31:30 -0800"
.to_string
()
);
assert_eq!
(
local
.rfc822z
()
.to_string
(),
"Fri, 13 Feb 2009 15:31:30 -0800"
);
assert_eq!
(
local
.rfc3339
()
.to_string
(),
"2009-02-13T15:31:30-08:00"
.to_string
()
);
assert_eq!
(
local
.rfc3339
()
.to_string
(),
"2009-02-13T15:31:30-08:00"
);
assert_eq!
(
utc
.asctime
()
.to_string
(),
"Fri Feb 13 23:31:30 2009"
.to_string
()
);
assert_eq!
(
utc
.asctime
()
.to_string
(),
"Fri Feb 13 23:31:30 2009"
);
assert_eq!
(
utc
.ctime
()
.to_string
(),
"Fri Feb 13 15:31:30 2009"
.to_string
()
);
assert_eq!
(
utc
.ctime
()
.to_string
(),
"Fri Feb 13 15:31:30 2009"
);
assert_eq!
(
utc
.rfc822
()
.to_string
(),
"Fri, 13 Feb 2009 23:31:30 GMT"
.to_string
()
);
assert_eq!
(
utc
.rfc822
()
.to_string
(),
"Fri, 13 Feb 2009 23:31:30 GMT"
);
assert_eq!
(
utc
.rfc822z
()
.to_string
(),
"Fri, 13 Feb 2009 23:31:30 -0000"
.to_string
()
);
assert_eq!
(
utc
.rfc822z
()
.to_string
(),
"Fri, 13 Feb 2009 23:31:30 -0000"
);
assert_eq!
(
utc
.rfc3339
()
.to_string
(),
"2009-02-13T23:31:30Z"
.to_string
()
);
assert_eq!
(
utc
.rfc3339
()
.to_string
(),
"2009-02-13T23:31:30Z"
);
}
}
fn
test_timespec_eq_ord
()
{
fn
test_timespec_eq_ord
()
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录