diff options
| author | Jorge Aparicio <japaricious@gmail.com> | 2015-01-07 11:58:31 -0500 |
|---|---|---|
| committer | Jorge Aparicio <japaricious@gmail.com> | 2015-01-07 17:35:56 -0500 |
| commit | 517f1cc63c1a5df148fdeef56791f66771d3d8e8 (patch) | |
| tree | 0d321b5be3d9610f460561e8dc446a2132bb5422 /src/libsyntax/codemap.rs | |
| parent | 6e2bfe4ae8277f0cfe76831b446d50820b4527f5 (diff) | |
| download | rust-517f1cc63c1a5df148fdeef56791f66771d3d8e8.tar.gz rust-517f1cc63c1a5df148fdeef56791f66771d3d8e8.zip | |
use slicing sugar
Diffstat (limited to 'src/libsyntax/codemap.rs')
| -rw-r--r-- | src/libsyntax/codemap.rs | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/src/libsyntax/codemap.rs b/src/libsyntax/codemap.rs index 31fe23847d9..40f239b5a5d 100644 --- a/src/libsyntax/codemap.rs +++ b/src/libsyntax/codemap.rs @@ -304,9 +304,9 @@ impl FileMap { lines.get(line_number).map(|&line| { let begin: BytePos = line - self.start_pos; let begin = begin.to_uint(); - let slice = self.src.index(&(begin..)); + let slice = &self.src[begin..]; match slice.find('\n') { - Some(e) => slice.index(&(0..e)), + Some(e) => &slice[0..e], None => slice }.to_string() }) @@ -351,9 +351,9 @@ impl CodeMap { // FIXME #12884: no efficient/safe way to remove from the start of a string // and reuse the allocation. let mut src = if src.starts_with("\u{feff}") { - String::from_str(src.index(&(3..))) + String::from_str(&src[3..]) } else { - String::from_str(src.index(&FullRange)) + String::from_str(&src[]) }; // Append '\n' in case it's not already there. @@ -440,8 +440,7 @@ impl CodeMap { if begin.fm.start_pos != end.fm.start_pos { None } else { - Some(begin.fm.src.index(&(begin.pos.to_uint().. - end.pos.to_uint())).to_string()) + Some((&begin.fm.src[begin.pos.to_uint()..end.pos.to_uint()]).to_string()) } } |
