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/libtest | |
| 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/libtest')
| -rw-r--r-- | src/libtest/lib.rs | 10 | ||||
| -rw-r--r-- | src/libtest/stats.rs | 2 |
2 files changed, 6 insertions, 6 deletions
diff --git a/src/libtest/lib.rs b/src/libtest/lib.rs index c943d8706e5..f445e812d2c 100644 --- a/src/libtest/lib.rs +++ b/src/libtest/lib.rs @@ -471,7 +471,7 @@ pub fn opt_shard(maybestr: Option<String>) -> Option<(uint,uint)> { match maybestr { None => None, Some(s) => { - let mut it = s.as_slice().split('.'); + let mut it = s.split('.'); match (it.next().and_then(from_str::<uint>), it.next().and_then(from_str::<uint>), it.next()) { (Some(a), Some(b), None) => { @@ -706,7 +706,7 @@ impl<T: Writer> ConsoleTestState<T> { } try!(self.write_plain("\nfailures:\n")); - failures.as_mut_slice().sort(); + failures.sort(); for name in failures.iter() { try!(self.write_plain(format!(" {}\n", name.as_slice()).as_slice())); @@ -934,8 +934,8 @@ fn should_sort_failures_before_printing_them() { Pretty(_) => unreachable!() }; - let apos = s.as_slice().find_str("a").unwrap(); - let bpos = s.as_slice().find_str("b").unwrap(); + let apos = s.find_str("a").unwrap(); + let bpos = s.find_str("b").unwrap(); assert!(apos < bpos); } @@ -1560,7 +1560,7 @@ mod tests { assert_eq!(filtered.len(), 1); assert_eq!(filtered[0].desc.name.to_string(), - "1".to_string()); + "1"); assert!(filtered[0].desc.ignore == false); } diff --git a/src/libtest/stats.rs b/src/libtest/stats.rs index c157fb10bd4..f9e6907f0e8 100644 --- a/src/libtest/stats.rs +++ b/src/libtest/stats.rs @@ -250,7 +250,7 @@ impl<T: FloatMath + FromPrimitive> Stats<T> for [T] { // This constant is derived by smarter statistics brains than me, but it is // consistent with how R and other packages treat the MAD. let number = FromPrimitive::from_f64(1.4826).unwrap(); - abs_devs.as_slice().median() * number + abs_devs.median() * number } fn median_abs_dev_pct(&self) -> T { |
