Enhance an error message about a path

This commit is contained in:
Hirrolot 2022-10-06 17:54:31 +06:00
parent 5d6cce4121
commit 6ae6b0024e

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 for custom parsers"#,
|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),
})
)
}
}