summaryrefslogtreecommitdiff
path: root/src/syntax/tokens.rs
diff options
context:
space:
mode:
authorLaurenz <laurmaedje@gmail.com>2022-11-04 09:30:44 +0100
committerLaurenz <laurmaedje@gmail.com>2022-11-04 11:38:09 +0100
commiteb951c008beea502042db4a3a0e8d1f8b51f6f52 (patch)
tree9856ee4ed0222222669de10e616a580b2a60135e /src/syntax/tokens.rs
parent33928a00dc58250e24da1dae4e5db17e7b598d70 (diff)
Style changes
Diffstat (limited to 'src/syntax/tokens.rs')
-rw-r--r--src/syntax/tokens.rs21
1 files changed, 12 insertions, 9 deletions
diff --git a/src/syntax/tokens.rs b/src/syntax/tokens.rs
index c787fa69..f18bb780 100644
--- a/src/syntax/tokens.rs
+++ b/src/syntax/tokens.rs
@@ -373,7 +373,7 @@ impl<'s> Tokens<'s> {
NodeKind::Raw(Arc::new(resolve_raw(
column,
backticks,
- self.s.get(start .. end),
+ self.s.get(start..end),
)))
} else {
self.terminated = false;
@@ -548,7 +548,7 @@ impl<'s> Tokens<'s> {
self.s.eat_while(char::is_ascii_alphanumeric);
}
- let number = self.s.get(start .. suffix_start);
+ let number = self.s.get(start..suffix_start);
let suffix = self.s.from(suffix_start);
// Find out whether it is a simple number.
@@ -558,9 +558,8 @@ impl<'s> Tokens<'s> {
}
}
- let v = match number.parse::<f64>() {
- Ok(v) => v,
- Err(_) => return NodeKind::Error(ErrorPos::Full, "invalid number".into()),
+ let Ok(v) = number.parse::<f64>() else {
+ return NodeKind::Error(ErrorPos::Full, "invalid number".into());
};
match suffix {
@@ -636,7 +635,7 @@ fn keyword(ident: &str) -> Option<NodeKind> {
#[inline]
fn column(string: &str, index: usize, offset: usize) -> usize {
let mut apply_offset = false;
- let res = string[.. index]
+ let res = string[..index]
.char_indices()
.rev()
.take_while(|&(_, c)| !is_newline(c))
@@ -653,7 +652,11 @@ fn column(string: &str, index: usize, offset: usize) -> usize {
apply_offset = true;
}
- if apply_offset { res + offset } else { res }
+ if apply_offset {
+ res + offset
+ } else {
+ res
+ }
}
/// Whether this character denotes a newline.
@@ -767,8 +770,8 @@ mod tests {
// - mode in which the suffix is applicable
// - the suffix string
// - the resulting suffix NodeKind
- fn suffixes()
- -> impl Iterator<Item = (char, Option<TokenMode>, &'static str, NodeKind)> {
+ fn suffixes(
+ ) -> impl Iterator<Item = (char, Option<TokenMode>, &'static str, NodeKind)> {
[
// Whitespace suffixes.
(' ', None, " ", Space(0)),