Parser<'a> {
l: &'a Lexer<'a>,
cur_token: Token,
peek_token: Token
}
impl<'a> Parser<'a> {
fn new(l: &'a mut Lexer<'a>) -> Parser<'a> {
...
}
fn next_token(&mut self) {
self.cur_token = self.peek_token;
self.peek_token = self.l.next_token();
}
}
https://doc.rust-lang.org/std/mem/fn.replace.html ?
self.cur_token = mem::replace(&mut self.peek_token, self.l.next_token())
Обсуждают сегодня