From d91b029e768c8bfe410df1add69ac24811b52958 Mon Sep 17 00:00:00 2001 From: Santo Cariotti Date: Mon, 25 Oct 2021 11:20:13 +0200 Subject: fix(style): run cargo clippy --- src/browser/web_browser.rs | 4 ++-- src/callbacks.rs | 28 +++++++++++----------------- src/keyboard.rs | 2 +- src/main.rs | 5 +---- 4 files changed, 15 insertions(+), 24 deletions(-) diff --git a/src/browser/web_browser.rs b/src/browser/web_browser.rs index 552d72c..34424b6 100644 --- a/src/browser/web_browser.rs +++ b/src/browser/web_browser.rs @@ -131,7 +131,7 @@ impl Browser { url: &str, ) -> WebDriverResult>> { if let Some(_d) = &self.driver { - if url != "" { + if !url.is_empty() { _d.get(url).await?; } @@ -139,7 +139,7 @@ impl Browser { match self.check_login().await { Ok(true) => { // Login has been made, so reload the url - if url != "" { + if !url.is_empty() { _d.get(url).await?; } } diff --git a/src/callbacks.rs b/src/callbacks.rs index 8b4e846..c3bcb03 100644 --- a/src/callbacks.rs +++ b/src/callbacks.rs @@ -9,9 +9,9 @@ use teloxide::{ /// Handle the string of callback data pub async fn handler( cx: &UpdateWithCx, CallbackQuery>, - text: &String, + text: &str, ) -> Result> { - let call: Vec<&str> = text.split("_").collect(); + let call: Vec<&str> = text.split('_').collect(); let chat_id = call[0]; // First part of `_` string is the type of callback we want to handle @@ -39,14 +39,12 @@ pub async fn handler( .reply_markup(keyboard) .await?; - return Ok(true); + Ok(true) } else { - return Ok(false); + Ok(false) } } - Err(_) => { - return Ok(false); - } + Err(_) => Ok(false), } }, "space" => unsafe { @@ -81,14 +79,12 @@ pub async fn handler( .reply_markup(keyboard) .await?; - return Ok(true); + Ok(true) } else { - return Ok(false); + Ok(false) } } - Err(_) => { - return Ok(false); - } + Err(_) => Ok(false), } }, "timetable" => unsafe { @@ -102,7 +98,7 @@ pub async fn handler( "Reservation made! ✅", ) .await?; - return Ok(true); + Ok(true) } else { cx.requester .edit_message_text( @@ -111,12 +107,10 @@ pub async fn handler( "Error, try again! ⚠️", ) .await?; - return Ok(false); + Ok(false) } } - Err(_) => { - return Ok(false); - } + Err(_) => Ok(false), } }, _ => Ok(false), diff --git a/src/keyboard.rs b/src/keyboard.rs index 8cee93d..69dac5c 100644 --- a/src/keyboard.rs +++ b/src/keyboard.rs @@ -32,5 +32,5 @@ pub async fn make_inline_keyboard( } // The `new` method accepts an interator - return InlineKeyboardMarkup::new(keyboard_array); + InlineKeyboardMarkup::new(keyboard_array) } diff --git a/src/main.rs b/src/main.rs index abd70b8..439e54a 100644 --- a/src/main.rs +++ b/src/main.rs @@ -18,10 +18,7 @@ async fn main() -> Result<(), Box> { let bot = Bot::from_env().auto_send(); let config = Config::from_env().unwrap(); - unsafe { - // Open the browser - browser::init(&config).await; - } + browser::init(&config).await; Dispatcher::new(bot) .messages_handler(|rx: DispatcherHandlerRx, Message>| { -- cgit v1.2.3-18-g5258