Minor improvement to error message in diff.
rustfmt Build rustfmt has succeeded Details
rust-test Build rust-test has succeeded Details
rust-build Build rust-build has succeeded Details

This commit is contained in:
Tom Alexander 2023-08-28 01:04:51 -04:00
parent 18a396b7cb
commit b6b869df25
Signed by: talexander
GPG Key ID: D3A179C9A53C0EDE
1 changed files with 4 additions and 4 deletions

View File

@ -44,28 +44,28 @@ impl<'s> Token<'s> {
pub fn as_vector<'p>(&'p self) -> Result<&'p Vec<Token<'s>>, Box<dyn std::error::Error>> {
Ok(match self {
Token::Vector(children) => Ok(children),
_ => Err(format!("wrong token type {:?}", self)),
_ => Err(format!("wrong token type, expected vector: {:?}", self)),
}?)
}
pub fn as_list<'p>(&'p self) -> Result<&'p Vec<Token<'s>>, Box<dyn std::error::Error>> {
Ok(match self {
Token::List(children) => Ok(children),
_ => Err(format!("wrong token type {:?}", self)),
_ => Err(format!("wrong token type, expected list: {:?}", self)),
}?)
}
pub fn as_atom<'p>(&'p self) -> Result<&'s str, Box<dyn std::error::Error>> {
Ok(match self {
Token::Atom(body) => Ok(*body),
_ => Err(format!("wrong token type {:?}", self)),
_ => Err(format!("wrong token type, expected atom: {:?}", self)),
}?)
}
pub fn as_text<'p>(&'p self) -> Result<&'p TextWithProperties<'s>, Box<dyn std::error::Error>> {
Ok(match self {
Token::TextWithProperties(body) => Ok(body),
_ => Err(format!("wrong token type {:?}", self)),
_ => Err(format!("wrong token type, expected text: {:?}", self)),
}?)
}