mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-29 05:15:04 +00:00
move to to_usize()
This commit is contained in:
parent
c48c0f370a
commit
139479e8a3
3 changed files with 6 additions and 6 deletions
|
@ -194,7 +194,7 @@ mod tests {
|
||||||
let (off, code) = extract_offset(code);
|
let (off, code) = extract_offset(code);
|
||||||
let code = {
|
let code = {
|
||||||
let mut buf = String::new();
|
let mut buf = String::new();
|
||||||
let off = u32::from(off) as usize;
|
let off = off.to_usize();
|
||||||
buf.push_str(&code[..off]);
|
buf.push_str(&code[..off]);
|
||||||
buf.push_str("marker");
|
buf.push_str("marker");
|
||||||
buf.push_str(&code[off..]);
|
buf.push_str(&code[off..]);
|
||||||
|
|
|
@ -29,8 +29,8 @@ impl AtomTextEdit {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn apply(&self, mut text: String) -> String {
|
pub fn apply(&self, mut text: String) -> String {
|
||||||
let start = u32::from(self.delete.start()) as usize;
|
let start = self.delete.start().to_usize();
|
||||||
let end = u32::from(self.delete.end()) as usize;
|
let end = self.delete.end().to_usize();
|
||||||
text.replace_range(start..end, &self.insert);
|
text.replace_range(start..end, &self.insert);
|
||||||
text
|
text
|
||||||
}
|
}
|
||||||
|
|
|
@ -66,13 +66,13 @@ impl TextEdit {
|
||||||
let mut total_len = text.len();
|
let mut total_len = text.len();
|
||||||
for atom in self.atoms.iter() {
|
for atom in self.atoms.iter() {
|
||||||
total_len += atom.insert.len();
|
total_len += atom.insert.len();
|
||||||
total_len -= u32::from(atom.delete.end() - atom.delete.start()) as usize;
|
total_len -= (atom.delete.end() - atom.delete.start()).to_usize();
|
||||||
}
|
}
|
||||||
let mut buf = String::with_capacity(total_len);
|
let mut buf = String::with_capacity(total_len);
|
||||||
let mut prev = 0;
|
let mut prev = 0;
|
||||||
for atom in self.atoms.iter() {
|
for atom in self.atoms.iter() {
|
||||||
let start = u32::from(atom.delete.start()) as usize;
|
let start = atom.delete.start().to_usize();
|
||||||
let end = u32::from(atom.delete.end()) as usize;
|
let end = atom.delete.end().to_usize();
|
||||||
if start > prev {
|
if start > prev {
|
||||||
buf.push_str(&text[prev..start]);
|
buf.push_str(&text[prev..start]);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue