about summary refs log tree commit diff
path: root/src/liballoc
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2014-12-08 02:32:31 +0000
committerbors <bors@rust-lang.org>2014-12-08 02:32:31 +0000
commit83a44c7fa676b4e5e546ce3d4624e585f9a1e899 (patch)
tree36d7db1d2567d86816d4ac6a1ec86276974dbc65 /src/liballoc
parent8bca470c5acf13aa20022a2c462a89f72de721fc (diff)
parent1fea900de7f11d665086141806246842c03b9fc5 (diff)
downloadrust-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/liballoc')
-rw-r--r--src/liballoc/arc.rs2
-rw-r--r--src/liballoc/boxed.rs8
2 files changed, 5 insertions, 5 deletions
diff --git a/src/liballoc/arc.rs b/src/liballoc/arc.rs
index ef05279e825..1d2157b7e2f 100644
--- a/src/liballoc/arc.rs
+++ b/src/liballoc/arc.rs
@@ -523,7 +523,7 @@ mod tests {
     #[test]
     fn show_arc() {
         let a = Arc::new(5u32);
-        assert!(format!("{}", a).as_slice() == "5")
+        assert!(format!("{}", a) == "5")
     }
 
     // Make sure deriving works with Arc<T>
diff --git a/src/liballoc/boxed.rs b/src/liballoc/boxed.rs
index eb483498998..b0ba20b0133 100644
--- a/src/liballoc/boxed.rs
+++ b/src/liballoc/boxed.rs
@@ -170,14 +170,14 @@ mod test {
         let b = box Test as Box<Any>;
         let a_str = a.to_str();
         let b_str = b.to_str();
-        assert_eq!(a_str.as_slice(), "Box<Any>");
-        assert_eq!(b_str.as_slice(), "Box<Any>");
+        assert_eq!(a_str, "Box<Any>");
+        assert_eq!(b_str, "Box<Any>");
 
         let a = &8u as &Any;
         let b = &Test as &Any;
         let s = format!("{}", a);
-        assert_eq!(s.as_slice(), "&Any");
+        assert_eq!(s, "&Any");
         let s = format!("{}", b);
-        assert_eq!(s.as_slice(), "&Any");
+        assert_eq!(s, "&Any");
     }
 }