This commit is contained in:
p0lunin 2020-02-22 23:02:31 +02:00
parent cb3fde7191
commit 673269602d
2 changed files with 9 additions and 8 deletions

View file

@ -15,7 +15,8 @@
//! Ban, //! Ban,
//! } //! }
//! //!
//! let (command, args) = AdminCommand::parse("/ban 3 hours", "bot_name").unwrap(); //! let (command, args) =
//! AdminCommand::parse("/ban 3 hours", "bot_name").unwrap();
//! assert_eq!(command, AdminCommand::Ban); //! assert_eq!(command, AdminCommand::Ban);
//! assert_eq!(args, vec!["3", "hours"]); //! assert_eq!(args, vec!["3", "hours"]);
//! ``` //! ```
@ -207,10 +208,7 @@ mod tests {
DefaultCommands::Start, DefaultCommands::Start,
DefaultCommands::parse("!start", "").unwrap().0 DefaultCommands::parse("!start", "").unwrap().0
); );
assert_eq!( assert_eq!(DefaultCommands::descriptions(), "!start - desc\n/help\n");
DefaultCommands::descriptions(),
"!start - desc\n/help\n"
);
} }
#[test] #[test]

View file

@ -82,9 +82,12 @@ pub fn derive_telegram_command_enum(tokens: TokenStream) -> TokenStream {
.zip(variant_name) .zip(variant_name)
.map(|(prefix, command)| prefix.to_string() + command.as_str()); .map(|(prefix, command)| prefix.to_string() + command.as_str());
let variant_str2 = variant_str1.clone(); let variant_str2 = variant_str1.clone();
let variant_description = variant_infos let variant_description = variant_infos.iter().map(|info| {
.iter() info.description
.map(|info| info.description.as_deref().map(|e| format!(" - {}", e)).unwrap_or(String::new())); .as_deref()
.map(|e| format!(" - {}", e))
.unwrap_or(String::new())
});
let ident = &input.ident; let ident = &input.ident;