std: convert character-based str::find_* to methods. Add .slice_{to,from} methods.

This commit is contained in:
Huon Wilson
2013-06-10 13:09:51 +10:00
parent 76fc9be5a1
commit 0cfc08d81e
9 changed files with 158 additions and 405 deletions

View File

@@ -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) {