diff options
| author | acdenisSK <[email protected]> | 2017-07-22 01:59:38 +0200 |
|---|---|---|
| committer | acdenisSK <[email protected]> | 2017-07-22 01:59:38 +0200 |
| commit | 3c2716bbaeb71eca8cb2c7fca0dfd0b00cd34ba5 (patch) | |
| tree | 14fad807195b4bf1893968bbc26395e94c2aac5e /src/framework | |
| parent | Make bucket checks less cache dependent (diff) | |
| download | serenity-3c2716bbaeb71eca8cb2c7fca0dfd0b00cd34ba5.tar.xz serenity-3c2716bbaeb71eca8cb2c7fca0dfd0b00cd34ba5.zip | |
Remove the uneccessary function and `Send + Sync` bounds
Diffstat (limited to 'src/framework')
| -rw-r--r-- | src/framework/command.rs | 14 | ||||
| -rw-r--r-- | src/framework/mod.rs | 18 |
2 files changed, 12 insertions, 20 deletions
diff --git a/src/framework/command.rs b/src/framework/command.rs index a1c25de..e75ee5e 100644 --- a/src/framework/command.rs +++ b/src/framework/command.rs @@ -4,13 +4,13 @@ use ::client::Context; use ::model::{Message, Permissions}; use std::collections::HashMap; -pub type Check = Fn(&mut Context, &Message, &Arc<Command>) -> bool + Send + Sync + 'static; -pub type Exec = Fn(&mut Context, &Message, Vec<String>) -> Result<(), String> + Send + Sync + 'static; -pub type Help = Fn(&mut Context, &Message, HashMap<String, Arc<CommandGroup>>, &[String]) -> Result<(), String> + Send + Sync + 'static; -pub type BeforeHook = Fn(&mut Context, &Message, &String) -> bool + Send + Sync + 'static; -pub type AfterHook = Fn(&mut Context, &Message, &String, Result<(), String>) + Send + Sync + 'static; +pub type Check = Fn(&mut Context, &Message, &Arc<Command>) -> bool + 'static; +pub type Exec = Fn(&mut Context, &Message, Vec<String>) -> Result<(), String> + 'static; +pub type Help = Fn(&mut Context, &Message, HashMap<String, Arc<CommandGroup>>, &[String]) -> Result<(), String> + 'static; +pub type BeforeHook = Fn(&mut Context, &Message, &String) -> bool + 'static; +pub type AfterHook = Fn(&mut Context, &Message, &String, Result<(), String>) + 'static; pub(crate) type InternalCommand = Arc<Command>; -pub type PrefixCheck = Fn(&mut Context, &Message) -> Option<String> + Send + Sync + 'static; +pub type PrefixCheck = Fn(&mut Context, &Message) -> Option<String> + 'static; pub enum CommandOrAlias { Alias(String), @@ -67,7 +67,7 @@ pub struct Command { impl Command { pub fn new<F>(f: F) -> Self - where F: Fn(&mut Context, &Message, Vec<String>) -> Result<(), String> + Send + Sync + 'static { + where F: Fn(&mut Context, &Message, Vec<String>) -> Result<(), String> + 'static { Command { aliases: Vec::new(), checks: Vec::default(), diff --git a/src/framework/mod.rs b/src/framework/mod.rs index 2215c64..73188ca 100644 --- a/src/framework/mod.rs +++ b/src/framework/mod.rs @@ -207,9 +207,9 @@ pub enum DispatchError { WebhookAuthor, } -type DispatchErrorHook = Fn(Context, Message, DispatchError) + Send + Sync + 'static; +type DispatchErrorHook = Fn(Context, Message, DispatchError) + 'static; -pub(crate) type ActionFn = Fn(Context, MessageId, ChannelId) + Send + Sync + 'static; +pub(crate) type ActionFn = Fn(Context, MessageId, ChannelId) + 'static; /// Defines wheter this action should be called when /// a reaction's added, or removed. @@ -894,7 +894,7 @@ impl Framework { /// })); /// ``` pub fn on_dispatch_error<F>(mut self, f: F) -> Self - where F: Fn(Context, Message, DispatchError) + Send + Sync + 'static { + where F: Fn(Context, Message, DispatchError) + 'static { self.dispatch_error_handler = Some(Arc::new(f)); self @@ -946,7 +946,7 @@ impl Framework { /// ``` /// pub fn before<F>(mut self, f: F) -> Self - where F: Fn(&mut Context, &Message, &String) -> bool + Send + Sync + 'static { + where F: Fn(&mut Context, &Message, &String) -> bool + 'static { self.before = Some(Arc::new(f)); self @@ -975,7 +975,7 @@ impl Framework { /// })); /// ``` pub fn after<F>(mut self, f: F) -> Self - where F: Fn(&mut Context, &Message, &String, Result<(), String>) + Send + Sync + 'static { + where F: Fn(&mut Context, &Message, &String, Result<(), String>) + 'static { self.after = Some(Arc::new(f)); self @@ -984,12 +984,4 @@ impl Framework { pub(crate) fn update_current_user(&mut self, user_id: UserId, is_bot: bool) { self.user_info = (user_id.0, is_bot); } - - #[allow(dead_code)] - fn ratelimit_time(&mut self, bucket_name: &str, user_id: u64) -> i64 { - self.buckets - .get_mut(bucket_name) - .map(|bucket| bucket.take(user_id)) - .unwrap_or(0) - } } |