diff options
| author | acdenisSK <[email protected]> | 2017-07-27 06:42:48 +0200 |
|---|---|---|
| committer | acdenisSK <[email protected]> | 2017-07-27 07:30:23 +0200 |
| commit | 550030264952f0e0043b63f4582bb817ef8bbf37 (patch) | |
| tree | b921e2f78fd603a5ca671623083a32806fd16090 /src/framework/create_group.rs | |
| parent | Use a consistent indentation style (diff) | |
| download | serenity-550030264952f0e0043b63f4582bb817ef8bbf37.tar.xz serenity-550030264952f0e0043b63f4582bb817ef8bbf37.zip | |
rustfmt
Diffstat (limited to 'src/framework/create_group.rs')
| -rw-r--r-- | src/framework/create_group.rs | 29 |
1 files changed, 20 insertions, 9 deletions
diff --git a/src/framework/create_group.rs b/src/framework/create_group.rs index 88aa6ba..d5b68c3 100644 --- a/src/framework/create_group.rs +++ b/src/framework/create_group.rs @@ -1,11 +1,11 @@ -pub use ext::framework::command::{Command, CommandType, CommandGroup}; +pub use ext::framework::command::{Command, CommandGroup, CommandType}; pub(crate) use ext::framework::command::CommandOrAlias; pub use ext::framework::create_command::CreateCommand; use std::default::Default; use std::sync::Arc; -use ::client::Context; -use ::model::Message; +use client::Context; +use model::Message; /// Used to create command groups /// @@ -27,18 +27,26 @@ pub struct CreateGroup(pub CommandGroup); impl CreateGroup { /// Adds a command to group. pub fn command<F>(mut self, command_name: &str, f: F) -> Self - where F: FnOnce(CreateCommand) -> CreateCommand { + where + F: FnOnce(CreateCommand) -> CreateCommand, { let cmd = f(CreateCommand(Command::default())).0; for n in &cmd.aliases { if let Some(ref prefix) = self.0.prefix { - self.0.commands.insert(format!("{} {}", prefix, n.to_owned()), CommandOrAlias::Alias(format!("{} {}", prefix, command_name.to_string()))); + self.0 + .commands + .insert(format!("{} {}", prefix, n.to_owned()), + CommandOrAlias::Alias(format!("{} {}", + prefix, + command_name.to_string()))); } else { - self.0.commands.insert(n.to_owned(), CommandOrAlias::Alias(command_name.to_string())); + self.0.commands.insert(n.to_owned(), + CommandOrAlias::Alias(command_name.to_string())); } } - self.0.commands.insert(command_name.to_owned(), CommandOrAlias::Command(Arc::new(cmd))); + self.0.commands.insert(command_name.to_owned(), + CommandOrAlias::Command(Arc::new(cmd))); self } @@ -46,10 +54,13 @@ impl CreateGroup { /// Adds a command to group with simplified API. /// You can return Err(string) if there's an error. pub fn on<F>(mut self, command_name: &str, 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> + Send + Sync + 'static, { let cmd = Arc::new(Command::new(f)); - self.0.commands.insert(command_name.to_owned(), CommandOrAlias::Command(cmd)); + self.0 + .commands + .insert(command_name.to_owned(), CommandOrAlias::Command(cmd)); self } |