Skip to content

Commit 912ee98

Browse files
author
Jorge Aparicio
committed
libtime: remove unnecessary to_string() calls
1 parent ea342f5 commit 912ee98

File tree

1 file changed

+58
-58
lines changed

1 file changed

+58
-58
lines changed

src/libtime/lib.rs

+58-58
Original file line numberDiff line numberDiff line change
@@ -1564,8 +1564,8 @@ mod tests {
15641564

15651565
debug!("test_ctime: {} {}", utc.asctime(), local.asctime());
15661566

1567-
assert_eq!(utc.asctime().to_string(), "Fri Feb 13 23:31:30 2009".to_string());
1568-
assert_eq!(local.asctime().to_string(), "Fri Feb 13 15:31:30 2009".to_string());
1567+
assert_eq!(utc.asctime().to_string(), "Fri Feb 13 23:31:30 2009");
1568+
assert_eq!(local.asctime().to_string(), "Fri Feb 13 15:31:30 2009");
15691569
}
15701570

15711571
fn test_ctime() {
@@ -1577,8 +1577,8 @@ mod tests {
15771577

15781578
debug!("test_ctime: {} {}", utc.ctime(), local.ctime());
15791579

1580-
assert_eq!(utc.ctime().to_string(), "Fri Feb 13 15:31:30 2009".to_string());
1581-
assert_eq!(local.ctime().to_string(), "Fri Feb 13 15:31:30 2009".to_string());
1580+
assert_eq!(utc.ctime().to_string(), "Fri Feb 13 15:31:30 2009");
1581+
assert_eq!(local.ctime().to_string(), "Fri Feb 13 15:31:30 2009");
15821582
}
15831583

15841584
fn test_strftime() {
@@ -1588,56 +1588,56 @@ mod tests {
15881588
let utc = at_utc(time);
15891589
let local = at(time);
15901590

1591-
assert_eq!(local.strftime("").unwrap().to_string(), "".to_string());
1592-
assert_eq!(local.strftime("%A").unwrap().to_string(), "Friday".to_string());
1593-
assert_eq!(local.strftime("%a").unwrap().to_string(), "Fri".to_string());
1594-
assert_eq!(local.strftime("%B").unwrap().to_string(), "February".to_string());
1595-
assert_eq!(local.strftime("%b").unwrap().to_string(), "Feb".to_string());
1596-
assert_eq!(local.strftime("%C").unwrap().to_string(), "20".to_string());
1591+
assert_eq!(local.strftime("").unwrap().to_string(), "");
1592+
assert_eq!(local.strftime("%A").unwrap().to_string(), "Friday");
1593+
assert_eq!(local.strftime("%a").unwrap().to_string(), "Fri");
1594+
assert_eq!(local.strftime("%B").unwrap().to_string(), "February");
1595+
assert_eq!(local.strftime("%b").unwrap().to_string(), "Feb");
1596+
assert_eq!(local.strftime("%C").unwrap().to_string(), "20");
15971597
assert_eq!(local.strftime("%c").unwrap().to_string(),
1598-
"Fri Feb 13 15:31:30 2009".to_string());
1599-
assert_eq!(local.strftime("%D").unwrap().to_string(), "02/13/09".to_string());
1600-
assert_eq!(local.strftime("%d").unwrap().to_string(), "13".to_string());
1601-
assert_eq!(local.strftime("%e").unwrap().to_string(), "13".to_string());
1602-
assert_eq!(local.strftime("%F").unwrap().to_string(), "2009-02-13".to_string());
1603-
assert_eq!(local.strftime("%f").unwrap().to_string(), "000054321".to_string());
1604-
assert_eq!(local.strftime("%G").unwrap().to_string(), "2009".to_string());
1605-
assert_eq!(local.strftime("%g").unwrap().to_string(), "09".to_string());
1606-
assert_eq!(local.strftime("%H").unwrap().to_string(), "15".to_string());
1607-
assert_eq!(local.strftime("%h").unwrap().to_string(), "Feb".to_string());
1608-
assert_eq!(local.strftime("%I").unwrap().to_string(), "03".to_string());
1609-
assert_eq!(local.strftime("%j").unwrap().to_string(), "044".to_string());
1610-
assert_eq!(local.strftime("%k").unwrap().to_string(), "15".to_string());
1611-
assert_eq!(local.strftime("%l").unwrap().to_string(), " 3".to_string());
1612-
assert_eq!(local.strftime("%M").unwrap().to_string(), "31".to_string());
1613-
assert_eq!(local.strftime("%m").unwrap().to_string(), "02".to_string());
1614-
assert_eq!(local.strftime("%n").unwrap().to_string(), "\n".to_string());
1615-
assert_eq!(local.strftime("%P").unwrap().to_string(), "pm".to_string());
1616-
assert_eq!(local.strftime("%p").unwrap().to_string(), "PM".to_string());
1617-
assert_eq!(local.strftime("%R").unwrap().to_string(), "15:31".to_string());
1618-
assert_eq!(local.strftime("%r").unwrap().to_string(), "03:31:30 PM".to_string());
1619-
assert_eq!(local.strftime("%S").unwrap().to_string(), "30".to_string());
1620-
assert_eq!(local.strftime("%s").unwrap().to_string(), "1234567890".to_string());
1621-
assert_eq!(local.strftime("%T").unwrap().to_string(), "15:31:30".to_string());
1622-
assert_eq!(local.strftime("%t").unwrap().to_string(), "\t".to_string());
1623-
assert_eq!(local.strftime("%U").unwrap().to_string(), "06".to_string());
1624-
assert_eq!(local.strftime("%u").unwrap().to_string(), "5".to_string());
1625-
assert_eq!(local.strftime("%V").unwrap().to_string(), "07".to_string());
1626-
assert_eq!(local.strftime("%v").unwrap().to_string(), "13-Feb-2009".to_string());
1627-
assert_eq!(local.strftime("%W").unwrap().to_string(), "06".to_string());
1628-
assert_eq!(local.strftime("%w").unwrap().to_string(), "5".to_string());
1598+
"Fri Feb 13 15:31:30 2009");
1599+
assert_eq!(local.strftime("%D").unwrap().to_string(), "02/13/09");
1600+
assert_eq!(local.strftime("%d").unwrap().to_string(), "13");
1601+
assert_eq!(local.strftime("%e").unwrap().to_string(), "13");
1602+
assert_eq!(local.strftime("%F").unwrap().to_string(), "2009-02-13");
1603+
assert_eq!(local.strftime("%f").unwrap().to_string(), "000054321");
1604+
assert_eq!(local.strftime("%G").unwrap().to_string(), "2009");
1605+
assert_eq!(local.strftime("%g").unwrap().to_string(), "09");
1606+
assert_eq!(local.strftime("%H").unwrap().to_string(), "15");
1607+
assert_eq!(local.strftime("%h").unwrap().to_string(), "Feb");
1608+
assert_eq!(local.strftime("%I").unwrap().to_string(), "03");
1609+
assert_eq!(local.strftime("%j").unwrap().to_string(), "044");
1610+
assert_eq!(local.strftime("%k").unwrap().to_string(), "15");
1611+
assert_eq!(local.strftime("%l").unwrap().to_string(), " 3");
1612+
assert_eq!(local.strftime("%M").unwrap().to_string(), "31");
1613+
assert_eq!(local.strftime("%m").unwrap().to_string(), "02");
1614+
assert_eq!(local.strftime("%n").unwrap().to_string(), "\n");
1615+
assert_eq!(local.strftime("%P").unwrap().to_string(), "pm");
1616+
assert_eq!(local.strftime("%p").unwrap().to_string(), "PM");
1617+
assert_eq!(local.strftime("%R").unwrap().to_string(), "15:31");
1618+
assert_eq!(local.strftime("%r").unwrap().to_string(), "03:31:30 PM");
1619+
assert_eq!(local.strftime("%S").unwrap().to_string(), "30");
1620+
assert_eq!(local.strftime("%s").unwrap().to_string(), "1234567890");
1621+
assert_eq!(local.strftime("%T").unwrap().to_string(), "15:31:30");
1622+
assert_eq!(local.strftime("%t").unwrap().to_string(), "\t");
1623+
assert_eq!(local.strftime("%U").unwrap().to_string(), "06");
1624+
assert_eq!(local.strftime("%u").unwrap().to_string(), "5");
1625+
assert_eq!(local.strftime("%V").unwrap().to_string(), "07");
1626+
assert_eq!(local.strftime("%v").unwrap().to_string(), "13-Feb-2009");
1627+
assert_eq!(local.strftime("%W").unwrap().to_string(), "06");
1628+
assert_eq!(local.strftime("%w").unwrap().to_string(), "5");
16291629
// FIXME (#2350): support locale
1630-
assert_eq!(local.strftime("%X").unwrap().to_string(), "15:31:30".to_string());
1630+
assert_eq!(local.strftime("%X").unwrap().to_string(), "15:31:30");
16311631
// FIXME (#2350): support locale
1632-
assert_eq!(local.strftime("%x").unwrap().to_string(), "02/13/09".to_string());
1633-
assert_eq!(local.strftime("%Y").unwrap().to_string(), "2009".to_string());
1634-
assert_eq!(local.strftime("%y").unwrap().to_string(), "09".to_string());
1632+
assert_eq!(local.strftime("%x").unwrap().to_string(), "02/13/09");
1633+
assert_eq!(local.strftime("%Y").unwrap().to_string(), "2009");
1634+
assert_eq!(local.strftime("%y").unwrap().to_string(), "09");
16351635
// FIXME (#2350): support locale
1636-
assert_eq!(local.strftime("%Z").unwrap().to_string(), "".to_string());
1637-
assert_eq!(local.strftime("%z").unwrap().to_string(), "-0800".to_string());
1636+
assert_eq!(local.strftime("%Z").unwrap().to_string(), "");
1637+
assert_eq!(local.strftime("%z").unwrap().to_string(), "-0800");
16381638
assert_eq!(local.strftime("%+").unwrap().to_string(),
1639-
"2009-02-13T15:31:30-08:00".to_string());
1640-
assert_eq!(local.strftime("%%").unwrap().to_string(), "%".to_string());
1639+
"2009-02-13T15:31:30-08:00");
1640+
assert_eq!(local.strftime("%%").unwrap().to_string(), "%");
16411641

16421642
let invalid_specifiers = ["%E", "%J", "%K", "%L", "%N", "%O", "%o", "%Q", "%q"];
16431643
for &sp in invalid_specifiers.iter() {
@@ -1646,16 +1646,16 @@ mod tests {
16461646
assert_eq!(local.strftime("%").unwrap_err(), MissingFormatConverter);
16471647
assert_eq!(local.strftime("%A %").unwrap_err(), MissingFormatConverter);
16481648

1649-
assert_eq!(local.asctime().to_string(), "Fri Feb 13 15:31:30 2009".to_string());
1650-
assert_eq!(local.ctime().to_string(), "Fri Feb 13 15:31:30 2009".to_string());
1651-
assert_eq!(local.rfc822z().to_string(), "Fri, 13 Feb 2009 15:31:30 -0800".to_string());
1652-
assert_eq!(local.rfc3339().to_string(), "2009-02-13T15:31:30-08:00".to_string());
1649+
assert_eq!(local.asctime().to_string(), "Fri Feb 13 15:31:30 2009");
1650+
assert_eq!(local.ctime().to_string(), "Fri Feb 13 15:31:30 2009");
1651+
assert_eq!(local.rfc822z().to_string(), "Fri, 13 Feb 2009 15:31:30 -0800");
1652+
assert_eq!(local.rfc3339().to_string(), "2009-02-13T15:31:30-08:00");
16531653

1654-
assert_eq!(utc.asctime().to_string(), "Fri Feb 13 23:31:30 2009".to_string());
1655-
assert_eq!(utc.ctime().to_string(), "Fri Feb 13 15:31:30 2009".to_string());
1656-
assert_eq!(utc.rfc822().to_string(), "Fri, 13 Feb 2009 23:31:30 GMT".to_string());
1657-
assert_eq!(utc.rfc822z().to_string(), "Fri, 13 Feb 2009 23:31:30 -0000".to_string());
1658-
assert_eq!(utc.rfc3339().to_string(), "2009-02-13T23:31:30Z".to_string());
1654+
assert_eq!(utc.asctime().to_string(), "Fri Feb 13 23:31:30 2009");
1655+
assert_eq!(utc.ctime().to_string(), "Fri Feb 13 15:31:30 2009");
1656+
assert_eq!(utc.rfc822().to_string(), "Fri, 13 Feb 2009 23:31:30 GMT");
1657+
assert_eq!(utc.rfc822z().to_string(), "Fri, 13 Feb 2009 23:31:30 -0000");
1658+
assert_eq!(utc.rfc3339().to_string(), "2009-02-13T23:31:30Z");
16591659
}
16601660

16611661
fn test_timespec_eq_ord() {

0 commit comments

Comments
 (0)