about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/interpret/scope.rs8
-rw-r--r--src/lex/lexer.rs22
-rw-r--r--src/main.rs2
3 files changed, 13 insertions, 19 deletions
diff --git a/src/interpret/scope.rs b/src/interpret/scope.rs
index de32692..d8b8f43 100644
--- a/src/interpret/scope.rs
+++ b/src/interpret/scope.rs
@@ -19,10 +19,10 @@ impl Scope {
         self.scopes.pop();
     }
 
-    pub fn set_var(&mut self, ident: &Identifier, value: Value) {
+    pub fn set_var(&mut self, ident: &str, value: Value) {
         for scope in self.scopes.iter_mut() {
             if scope.contains_key(ident) {
-                scope.insert(ident.clone(), value);
+                scope.insert(ident.to_string(), value);
                 return;
             }
         }
@@ -31,10 +31,10 @@ impl Scope {
             .scopes
             .last_mut()
             .expect("Tried accessing scope after last frame is gone.");
-        inner_scope.insert(ident.clone(), value);
+        inner_scope.insert(ident.to_string(), value);
     }
 
-    pub fn get_var(&self, ident: &Identifier) -> Option<Value> {
+    pub fn get_var(&self, ident: &str) -> Option<Value> {
         for scope in self.scopes.iter().rev() {
             if let Some(value) = scope.get(ident) {
                 return Some(value.clone());
diff --git a/src/lex/lexer.rs b/src/lex/lexer.rs
index c8c1a2f..4d980d6 100644
--- a/src/lex/lexer.rs
+++ b/src/lex/lexer.rs
@@ -136,23 +136,17 @@ impl<'s> Lexer<'s> {
 
     fn skip_non_code(&mut self) {
         let mut is_in_comment = false;
-        loop {
-            if let Some(c) = self.peek() {
-                if is_in_comment {
-                    if c == '\n' {
-                        is_in_comment = false;
-                    }
-                } else {
-                    if c == '#' {
-                        is_in_comment = true;
-                    } else if !c.is_whitespace() && c != '\n' {
-                        break;
-                    }
+        while let Some(c) = self.peek() {
+            if is_in_comment {
+                if c == '\n' {
+                    is_in_comment = false;
                 }
-                self.advance();
-            } else {
+            } else if c == '#' {
+                is_in_comment = true;
+            } else if !c.is_whitespace() && c != '\n' {
                 break;
             }
+            self.advance();
         }
     }
 
diff --git a/src/main.rs b/src/main.rs
index e4dfc4f..9128cdb 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -33,7 +33,7 @@ fn file(filename: impl AsRef<Path>) {
 }
 
 fn repl() {
-    const PROMPT: &'static str = "🐇: ";
+    const PROMPT: &str = "🐇: ";
 
     let mut walker = Walker::new();