[lexer] Add fail() constructor to StateResult

This commit is contained in:
Eryn Wells 2018-09-01 22:21:21 -07:00
parent d69c3dbc31
commit 7b6259977f

View file

@ -35,3 +35,9 @@ pub trait State: Debug {
fn lex(&mut self, c: char) -> StateResult;
fn none(&mut self) -> Result<Option<Token>, String>;
}
impl StateResult {
pub fn fail(msg: &str) -> StateResult {
StateResult::Fail { msg: msg.to_string() }
}
}