mirror of
https://github.com/teloxide/teloxide.git
synced 2025-01-03 09:49:07 +01:00
Merge pull request #37 from teloxide/enhance-path-error-msg
Enhance an error message about a path
This commit is contained in:
commit
e715105dda
1 changed files with 10 additions and 7 deletions
|
@ -12,15 +12,18 @@ pub(crate) enum ParserType {
|
||||||
|
|
||||||
impl ParserType {
|
impl ParserType {
|
||||||
pub fn parse(value: AttrValue) -> Result<Self> {
|
pub fn parse(value: AttrValue) -> Result<Self> {
|
||||||
value.expect(r#""default", "split" or a path"#, |v| match v {
|
value.expect(
|
||||||
AttrValue::Path(p) => Ok(ParserType::Custom(p)),
|
r#""default", "split", or a path to a custom parser function"#,
|
||||||
AttrValue::Lit(syn::Lit::Str(ref l)) => match &*l.value() {
|
|v| match v {
|
||||||
"default" => Ok(ParserType::Default),
|
AttrValue::Path(p) => Ok(ParserType::Custom(p)),
|
||||||
"split" => Ok(ParserType::Split { separator: None }),
|
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),
|
||||||
},
|
},
|
||||||
_ => Err(v),
|
)
|
||||||
})
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue