From 63a462f37ca584e1a585a69e30823ce25d4d252f Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Sat, 25 Apr 2020 00:57:47 +0200 Subject: Switch to TryFrom --- crates/ra_mbe/src/syntax_bridge.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'crates/ra_mbe/src') diff --git a/crates/ra_mbe/src/syntax_bridge.rs b/crates/ra_mbe/src/syntax_bridge.rs index fa9787266..bb28acfd9 100644 --- a/crates/ra_mbe/src/syntax_bridge.rs +++ b/crates/ra_mbe/src/syntax_bridge.rs @@ -516,7 +516,7 @@ impl TokenConvertor for Convertor { fn bump(&mut self) -> Option<(Self::Token, TextRange)> { if let Some((punct, offset)) = self.punct_offset.clone() { if usize::from(offset) + 1 < punct.text().len() { - let offset = offset + TextSize::from_usize(1); + let offset = offset + TextSize::of('.'); let range = punct.text_range(); self.punct_offset = Some((punct.clone(), offset)); let range = TextRange::at(range.start() + offset, TextSize::of('.')); @@ -532,9 +532,9 @@ impl TokenConvertor for Convertor { let token = if curr.kind().is_punct() { let range = curr.text_range(); - let range = TextRange::at(range.start(), TextSize::from_usize(1)); - self.punct_offset = Some((curr.clone(), TextSize::from_usize(0))); - (SynToken::Punch(curr, TextSize::from_usize(0)), range) + let range = TextRange::at(range.start(), TextSize::of('.')); + self.punct_offset = Some((curr.clone(), 0.into())); + (SynToken::Punch(curr, 0.into()), range) } else { self.punct_offset = None; let range = curr.text_range(); @@ -546,7 +546,7 @@ impl TokenConvertor for Convertor { fn peek(&self) -> Option { if let Some((punct, mut offset)) = self.punct_offset.clone() { - offset = offset + TextSize::from_usize(1); + offset = offset + TextSize::of('.'); if usize::from(offset) < punct.text().len() { return Some(SynToken::Punch(punct, offset)); } @@ -558,7 +558,7 @@ impl TokenConvertor for Convertor { } let token = if curr.kind().is_punct() { - SynToken::Punch(curr, TextSize::from_usize(0)) + SynToken::Punch(curr, 0.into()) } else { SynToken::Ordiniary(curr) }; -- cgit v1.2.3