From 139479e8a376aecff35db2055b9ebd2311935f98 Mon Sep 17 00:00:00 2001 From: Veetaha Date: Mon, 10 Feb 2020 01:57:43 +0200 Subject: move to to_usize() --- crates/ra_text_edit/src/lib.rs | 4 ++-- crates/ra_text_edit/src/text_edit.rs | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) (limited to 'crates/ra_text_edit') 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 { } pub fn apply(&self, mut text: String) -> String { - let start = u32::from(self.delete.start()) as usize; - let end = u32::from(self.delete.end()) as usize; + let start = self.delete.start().to_usize(); + let end = self.delete.end().to_usize(); text.replace_range(start..end, &self.insert); text } 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 { let mut total_len = text.len(); for atom in self.atoms.iter() { 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 prev = 0; for atom in self.atoms.iter() { - let start = u32::from(atom.delete.start()) as usize; - let end = u32::from(atom.delete.end()) as usize; + let start = atom.delete.start().to_usize(); + let end = atom.delete.end().to_usize(); if start > prev { buf.push_str(&text[prev..start]); } -- cgit v1.2.3