diff options
| author | Huon Wilson <dbau.pp+github@gmail.com> | 2013-06-10 13:09:51 +1000 |
|---|---|---|
| committer | Huon Wilson <dbau.pp+github@gmail.com> | 2013-06-10 23:02:54 +1000 |
| commit | 0cfc08d81e7cc664330ce9d38a874c14a4ae51bf (patch) | |
| tree | ad575636aa13556e1f6cb605b77c296e87596499 /src/libsyntax/codemap.rs | |
| parent | 76fc9be5a1634c8b7ebf766f51ad594d9012fe9c (diff) | |
| download | rust-0cfc08d81e7cc664330ce9d38a874c14a4ae51bf.tar.gz rust-0cfc08d81e7cc664330ce9d38a874c14a4ae51bf.zip | |
std: convert character-based str::find_* to methods. Add .slice_{to,from} methods.
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 52f6e458db3..68403b2c608 100644 --- a/src/libsyntax/codemap.rs +++ b/src/libsyntax/codemap.rs @@ -24,7 +24,6 @@ source code snippets, etc. use core::prelude::*; use core::cmp; -use core::str; use core::to_bytes; use core::uint; use extra::serialize::{Encodable, Decodable, Encoder, Decoder}; @@ -288,11 +287,11 @@ impl FileMap { pub fn get_line(&self, line: int) -> ~str { let begin: BytePos = self.lines[line] - self.start_pos; let begin = begin.to_uint(); - let end = match str::find_char_from(*self.src, '\n', begin) { - Some(e) => e, - None => self.src.len() - }; - self.src.slice(begin, end).to_owned() + let slice = self.src.slice_from(begin); + match slice.find('\n') { + Some(e) => slice.slice_to(e).to_owned(), + None => slice.to_owned() + } } pub fn record_multibyte_char(&self, pos: BytePos, bytes: uint) { |
