mirror of
https://github.com/teloxide/teloxide.git
synced 2025-01-03 17:52:12 +01:00
Merge pull request #923 from TheAwiteb/fix-hide-attr-bug-work-as-MetaNameValueStr
Fix hide attr bug work as meta name value str
This commit is contained in:
commit
9b7e5957cc
2 changed files with 13 additions and 2 deletions
|
@ -87,6 +87,17 @@ impl AttrValue {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Unwraps this value if it's a nothing.
|
||||||
|
pub fn expect_none(self, option_name: &str) -> Result<()> {
|
||||||
|
match self {
|
||||||
|
AttrValue::None(_) => Ok(()),
|
||||||
|
_ => Err(compile_error_at(
|
||||||
|
&format!("The {option_name} option should not have a value, remove it"),
|
||||||
|
self.span(),
|
||||||
|
)),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// /// Unwraps this value if it's a path.
|
// /// Unwraps this value if it's a path.
|
||||||
// pub fn expect_path(self) -> Result<Path> {
|
// pub fn expect_path(self) -> Result<Path> {
|
||||||
// self.expect("a path", |this| match this {
|
// self.expect("a path", |this| match this {
|
||||||
|
@ -124,7 +135,7 @@ impl AttrValue {
|
||||||
/// #[blahblah(key = "puff", value = 12, nope )]
|
/// #[blahblah(key = "puff", value = 12, nope )]
|
||||||
/// ^^^^^^ ^^ ^
|
/// ^^^^^^ ^^ ^
|
||||||
/// ```
|
/// ```
|
||||||
fn span(&self) -> Span {
|
pub fn span(&self) -> Span {
|
||||||
match self {
|
match self {
|
||||||
Self::Path(p) => p.span(),
|
Self::Path(p) => p.span(),
|
||||||
Self::Lit(l) => l.span(),
|
Self::Lit(l) => l.span(),
|
||||||
|
|
|
@ -104,7 +104,7 @@ impl CommandAttr {
|
||||||
"rename" => Rename(value.expect_string()?),
|
"rename" => Rename(value.expect_string()?),
|
||||||
"parse_with" => ParseWith(ParserType::parse(value)?),
|
"parse_with" => ParseWith(ParserType::parse(value)?),
|
||||||
"separator" => Separator(value.expect_string()?),
|
"separator" => Separator(value.expect_string()?),
|
||||||
"hide" => Hide,
|
"hide" => value.expect_none("hide").map(|_| Hide)?,
|
||||||
_ => {
|
_ => {
|
||||||
return Err(compile_error_at(
|
return Err(compile_error_at(
|
||||||
"unexpected attribute name (expected one of `prefix`, `description`, \
|
"unexpected attribute name (expected one of `prefix`, `description`, \
|
||||||
|
|
Loading…
Reference in a new issue