Replace full slice notation with index calls

This commit is contained in:
Nick Cameron 2015-01-02 13:56:28 +13:00
parent 918255ef8c
commit f7ff37e4c5
225 changed files with 2166 additions and 2139 deletions

View file

@ -321,9 +321,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[begin..];
let slice = self.src.index(&(begin..));
match slice.find('\n') {
Some(e) => slice[0..e],
Some(e) => slice.index(&(0..e)),
None => slice
}.to_string()
})
@ -368,9 +368,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[3..])
String::from_str(src.index(&(3..)))
} else {
String::from_str(src[])
String::from_str(src.index(&FullRange))
};
// Append '\n' in case it's not already there.
@ -457,8 +457,8 @@ impl CodeMap {
if begin.fm.start_pos != end.fm.start_pos {
None
} else {
Some(begin.fm.src[begin.pos.to_uint()..
end.pos.to_uint()].to_string())
Some(begin.fm.src.index(&(begin.pos.to_uint()..
end.pos.to_uint())).to_string())
}
}