Fix Clippy

This commit is contained in:
Temirkhan Myrzamadi 2020-02-07 20:45:00 +06:00
parent 99c7bf5955
commit ab8dae9213
5 changed files with 9 additions and 7 deletions

View file

@ -280,6 +280,7 @@ where
UpdateKind::Poll(poll) => {
self.handle(&self.poll_handler, poll).await
}
_ => unreachable!(),
}
}
})

View file

@ -106,6 +106,7 @@ impl<'a> SendPoll<'a> {
}
/// `true`, if the poll needs to be anonymous, defaults to `true`.
#[allow(clippy::wrong_self_convention)]
pub fn is_anonymous<T>(mut self, val: T) -> Self
where
T: Into<bool>,
@ -145,6 +146,7 @@ impl<'a> SendPoll<'a> {
/// Pass `true`, if the poll needs to be immediately closed.
///
/// This can be useful for poll preview.
#[allow(clippy::wrong_self_convention)]
pub fn is_closed<T>(mut self, val: T) -> Self
where
T: Into<bool>,

View file

@ -47,7 +47,7 @@ fn parse_attrs(attrs: &[Attr]) -> Result<CommandAttrs, String> {
BotCommandAttribute::Description => description = Some(attr.value()),
BotCommandAttribute::RenameRule => rename_rule = Some(attr.value()),
#[allow(unreachable_patterns)]
_ => return Err(format!("unexpected attribute")),
_ => return Err("unexpected attribute".to_owned()),
}
}

View file

@ -16,7 +16,7 @@ impl CommandEnum {
if let Some(rename_rule) = &rename {
match rename_rule.as_str() {
"lowercase" => {},
_ => return Err(format!("unallowed value")),
_ => return Err("disallowed value".to_owned()),
}
}
Ok(Self {
@ -44,7 +44,7 @@ fn parse_attrs(attrs: &[Attr]) -> Result<CommandAttrs, String> {
BotCommandAttribute::Description => description = Some(attr.value()),
BotCommandAttribute::RenameRule => rename_rule = Some(attr.value()),
#[allow(unreachable_patterns)]
_ => return Err(format!("unexpected attribute")),
_ => return Err("unexpected attribute".to_owned()),
}
}

View file

@ -81,7 +81,7 @@ pub fn derive_telegram_command_enum(tokens: TokenStream) -> TokenStream {
});
let variant_str1 = variant_prefixes.zip(variant_name).map(|(prefix, command)| prefix.to_string() + command.as_str());
let variant_str2 = variant_str1.clone();
let variant_description = variant_infos.iter().map(|info| info.description.as_ref().map(String::as_str).unwrap_or(""));
let variant_description = variant_infos.iter().map(|info| info.description.as_deref().unwrap_or(""));
let ident = &input.ident;
@ -114,8 +114,7 @@ pub fn derive_telegram_command_enum(tokens: TokenStream) -> TokenStream {
};
//for debug
//println!("{}", &expanded.to_string());
let tokens = TokenStream::from(expanded);
tokens
TokenStream::from(expanded)
}
fn get_enum_data(input: &DeriveInput) -> Result<&syn::DataEnum, TokenStream> {
@ -125,7 +124,7 @@ fn get_enum_data(input: &DeriveInput) -> Result<&syn::DataEnum, TokenStream> {
}
}
fn parse_attributes(input: &Vec<syn::Attribute>) -> Result<Vec<Attr>, TokenStream> {
fn parse_attributes(input: &[syn::Attribute]) -> Result<Vec<Attr>, TokenStream> {
let mut enum_attrs = Vec::new();
for attr in input.iter() {
match attr.parse_args::<VecAttrs>() {