It would be nice if std::error::Error was implemented for lrpar::lex::Lexeme<T>.
That way, if we're in the context of a -> Result<T, Box<dyn std::error::Error>> function, we can do
instead of
let value = $1.map_err(|error| format!("{:?}", error))?;
In context:
Integer -> Result<i32, Box<dyn Error>>:
"INT" {
let value = $1.map_err(|error| format!("{:?}", error))?;
let string = $lexer.lexeme_str(&value);
Ok(string.parse::<i32>()?)
}
;
$1 is of type Result<Lexeme<u32>, Lexeme<u32>> in the generated code.
It would be nice if
std::error::Errorwas implemented forlrpar::lex::Lexeme<T>.That way, if we're in the context of a
-> Result<T, Box<dyn std::error::Error>>function, we can doinstead of
In context:
$1is of typeResult<Lexeme<u32>, Lexeme<u32>>in the generated code.