From ca8ffba11f6292a9f29bc196158cafe59d10e63d Mon Sep 17 00:00:00 2001 From: Temirkhan Myrzamadi Date: Thu, 16 Jul 2020 20:02:39 +0600 Subject: [PATCH] Fix Clippy --- src/bot/mod.rs | 8 ++++---- tests/command.rs | 12 +++++++----- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/src/bot/mod.rs b/src/bot/mod.rs index 5ea0b550..dc0df783 100644 --- a/src/bot/mod.rs +++ b/src/bot/mod.rs @@ -155,11 +155,11 @@ impl BotBuilder { #[must_use] pub fn build(self) -> Bot { Bot { - client: self.client.unwrap_or(Client::new()), - token: self.token.unwrap_or( + client: self.client.unwrap_or_default(), + token: self.token.unwrap_or_else(|| { std::env::var("TELOXIDE_TOKEN") - .expect("Cannot get the TELOXIDE_TOKEN env variable"), - ), + .expect("Cannot get the TELOXIDE_TOKEN env variable") + }), parse_mode: self.parse_mode, } } diff --git a/tests/command.rs b/tests/command.rs index 47b3555f..fd474c2a 100644 --- a/tests/command.rs +++ b/tests/command.rs @@ -135,11 +135,13 @@ fn parse_custom_parser() { )) } }; - left.parse::().map(|res| (res, right.to_string())).map_err(|_| { - ParseError::Custom( - "First argument must be a integer!".to_owned().into(), - ) - }) + left.parse::().map(|res| (res, (*right).to_string())).map_err( + |_| { + ParseError::Custom( + "First argument must be a integer!".to_owned().into(), + ) + }, + ) } #[command(rename = "lowercase")]