diff options
| author | bors <bors@rust-lang.org> | 2014-12-08 02:32:31 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2014-12-08 02:32:31 +0000 |
| commit | 83a44c7fa676b4e5e546ce3d4624e585f9a1e899 (patch) | |
| tree | 36d7db1d2567d86816d4ac6a1ec86276974dbc65 /src/libstd/task.rs | |
| parent | 8bca470c5acf13aa20022a2c462a89f72de721fc (diff) | |
| parent | 1fea900de7f11d665086141806246842c03b9fc5 (diff) | |
| download | rust-83a44c7fa676b4e5e546ce3d4624e585f9a1e899.tar.gz rust-83a44c7fa676b4e5e546ce3d4624e585f9a1e899.zip | |
auto merge of #19378 : japaric/rust/no-as-slice, r=alexcrichton
Now that we have an overloaded comparison (`==`) operator, and that `Vec`/`String` deref to `[T]`/`str` on method calls, many `as_slice()`/`as_mut_slice()`/`to_string()` calls have become redundant. This patch removes them. These were the most common patterns: - `assert_eq(test_output.as_slice(), "ground truth")` -> `assert_eq(test_output, "ground truth")` - `assert_eq(test_output, "ground truth".to_string())` -> `assert_eq(test_output, "ground truth")` - `vec.as_mut_slice().sort()` -> `vec.sort()` - `vec.as_slice().slice(from, to)` -> `vec.slice(from_to)` --- Note that e.g. `a_string.push_str(b_string.as_slice())` has been left untouched in this PR, since we first need to settle down whether we want to favor the `&*b_string` or the `b_string[]` notation. This is rebased on top of #19167 cc @alexcrichton @aturon
Diffstat (limited to 'src/libstd/task.rs')
| -rw-r--r-- | src/libstd/task.rs | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/src/libstd/task.rs b/src/libstd/task.rs index 8b4dbf61c18..c91417e611e 100644 --- a/src/libstd/task.rs +++ b/src/libstd/task.rs @@ -55,7 +55,7 @@ use result::Result; use rustrt::local::Local; use rustrt::task::Task; use rustrt::task; -use str::{Str, SendStr}; +use str::SendStr; use string::{String, ToString}; use sync::Future; @@ -244,7 +244,7 @@ pub fn name() -> Option<String> { let task = Local::borrow(None::<Task>); match task.name { - Some(ref name) => Some(name.as_slice().to_string()), + Some(ref name) => Some(name.to_string()), None => None } } @@ -289,21 +289,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(); } @@ -464,7 +464,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!() } @@ -511,7 +511,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 |
