mirror of
https://github.com/teloxide/teloxide.git
synced 2025-01-03 09:49:07 +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.
|
||||
// pub fn expect_path(self) -> Result<Path> {
|
||||
// self.expect("a path", |this| match this {
|
||||
|
@ -124,7 +135,7 @@ impl AttrValue {
|
|||
/// #[blahblah(key = "puff", value = 12, nope )]
|
||||
/// ^^^^^^ ^^ ^
|
||||
/// ```
|
||||
fn span(&self) -> Span {
|
||||
pub fn span(&self) -> Span {
|
||||
match self {
|
||||
Self::Path(p) => p.span(),
|
||||
Self::Lit(l) => l.span(),
|
||||
|
|
|
@ -104,7 +104,7 @@ impl CommandAttr {
|
|||
"rename" => Rename(value.expect_string()?),
|
||||
"parse_with" => ParseWith(ParserType::parse(value)?),
|
||||
"separator" => Separator(value.expect_string()?),
|
||||
"hide" => Hide,
|
||||
"hide" => value.expect_none("hide").map(|_| Hide)?,
|
||||
_ => {
|
||||
return Err(compile_error_at(
|
||||
"unexpected attribute name (expected one of `prefix`, `description`, \
|
||||
|
|
Loading…
Reference in a new issue