diff --git a/src/codegen.rs b/src/codegen.rs index 60bc459..56ed13c 100644 --- a/src/codegen.rs +++ b/src/codegen.rs @@ -25,8 +25,8 @@ impl<'a> Scope<'a> { self.named_vars.get(name) } - pub fn set(&mut self, name: &String, val: Value) -> Result<(), ()> { - if let hash_map::Entry::Vacant(e) = self.named_vars.entry(name.clone()) { + pub fn set(&mut self, name: &str, val: Value) -> Result<(), ()> { + if let hash_map::Entry::Vacant(e) = self.named_vars.entry(name.to_owned()) { e.insert(val); Ok(()) } else { @@ -86,8 +86,8 @@ impl Expression { }, BlockExpr(_) => panic!("Not implemented!"), FunctionCall(_) => panic!("Not implemented!"), - VariableName(name) => scope.get(&name).cloned().unwrap(), - Literal(lit) => scope.block.get_const(&lit), + VariableName(name) => scope.get(name).cloned().unwrap(), + Literal(lit) => scope.block.get_const(lit), } } } diff --git a/src/lexer.rs b/src/lexer.rs index 7199c73..828c344 100644 --- a/src/lexer.rs +++ b/src/lexer.rs @@ -1,4 +1,4 @@ -use std::{fmt::Debug, iter::Peekable, str::Chars}; +use std::{fmt::Debug, str::Chars}; static DECIMAL_NUMERICS: &[char] = &['0', '1', '2', '3', '4', '5', '6', '7', '8', '9']; @@ -71,8 +71,6 @@ impl Debug for FullToken { pub type Position = (u32, u32); -const EOF_CHAR: char = '\0'; - pub struct Cursor<'a> { pub position: Position, char_stream: Chars<'a>, @@ -94,6 +92,7 @@ impl<'a> Cursor<'a> { self.char_stream.clone().next() } + #[allow(dead_code)] // Is this actually needed? fn second(&mut self) -> Option { // `.next()` optimizes better than `.nth(1)` let mut stream = self.char_stream.clone();