aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_text_edit
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2020-03-13 08:24:19 +0000
committerGitHub <[email protected]>2020-03-13 08:24:19 +0000
commitbe3cf01c15cd48877046e675f4a0ff31b8a08798 (patch)
tree23e3903d5d9c7d72c32eb73649dd36b24eba6d38 /crates/ra_text_edit
parent2f9f409538553fc709bbcad1a5c76968f36e5968 (diff)
parent88c944f96b426955933b77ca68c92990734769be (diff)
Merge #3570
3570: Remove some TextUnit->usize escapees r=matklad a=CAD97 As spotted during [a review of all uses of `text_unit::TextUnit::to_usize`](https://github.com/rust-analyzer/text_unit/pull/12#issuecomment-598512370). Legitimate uses do remain. Co-authored-by: CAD97 <[email protected]>
Diffstat (limited to 'crates/ra_text_edit')
-rw-r--r--crates/ra_text_edit/src/text_edit.rs10
1 files changed, 5 insertions, 5 deletions
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 {
63 } 63 }
64 64
65 pub fn apply(&self, text: &str) -> String { 65 pub fn apply(&self, text: &str) -> String {
66 let mut total_len = text.len(); 66 let mut total_len = TextUnit::of_str(text);
67 for atom in self.atoms.iter() { 67 for atom in self.atoms.iter() {
68 total_len += atom.insert.len(); 68 total_len += TextUnit::of_str(&atom.insert);
69 total_len -= (atom.delete.end() - atom.delete.start()).to_usize(); 69 total_len -= atom.delete.end() - atom.delete.start();
70 } 70 }
71 let mut buf = String::with_capacity(total_len); 71 let mut buf = String::with_capacity(total_len.to_usize());
72 let mut prev = 0; 72 let mut prev = 0;
73 for atom in self.atoms.iter() { 73 for atom in self.atoms.iter() {
74 let start = atom.delete.start().to_usize(); 74 let start = atom.delete.start().to_usize();
@@ -80,7 +80,7 @@ impl TextEdit {
80 prev = end; 80 prev = end;
81 } 81 }
82 buf.push_str(&text[prev..text.len()]); 82 buf.push_str(&text[prev..text.len()]);
83 assert_eq!(buf.len(), total_len); 83 assert_eq!(TextUnit::of_str(&buf), total_len);
84 buf 84 buf
85 } 85 }
86 86