diff options
author | Santo Cariotti <santo@dcariotti.me> | 2021-10-25 11:20:13 +0200 |
---|---|---|
committer | Santo Cariotti <santo@dcariotti.me> | 2021-10-25 11:20:13 +0200 |
commit | d91b029e768c8bfe410df1add69ac24811b52958 (patch) | |
tree | abb98a91bc5e5e0072a7ce3e866b640f41d24351 /src | |
parent | ba38ac07dc702e7d734ec648fdb8d552c03c1458 (diff) |
fix(style): run cargo clippymain
Diffstat (limited to 'src')
-rw-r--r-- | src/browser/web_browser.rs | 4 | ||||
-rw-r--r-- | src/callbacks.rs | 28 | ||||
-rw-r--r-- | src/keyboard.rs | 2 | ||||
-rw-r--r-- | 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<Option<HashMap<String, String>>> { 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<AutoSend<Bot>, CallbackQuery>, - text: &String, + text: &str, ) -> Result<bool, Box<dyn Error + Send + Sync>> { - 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<dyn Error>> { 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<AutoSend<Bot>, Message>| { |