about summary refs log tree commit diff
path: root/users/tazjin
diff options
context:
space:
mode:
Diffstat (limited to 'users/tazjin')
-rw-r--r--users/tazjin/rlox/src/scanner.rs10
1 files changed, 3 insertions, 7 deletions
diff --git a/users/tazjin/rlox/src/scanner.rs b/users/tazjin/rlox/src/scanner.rs
index c1809010547a..78a019592ca4 100644
--- a/users/tazjin/rlox/src/scanner.rs
+++ b/users/tazjin/rlox/src/scanner.rs
@@ -55,13 +55,13 @@ pub enum TokenKind {
 #[derive(Debug)]
 pub struct Token<'a> {
     kind: TokenKind,
-    lexeme: &'a str,
+    lexeme: &'a [char],
     // literal: Object, // TODO(tazjin): Uhh?
     line: usize,
 }
 
 struct Scanner<'a> {
-    source: &'a str,
+    source: &'a [char],
     tokens: Vec<Token<'a>>,
     errors: Vec<Error>,
     start: usize,   // offset of first character in current lexeme
@@ -76,11 +76,7 @@ impl<'a> Scanner<'a> {
 
     fn advance(&mut self) -> char {
         self.current += 1;
-
-        // TODO(tazjin): Due to utf8-safety, this is a bit annoying.
-        // Since string iteration is not the point here I'm just
-        // leaving this as is for now.
-        self.source.chars().nth(self.current - 1).unwrap()
+        self.source[self.current-1]
     }
 
     fn add_token(&mut self, kind: TokenKind) {