diff options
| author | Jorge Aparicio <japaricious@gmail.com> | 2014-11-27 19:45:47 -0500 |
|---|---|---|
| committer | Jorge Aparicio <japaricious@gmail.com> | 2014-12-06 23:53:02 -0500 |
| commit | c2da923fc95e29424a7dac1505d6e8ea50c49b9f (patch) | |
| tree | 8b47144a56039b4a53519513bce60aa74c1dcf51 /src/libstd | |
| parent | ba01ea3730025028affbf4ce56f29621861779c6 (diff) | |
| download | rust-c2da923fc95e29424a7dac1505d6e8ea50c49b9f.tar.gz rust-c2da923fc95e29424a7dac1505d6e8ea50c49b9f.zip | |
libstd: remove unnecessary `to_string()` calls
Diffstat (limited to 'src/libstd')
| -rw-r--r-- | src/libstd/ascii.rs | 42 | ||||
| -rw-r--r-- | src/libstd/collections/hash/map.rs | 4 | ||||
| -rw-r--r-- | src/libstd/collections/hash/set.rs | 4 | ||||
| -rw-r--r-- | src/libstd/collections/lru_cache.rs | 12 | ||||
| -rw-r--r-- | src/libstd/io/mem.rs | 4 | ||||
| -rw-r--r-- | src/libstd/io/mod.rs | 16 | ||||
| -rw-r--r-- | src/libstd/io/net/ip.rs | 6 | ||||
| -rw-r--r-- | src/libstd/io/process.rs | 10 | ||||
| -rw-r--r-- | src/libstd/io/stdio.rs | 2 | ||||
| -rw-r--r-- | src/libstd/num/strconv.rs | 16 | ||||
| -rw-r--r-- | src/libstd/num/uint_macros.rs | 16 | ||||
| -rw-r--r-- | src/libstd/path/windows.rs | 4 | ||||
| -rw-r--r-- | src/libstd/rt/backtrace.rs | 2 | ||||
| -rw-r--r-- | src/libstd/sync/future.rs | 12 | ||||
| -rw-r--r-- | src/libstd/sys/windows/process.rs | 10 | ||||
| -rw-r--r-- | src/libstd/task.rs | 10 | ||||
| -rw-r--r-- | src/libstd/time/duration.rs | 22 |
17 files changed, 96 insertions, 96 deletions
diff --git a/src/libstd/ascii.rs b/src/libstd/ascii.rs index f31c694098f..a03d946f407 100644 --- a/src/libstd/ascii.rs +++ b/src/libstd/ascii.rs @@ -680,13 +680,13 @@ mod tests { 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 @@ mod tests { #[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 @@ mod tests { #[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 @@ mod tests { #[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 @@ mod tests { #[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 @@ mod tests { 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 @@ mod tests { #[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 @@ mod tests { #[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"); } } diff --git a/src/libstd/collections/hash/map.rs b/src/libstd/collections/hash/map.rs index 1fb6279d004..ef7fe48b1ad 100644 --- a/src/libstd/collections/hash/map.rs +++ b/src/libstd/collections/hash/map.rs @@ -1903,8 +1903,8 @@ mod test_map { 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] diff --git a/src/libstd/collections/hash/set.rs b/src/libstd/collections/hash/set.rs index 9c9f23369e5..ebf7a29ad3f 100644 --- a/src/libstd/collections/hash/set.rs +++ b/src/libstd/collections/hash/set.rs @@ -862,7 +862,7 @@ mod test_set { 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), "{}"); } } diff --git a/src/libstd/collections/lru_cache.rs b/src/libstd/collections/lru_cache.rs index 94bea37d187..638ccdb1112 100644 --- a/src/libstd/collections/lru_cache.rs +++ b/src/libstd/collections/lru_cache.rs @@ -446,15 +446,15 @@ mod tests { 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 @@ mod tests { 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(), "{}"); } } diff --git a/src/libstd/io/mem.rs b/src/libstd/io/mem.rs index c48f487c95c..078daf8feca 100644 --- a/src/libstd/io/mem.rs +++ b/src/libstd/io/mem.rs @@ -592,7 +592,7 @@ mod test { 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\ntesting".to_string()); + assert_eq!(r.read_to_string().unwrap(), "testingtesting\ntesting"); } #[test] @@ -602,7 +602,7 @@ mod test { 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] diff --git a/src/libstd/io/mod.rs b/src/libstd/io/mod.rs index 5a56636ffa4..a9e653e267a 100644 --- a/src/libstd/io/mod.rs +++ b/src/libstd/io/mod.rs @@ -2005,14 +2005,14 @@ mod tests { 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 { diff --git a/src/libstd/io/net/ip.rs b/src/libstd/io/net/ip.rs index 4812e911cc4..20e2753392c 100644 --- a/src/libstd/io/net/ip.rs +++ b/src/libstd/io/net/ip.rs @@ -640,10 +640,10 @@ mod test { #[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] diff --git a/src/libstd/io/process.rs b/src/libstd/io/process.rs index 53c672b4302..a4ca77e92fa 100644 --- a/src/libstd/io/process.rs +++ b/src/libstd/io/process.rs @@ -810,7 +810,7 @@ mod tests { 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 @@ mod tests { 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 @@ mod tests { 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 @@ mod tests { 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 @@ mod tests { 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()); diff --git a/src/libstd/io/stdio.rs b/src/libstd/io/stdio.rs index 89d5b7a8acd..fce1ee7e9b4 100644 --- a/src/libstd/io/stdio.rs +++ b/src/libstd/io/stdio.rs @@ -527,7 +527,7 @@ mod tests { 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] diff --git a/src/libstd/num/strconv.rs b/src/libstd/num/strconv.rs index b42286c0308..c87f40f351b 100644 --- a/src/libstd/num/strconv.rs +++ b/src/libstd/num/strconv.rs @@ -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"); } } diff --git a/src/libstd/num/uint_macros.rs b/src/libstd/num/uint_macros.rs index 7b79e535201..0baefb11cf8 100644 --- a/src/libstd/num/uint_macros.rs +++ b/src/libstd/num/uint_macros.rs @@ -79,28 +79,28 @@ mod tests { #[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] diff --git a/src/libstd/path/windows.rs b/src/libstd/path/windows.rs index 366e3125c65..512756ececd 100644 --- a/src/libstd/path/windows.rs +++ b/src/libstd/path/windows.rs @@ -1321,9 +1321,9 @@ mod tests { #[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(); diff --git a/src/libstd/rt/backtrace.rs b/src/libstd/rt/backtrace.rs index 159fc3080e8..93690323d31 100644 --- a/src/libstd/rt/backtrace.rs +++ b/src/libstd/rt/backtrace.rs @@ -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] diff --git a/src/libstd/sync/future.rs b/src/libstd/sync/future.rs index 79e0d487cad..a8c9983e5aa 100644 --- a/src/libstd/sync/future.rs +++ b/src/libstd/sync/future.rs @@ -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 @@ mod test { 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 @@ mod test { #[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] diff --git a/src/libstd/sys/windows/process.rs b/src/libstd/sys/windows/process.rs index 2af5e4890e8..02548bedf02 100644 --- a/src/libstd/sys/windows/process.rs +++ b/src/libstd/sys/windows/process.rs @@ -484,24 +484,24 @@ mod tests { 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" ); } } diff --git a/src/libstd/task.rs b/src/libstd/task.rs index c433dfa08f4..0fb9e5b5c43 100644 --- a/src/libstd/task.rs +++ b/src/libstd/task.rs @@ -287,21 +287,21 @@ mod test { #[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 @@ mod test { 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 @@ mod test { 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 diff --git a/src/libstd/time/duration.rs b/src/libstd/time/duration.rs index ec2d62ff85c..1c36024bd96 100644 --- a/src/libstd/time/duration.rs +++ b/src/libstd/time/duration.rs @@ -538,20 +538,20 @@ mod tests { #[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"); } } |
