]> git.lizzy.rs Git - rust.git/blobdiff - src/libfmt_macros/lib.rs
use slicing sugar
[rust.git] / src / libfmt_macros / lib.rs
index 47cc072a636a147fe81e5b69b537bd28da6cca21..6e00b7688bc1353d7701407dec917ff81a562ec6 100644 (file)
@@ -211,12 +211,12 @@ fn must_consume(&mut self, c: char) {
                 self.cur.next();
             }
             Some((_, other)) => {
-                self.err(format!("expected `{:?}`, found `{:?}`", c,
-                                 other).index(&FullRange));
+                self.err(&format!("expected `{:?}`, found `{:?}`", c,
+                                  other)[]);
             }
             None => {
-                self.err(format!("expected `{:?}` but string was terminated",
-                                 c).index(&FullRange));
+                self.err(&format!("expected `{:?}` but string was terminated",
+                                  c)[]);
             }
         }
     }
@@ -239,12 +239,12 @@ fn string(&mut self, start: uint) -> &'a str {
             // we may not consume the character, so clone the iterator
             match self.cur.clone().next() {
                 Some((pos, '}')) | Some((pos, '{')) => {
-                    return self.input.index(&(start..pos));
+                    return &self.input[start..pos];
                 }
                 Some(..) => { self.cur.next(); }
                 None => {
                     self.cur.next();
-                    return self.input.index(&(start..self.input.len()));
+                    return &self.input[start..self.input.len()];
                 }
             }
         }
@@ -284,7 +284,7 @@ fn format(&mut self) -> FormatSpec<'a> {
             flags: 0,
             precision: CountImplied,
             width: CountImplied,
-            ty: self.input.index(&(0..0)),
+            ty: &self.input[0..0],
         };
         if !self.consume(':') { return spec }
 
@@ -393,7 +393,7 @@ fn word(&mut self) -> &'a str {
                 self.cur.next();
                 pos
             }
-            Some(..) | None => { return self.input.index(&(0..0)); }
+            Some(..) | None => { return &self.input[0..0]; }
         };
         let mut end;
         loop {
@@ -405,7 +405,7 @@ fn word(&mut self) -> &'a str {
                 None => { end = self.input.len(); break }
             }
         }
-        self.input.index(&(start..end))
+        &self.input[start..end]
     }
 
     /// Optionally parses an integer at the current position. This doesn't deal