diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2020-02-10 09:06:01 +0000 |
---|---|---|
committer | GitHub <[email protected]> | 2020-02-10 09:06:01 +0000 |
commit | b4ac3dda78ebea1b483c0164a39907daa0c8caaa (patch) | |
tree | a4a834a6a9b6f8ab4b0be5a4da77af36f894f588 /crates/ra_text_edit | |
parent | abeadb29cea2ecf158bf89eb0da5498dfebbaea9 (diff) | |
parent | 139479e8a376aecff35db2055b9ebd2311935f98 (diff) |
Merge #3075
3075: Migrate u32::from(TextUnit) as usize to .to_usize() r=matklad a=Veetaha
@matklad I see 29 uses of `.to_usize()` cast, wouldn't it be reasonable to change `TextUnit(u32)` to `TextUnit(usize)` ? Or do you have reasons to stick with `u32` here?
Co-authored-by: Veetaha <[email protected]>
Diffstat (limited to 'crates/ra_text_edit')
-rw-r--r-- | crates/ra_text_edit/src/lib.rs | 4 | ||||
-rw-r--r-- | crates/ra_text_edit/src/text_edit.rs | 6 |
2 files changed, 5 insertions, 5 deletions
diff --git a/crates/ra_text_edit/src/lib.rs b/crates/ra_text_edit/src/lib.rs index 5f1b12222..37f23d043 100644 --- a/crates/ra_text_edit/src/lib.rs +++ b/crates/ra_text_edit/src/lib.rs | |||
@@ -29,8 +29,8 @@ impl AtomTextEdit { | |||
29 | } | 29 | } |
30 | 30 | ||
31 | pub fn apply(&self, mut text: String) -> String { | 31 | pub fn apply(&self, mut text: String) -> String { |
32 | let start = u32::from(self.delete.start()) as usize; | 32 | let start = self.delete.start().to_usize(); |
33 | let end = u32::from(self.delete.end()) as usize; | 33 | let end = self.delete.end().to_usize(); |
34 | text.replace_range(start..end, &self.insert); | 34 | text.replace_range(start..end, &self.insert); |
35 | text | 35 | text |
36 | } | 36 | } |
diff --git a/crates/ra_text_edit/src/text_edit.rs b/crates/ra_text_edit/src/text_edit.rs index 413c7d782..3291ada42 100644 --- a/crates/ra_text_edit/src/text_edit.rs +++ b/crates/ra_text_edit/src/text_edit.rs | |||
@@ -66,13 +66,13 @@ impl TextEdit { | |||
66 | let mut total_len = text.len(); | 66 | let mut total_len = text.len(); |
67 | for atom in self.atoms.iter() { | 67 | for atom in self.atoms.iter() { |
68 | total_len += atom.insert.len(); | 68 | total_len += atom.insert.len(); |
69 | total_len -= u32::from(atom.delete.end() - atom.delete.start()) as usize; | 69 | total_len -= (atom.delete.end() - atom.delete.start()).to_usize(); |
70 | } | 70 | } |
71 | let mut buf = String::with_capacity(total_len); | 71 | let mut buf = String::with_capacity(total_len); |
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 = u32::from(atom.delete.start()) as usize; | 74 | let start = atom.delete.start().to_usize(); |
75 | let end = u32::from(atom.delete.end()) as usize; | 75 | let end = atom.delete.end().to_usize(); |
76 | if start > prev { | 76 | if start > prev { |
77 | buf.push_str(&text[prev..start]); | 77 | buf.push_str(&text[prev..start]); |
78 | } | 78 | } |