Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
Jon-Becker committed Jan 4, 2025
1 parent 270f6f8 commit 9aab7d9
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 20 deletions.
36 changes: 18 additions & 18 deletions crates/common/src/ether/tokenize.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ pub enum Token {
}

impl Display for Token {
fn fmt(&self, f: &mut Formatter) -> std::fmt::Result {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
match self {
Token::Literal(literal) => write!(f, "{}", literal),
Token::Variable(variable) => write!(f, "{}", variable),
Expand Down Expand Up @@ -130,17 +130,17 @@ pub fn tokenize(s: &str) -> Token {
let mut op = ch.to_string();
iter.next();
if let Some(&next_ch) = iter.peek() {
if (ch == '=' && (next_ch == '=' || next_ch == '>')) ||
(ch == '&' && next_ch == '&') ||
(ch == '|' && next_ch == '|') ||
(ch == '<' && next_ch == '=') ||
(ch == '>' && next_ch == '=') ||
(ch == '!' && next_ch == '=') ||
(ch == '+' && next_ch == '+') ||
(ch == '-' && next_ch == '-') ||
(ch == '*' && next_ch == '*') ||
(ch == '>' && next_ch == '>') ||
(ch == '<' && next_ch == '<')
if (ch == '=' && (next_ch == '=' || next_ch == '>'))
|| (ch == '&' && next_ch == '&')
|| (ch == '|' && next_ch == '|')
|| (ch == '<' && next_ch == '=')
|| (ch == '>' && next_ch == '=')
|| (ch == '!' && next_ch == '=')
|| (ch == '+' && next_ch == '+')
|| (ch == '-' && next_ch == '-')
|| (ch == '*' && next_ch == '*')
|| (ch == '>' && next_ch == '>')
|| (ch == '<' && next_ch == '<')
{
op.push(next_ch);
iter.next();
Expand Down Expand Up @@ -174,7 +174,7 @@ pub fn tokenize(s: &str) -> Token {
Token::Expression(tokens)
}

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

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

// literal validation
if literal.starts_with("0x") &&
literal.len() > 2 &&
literal[2..].chars().all(|c| c.is_ascii_hexdigit())
if literal.starts_with("0x")
&& literal.len() > 2
&& literal[2..].chars().all(|c| c.is_ascii_hexdigit())
{
return literal;
}
Expand All @@ -200,7 +200,7 @@ fn parse_literal(iter: &mut std::iter::Peekable<std::str::Chars>) -> String {
String::from("0")
}

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

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

Expand Down
2 changes: 0 additions & 2 deletions crates/common/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
extern crate lazy_static;

pub mod constants;
pub mod ether;
pub mod resources;
Expand Down

0 comments on commit 9aab7d9

Please sign in to comment.