From 42fd9b869305cea3f8648d635409f850a77cb903 Mon Sep 17 00:00:00 2001 From: TheAwiteb Date: Thu, 7 Sep 2023 08:03:08 +0300 Subject: [PATCH] Use `AttrValue::expect_none` with `hide` option --- crates/teloxide-macros/src/command_attr.rs | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/crates/teloxide-macros/src/command_attr.rs b/crates/teloxide-macros/src/command_attr.rs index 203b92ea..1e01aed1 100644 --- a/crates/teloxide-macros/src/command_attr.rs +++ b/crates/teloxide-macros/src/command_attr.rs @@ -1,5 +1,5 @@ use crate::{ - attr::{fold_attrs, Attr, AttrValue}, + attr::{fold_attrs, Attr}, error::compile_error_at, fields_parse::ParserType, rename_rules::RenameRule, @@ -104,16 +104,7 @@ impl CommandAttr { "rename" => Rename(value.expect_string()?), "parse_with" => ParseWith(ParserType::parse(value)?), "separator" => Separator(value.expect_string()?), - "hide" => { - if let AttrValue::None(_) = value { - Hide - } else { - return Err(compile_error_at( - "The hide attribute should not have a value, remove it ", - value.span(), - )); - } - } + "hide" => value.expect_none("hide").map(|_| Hide)?, _ => { return Err(compile_error_at( "unexpected attribute name (expected one of `prefix`, `description`, \