diff --git a/src/mango/lexing/code_lexer.rs b/src/mango/lexing/code_lexer.rs index 1fc8bb29..26fccf7c 100644 --- a/src/mango/lexing/code_lexer.rs +++ b/src/mango/lexing/code_lexer.rs @@ -20,10 +20,11 @@ enum ReaderOrDelegate { } impl ReaderOrDelegate { - fn end_delegation(&mut self) { - *self = match self { - ReaderOrDelegate::Delegate(delegate) => ReaderOrDelegate::Reader(delegate.consume()), - ReaderOrDelegate::Reader(reader) => ReaderOrDelegate::Reader(*reader), + fn end_delegation(self) -> Self { + use self::ReaderOrDelegate::*; + match self { + Delegate(delegate) => Reader(delegate.consume()), + read => read, } } } @@ -87,7 +88,7 @@ impl Lexer for CodeLexer { } // Code to stop delegation cannot be here, because `self` is still mutably borrowed through `delegate` } - ReaderOrDelegate::Reader(mut reader) => { + ReaderOrDelegate::Reader(ref mut reader) => { // todo: maybe this branch could be a separate function? // If there is a buffer due to indentation or continuations, return from that. diff --git a/src/mango/lexing/string_lexer.rs b/src/mango/lexing/string_lexer.rs index d3f0cf2b..de5c72da 100644 --- a/src/mango/lexing/string_lexer.rs +++ b/src/mango/lexing/string_lexer.rs @@ -30,6 +30,7 @@ impl StringLexer { impl Lexer for StringLexer { fn lex(&mut self) -> MaybeToken { + // TODO: perhaps there's a library that does parsing a string with escape characters // TODO: doesn't handle escaping etc at all now // TODO: this is going to have a problem if `matches` automatically eats whitespace match self.reader.matches("[^\"\\n]*") {