about summary refs log tree commit diff
path: root/src/libterm
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/libterm
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/libterm')
-rw-r--r--src/libterm/terminfo/mod.rs2
-rw-r--r--src/libterm/terminfo/parm.rs3
-rw-r--r--src/libterm/terminfo/parser/compiled.rs3
-rw-r--r--src/libterm/terminfo/searcher.rs6
4 files changed, 6 insertions, 8 deletions
diff --git a/src/libterm/terminfo/mod.rs b/src/libterm/terminfo/mod.rs
index c1393767c8a..65f8415835a 100644
--- a/src/libterm/terminfo/mod.rs
+++ b/src/libterm/terminfo/mod.rs
@@ -183,7 +183,7 @@ impl<T: Writer+Send> TerminfoTerminal<T> {
         let entry = open(term.as_slice());
         if entry.is_err() {
             if os::getenv("MSYSCON").map_or(false, |s| {
-                    "mintty.exe" == s.as_slice()
+                    "mintty.exe" == s
                 }) {
                 // msys terminal
                 return Some(box TerminfoTerminal {out: out,
diff --git a/src/libterm/terminfo/parm.rs b/src/libterm/terminfo/parm.rs
index 3c909a3c708..ee8178fed91 100644
--- a/src/libterm/terminfo/parm.rs
+++ b/src/libterm/terminfo/parm.rs
@@ -529,8 +529,7 @@ fn format(val: Param, op: FormatOp, flags: Flags) -> Result<Vec<u8> ,String> {
                     }
                 }
                 FormatHEX => {
-                    s = s.as_slice()
-                         .to_ascii()
+                    s = s.to_ascii()
                          .iter()
                          .map(|b| b.to_uppercase().as_byte())
                          .collect();
diff --git a/src/libterm/terminfo/parser/compiled.rs b/src/libterm/terminfo/parser/compiled.rs
index 9eb7216fba0..9b5e6f5cc9f 100644
--- a/src/libterm/terminfo/parser/compiled.rs
+++ b/src/libterm/terminfo/parser/compiled.rs
@@ -218,8 +218,7 @@ pub fn parse(file: &mut io::Reader, longnames: bool)
         Err(_) => return Err("input not utf-8".to_string()),
     };
 
-    let term_names: Vec<String> = names_str.as_slice()
-                                           .split('|')
+    let term_names: Vec<String> = names_str.split('|')
                                            .map(|s| s.to_string())
                                            .collect();
 
diff --git a/src/libterm/terminfo/searcher.rs b/src/libterm/terminfo/searcher.rs
index 94e234291af..33bfd69f71b 100644
--- a/src/libterm/terminfo/searcher.rs
+++ b/src/libterm/terminfo/searcher.rs
@@ -37,7 +37,7 @@ pub fn get_dbpath_for_term(term: &str) -> Option<Box<Path>> {
                 dirs_to_search.push(homedir.unwrap().join(".terminfo"))
             }
             match getenv("TERMINFO_DIRS") {
-                Some(dirs) => for i in dirs.as_slice().split(':') {
+                Some(dirs) => for i in dirs.split(':') {
                     if i == "" {
                         dirs_to_search.push(Path::new("/usr/share/terminfo"));
                     } else {
@@ -102,10 +102,10 @@ fn test_get_dbpath_for_term() {
         let p = get_dbpath_for_term(t).expect("no terminfo entry found");
         p.as_str().unwrap().to_string()
     };
-    assert!(x("screen") == "/usr/share/terminfo/s/screen".to_string());
+    assert!(x("screen") == "/usr/share/terminfo/s/screen");
     assert!(get_dbpath_for_term("") == None);
     setenv("TERMINFO_DIRS", ":");
-    assert!(x("screen") == "/usr/share/terminfo/s/screen".to_string());
+    assert!(x("screen") == "/usr/share/terminfo/s/screen");
     unsetenv("TERMINFO_DIRS");
 }