From df58faab9748bfeb61bad968d08331c5a54dddd8 Mon Sep 17 00:00:00 2001 From: Hirrolot Date: Sun, 2 Oct 2022 10:15:20 +0600 Subject: [PATCH] More `#[must_use]` functions. --- CHANGELOG.md | 21 +++++++++++++-------- src/dispatching/dialogue.rs | 1 + src/dispatching/handler_ext.rs | 1 + src/utils/command.rs | 5 +++++ 4 files changed, 20 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8bfe7543..10bf0b51 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,17 +9,22 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed -- Updated `teloxide-macros` see its [changelog](https://github.com/teloxide/teloxide-macros/blob/master/CHANGELOG.md#unreleased) for more -- `UpdateListener` now has an associated type `Err` instead of a generic -- `AsUpdateStream` now has an associated type `StreamErr` instead of a generic -- Rename `dispatching::stop_token::{AsyncStopToken, AsyncStopFlag}` => `stop::{StopToken, StopFlag}` + - Updated `teloxide-macros` see its [changelog](https://github.com/teloxide/teloxide-macros/blob/master/CHANGELOG.md#unreleased) for more + - `UpdateListener` now has an associated type `Err` instead of a generic + - `AsUpdateStream` now has an associated type `StreamErr` instead of a generic + - Rename `dispatching::stop_token::{AsyncStopToken, AsyncStopFlag}` => `stop::{StopToken, StopFlag}` + - The following functions are now `#[must_use]`: + - `BotCommands::ty`. + - `CommandDescriptions::{new, global_description, username, username_from_me}`. + - `teloxide::filter_command`. + - `teloxide::dispatching::dialogue::enter`. ### Removed -- `dispatching::stop_token::StopToken` trait (all uses are replaced with `stop::StopToken` structure) -- Some previously deprecated items - - `enable_logging!`, `enable_logging_with_filter!` - - `HandlerFactory`, `HandlerExt::dispatch_by` + - `dispatching::stop_token::StopToken` trait (all uses are replaced with `stop::StopToken` structure) + - Some previously deprecated items + - `enable_logging!`, `enable_logging_with_filter!` + - `HandlerFactory`, `HandlerExt::dispatch_by` ## 0.10.1 - 2022-07-22 diff --git a/src/dispatching/dialogue.rs b/src/dispatching/dialogue.rs index 1ecffde2..6f9aa824 100644 --- a/src/dispatching/dialogue.rs +++ b/src/dispatching/dialogue.rs @@ -211,6 +211,7 @@ where /// - `Upd` /// /// [`HandlerExt::enter_dialogue`]: super::HandlerExt::enter_dialogue +#[must_use] pub fn enter() -> Handler<'static, DependencyMap, Output, DpHandlerDescription> where S: Storage + ?Sized + Send + Sync + 'static, diff --git a/src/dispatching/handler_ext.rs b/src/dispatching/handler_ext.rs index a6e80f0c..f73dfb0a 100644 --- a/src/dispatching/handler_ext.rs +++ b/src/dispatching/handler_ext.rs @@ -82,6 +82,7 @@ where /// /// - [`crate::types::Message`] /// - [`crate::types::Me`] +#[must_use] pub fn filter_command() -> Handler<'static, DependencyMap, Output, DpHandlerDescription> where C: BotCommands + Send + Sync + 'static, diff --git a/src/utils/command.rs b/src/utils/command.rs index 8d29ee7b..d84efc0c 100644 --- a/src/utils/command.rs +++ b/src/utils/command.rs @@ -235,6 +235,7 @@ pub trait BotCommands: Sized { /// Returns `PhantomData` that is used as a param of [`commands_repl`] /// /// [`commands_repl`]: (crate::repls2::commands_repl) + #[must_use] fn ty() -> PhantomData { PhantomData } @@ -296,11 +297,13 @@ pub struct CommandDescription<'a> { impl<'a> CommandDescriptions<'a> { /// Creates new [`CommandDescriptions`] from a list of command descriptions. + #[must_use] pub fn new(descriptions: &'a [CommandDescription<'a>]) -> Self { Self { global_description: None, descriptions, bot_username: None } } /// Sets the global description of these commands. + #[must_use] pub fn global_description(self, global_description: &'a str) -> Self { Self { global_description: Some(global_description), ..self } } @@ -328,6 +331,7 @@ impl<'a> CommandDescriptions<'a> { /// message" /// ); /// ``` + #[must_use] pub fn username(self, bot_username: &'a str) -> Self { Self { bot_username: Some(bot_username), ..self } } @@ -338,6 +342,7 @@ impl<'a> CommandDescriptions<'a> { /// method to get the username. /// /// [`username`]: self::CommandDescriptions::username + #[must_use] pub fn username_from_me(self, me: &'a Me) -> CommandDescriptions<'a> { self.username(me.user.username.as_deref().expect("Bots must have usernames")) }