fixed descriptions (now Command::descriptions() does not display " - " when there is no description)

This commit is contained in:
p0lunin 2020-02-22 22:54:48 +02:00
parent 61f06a5e7a
commit cb3fde7191

View file

@ -84,7 +84,7 @@ pub fn derive_telegram_command_enum(tokens: TokenStream) -> TokenStream {
let variant_str2 = variant_str1.clone(); let variant_str2 = variant_str1.clone();
let variant_description = variant_infos let variant_description = variant_infos
.iter() .iter()
.map(|info| info.description.as_deref().unwrap_or("")); .map(|info| info.description.as_deref().map(|e| format!(" - {}", e)).unwrap_or(String::new()));
let ident = &input.ident; let ident = &input.ident;
@ -105,7 +105,7 @@ pub fn derive_telegram_command_enum(tokens: TokenStream) -> TokenStream {
} }
} }
fn descriptions() -> String { fn descriptions() -> String {
std::concat!(#global_description #(#variant_str2, " - ", #variant_description, '\n'),*).to_string() std::concat!(#global_description #(#variant_str2, #variant_description, '\n'),*).to_string()
} }
fn parse<'a, 'b>(s: &'a str, bot_name: &'b str) -> Option<(Self, Vec<&'a str>)> { fn parse<'a, 'b>(s: &'a str, bot_name: &'b str) -> Option<(Self, Vec<&'a str>)> {
let mut words = s.split_whitespace(); let mut words = s.split_whitespace();