Skip to content

Commit

Permalink
refactor(lexer): fix warnings by 'cargo clippy' for lexer (#1000)
Browse files Browse the repository at this point in the history
Signed-off-by: Abhishek Kumar <[email protected]>
  • Loading branch information
octonawish-akcodes authored Jan 24, 2024
1 parent 9c746e9 commit 0f99a7c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion kclvm/lexer/src/number.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ impl<'a> Cursor<'a> {
// with a number
self.bump();
let mut empty_exponent = false;
if self.peek().is_digit(10) {
if self.peek().is_ascii_digit() {
self.eat_decimal_digits();
match self.peek() {
'e' | 'E' => {
Expand Down
8 changes: 5 additions & 3 deletions kclvm/lexer/src/tests.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
use super::*;
use expect_test::{expect, Expect};
use std::fmt::Write;

fn check_lexing(src: &str, expect: Expect) {
let actual: String = tokenize(src)
.map(|token| format!("{:?}\n", token))
.collect();
let actual: String = tokenize(src).fold(String::new(), |mut acc, token| {
writeln!(acc, "{:?}", token).expect("Failed to write to string");
acc
});
expect.assert_eq(&actual)
}

Expand Down

0 comments on commit 0f99a7c

Please sign in to comment.