Merge pull request #37 from teloxide/enhance-path-error-msg

Enhance an error message about a path
This commit is contained in:
Hirrolot 2022-10-06 18:06:00 +06:00 committed by GitHub
commit e715105dda
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -12,15 +12,18 @@ pub(crate) enum ParserType {
impl ParserType {
pub fn parse(value: AttrValue) -> Result<Self> {
value.expect(r#""default", "split" or a path"#, |v| match v {
AttrValue::Path(p) => Ok(ParserType::Custom(p)),
AttrValue::Lit(syn::Lit::Str(ref l)) => match &*l.value() {
"default" => Ok(ParserType::Default),
"split" => Ok(ParserType::Split { separator: None }),
value.expect(
r#""default", "split", or a path to a custom parser function"#,
|v| match v {
AttrValue::Path(p) => Ok(ParserType::Custom(p)),
AttrValue::Lit(syn::Lit::Str(ref l)) => match &*l.value() {
"default" => Ok(ParserType::Default),
"split" => Ok(ParserType::Split { separator: None }),
_ => Err(v),
},
_ => Err(v),
},
_ => Err(v),
})
)
}
}