From 88c944f96b426955933b77ca68c92990734769be Mon Sep 17 00:00:00 2001 From: CAD97 Date: Thu, 12 Mar 2020 22:29:44 -0400 Subject: Remove some TextUnit->usize escapees --- crates/ra_text_edit/src/text_edit.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'crates/ra_text_edit/src') diff --git a/crates/ra_text_edit/src/text_edit.rs b/crates/ra_text_edit/src/text_edit.rs index 3291ada42..5c37a08a8 100644 --- a/crates/ra_text_edit/src/text_edit.rs +++ b/crates/ra_text_edit/src/text_edit.rs @@ -63,12 +63,12 @@ impl TextEdit { } pub fn apply(&self, text: &str) -> String { - let mut total_len = text.len(); + let mut total_len = TextUnit::of_str(text); for atom in self.atoms.iter() { - total_len += atom.insert.len(); - total_len -= (atom.delete.end() - atom.delete.start()).to_usize(); + total_len += TextUnit::of_str(&atom.insert); + total_len -= atom.delete.end() - atom.delete.start(); } - let mut buf = String::with_capacity(total_len); + let mut buf = String::with_capacity(total_len.to_usize()); let mut prev = 0; for atom in self.atoms.iter() { let start = atom.delete.start().to_usize(); @@ -80,7 +80,7 @@ impl TextEdit { prev = end; } buf.push_str(&text[prev..text.len()]); - assert_eq!(buf.len(), total_len); + assert_eq!(TextUnit::of_str(&buf), total_len); buf } -- cgit v1.2.3