Skip to content

Commit 9aab7d9

Browse files
committed
wip
1 parent 270f6f8 commit 9aab7d9

File tree

2 files changed

+18
-20
lines changed

2 files changed

+18
-20
lines changed

crates/common/src/ether/tokenize.rs

+18-18
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ pub enum Token {
99
}
1010

1111
impl Display for Token {
12-
fn fmt(&self, f: &mut Formatter) -> std::fmt::Result {
12+
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
1313
match self {
1414
Token::Literal(literal) => write!(f, "{}", literal),
1515
Token::Variable(variable) => write!(f, "{}", variable),
@@ -130,17 +130,17 @@ pub fn tokenize(s: &str) -> Token {
130130
let mut op = ch.to_string();
131131
iter.next();
132132
if let Some(&next_ch) = iter.peek() {
133-
if (ch == '=' && (next_ch == '=' || next_ch == '>')) ||
134-
(ch == '&' && next_ch == '&') ||
135-
(ch == '|' && next_ch == '|') ||
136-
(ch == '<' && next_ch == '=') ||
137-
(ch == '>' && next_ch == '=') ||
138-
(ch == '!' && next_ch == '=') ||
139-
(ch == '+' && next_ch == '+') ||
140-
(ch == '-' && next_ch == '-') ||
141-
(ch == '*' && next_ch == '*') ||
142-
(ch == '>' && next_ch == '>') ||
143-
(ch == '<' && next_ch == '<')
133+
if (ch == '=' && (next_ch == '=' || next_ch == '>'))
134+
|| (ch == '&' && next_ch == '&')
135+
|| (ch == '|' && next_ch == '|')
136+
|| (ch == '<' && next_ch == '=')
137+
|| (ch == '>' && next_ch == '=')
138+
|| (ch == '!' && next_ch == '=')
139+
|| (ch == '+' && next_ch == '+')
140+
|| (ch == '-' && next_ch == '-')
141+
|| (ch == '*' && next_ch == '*')
142+
|| (ch == '>' && next_ch == '>')
143+
|| (ch == '<' && next_ch == '<')
144144
{
145145
op.push(next_ch);
146146
iter.next();
@@ -174,7 +174,7 @@ pub fn tokenize(s: &str) -> Token {
174174
Token::Expression(tokens)
175175
}
176176

177-
fn parse_literal(iter: &mut std::iter::Peekable<std::str::Chars>) -> String {
177+
fn parse_literal(iter: &mut std::iter::Peekable<std::str::Chars<'_>>) -> String {
178178
let mut literal = String::new();
179179

180180
while let Some(&ch) = iter.peek() {
@@ -188,9 +188,9 @@ fn parse_literal(iter: &mut std::iter::Peekable<std::str::Chars>) -> String {
188188
}
189189

190190
// literal validation
191-
if literal.starts_with("0x") &&
192-
literal.len() > 2 &&
193-
literal[2..].chars().all(|c| c.is_ascii_hexdigit())
191+
if literal.starts_with("0x")
192+
&& literal.len() > 2
193+
&& literal[2..].chars().all(|c| c.is_ascii_hexdigit())
194194
{
195195
return literal;
196196
}
@@ -200,7 +200,7 @@ fn parse_literal(iter: &mut std::iter::Peekable<std::str::Chars>) -> String {
200200
String::from("0")
201201
}
202202

203-
fn parse_variable(iter: &mut std::iter::Peekable<std::str::Chars>) -> String {
203+
fn parse_variable(iter: &mut std::iter::Peekable<std::str::Chars<'_>>) -> String {
204204
let mut variable = String::new();
205205
while let Some(&ch) = iter.peek() {
206206
match ch {
@@ -214,7 +214,7 @@ fn parse_variable(iter: &mut std::iter::Peekable<std::str::Chars>) -> String {
214214
variable
215215
}
216216

217-
fn consume_parentheses(iter: &mut std::iter::Peekable<std::str::Chars>) -> String {
217+
fn consume_parentheses(iter: &mut std::iter::Peekable<std::str::Chars<'_>>) -> String {
218218
let mut expression = String::new();
219219
let mut parentheses_count = 1;
220220

crates/common/src/lib.rs

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
extern crate lazy_static;
2-
31
pub mod constants;
42
pub mod ether;
53
pub mod resources;

0 commit comments

Comments
 (0)