aboutsummaryrefslogtreecommitdiff
path: root/src/framework
diff options
context:
space:
mode:
Diffstat (limited to 'src/framework')
-rw-r--r--src/framework/standard/create_command.rs30
1 files changed, 10 insertions, 20 deletions
diff --git a/src/framework/standard/create_command.rs b/src/framework/standard/create_command.rs
index 6450b64..c825e67 100644
--- a/src/framework/standard/create_command.rs
+++ b/src/framework/standard/create_command.rs
@@ -207,33 +207,23 @@ impl CreateCommand {
}
pub(crate) fn finish(self) -> Arc<Command> {
- let CreateCommand(options, fc) = self;
+ struct A<C: Command>(Arc<CommandOptions>, C);
- match fc {
- FnOrCommand::Fn(func) => {
- struct A(Arc<CommandOptions>, fn(&mut Context, &Message, Args) -> Result<(), CommandError>);
+ impl<C: Command> Command for A<C> {
+ fn execute(&self, c: &mut Context, m: &Message, a: Args) -> Result<(), CommandError> {
+ self.1.execute(c, m, a)
+ }
- impl Command for A {
- fn execute(&self, c: &mut Context, m: &Message, a: Args) -> Result<(), CommandError> {
- (self.1)(c, m, a)
- }
+ fn options(&self) -> Arc<CommandOptions> { Arc::clone(&self.0) }
+ }
- fn options(&self) -> Arc<CommandOptions> { Arc::clone(&self.0) }
- }
+ let CreateCommand(options, fc) = self;
+ match fc {
+ FnOrCommand::Fn(func) => {
Arc::new(A(Arc::new(options), func))
},
FnOrCommand::Command(cmd) => {
- struct A(Arc<CommandOptions>, Arc<Command>);
-
- impl Command for A {
- fn execute(&self, c: &mut Context, m: &Message, a: Args) -> Result<(), CommandError> {
- self.1.execute(c, m, a)
- }
-
- fn options(&self) -> Arc<CommandOptions> { Arc::clone(&self.0) }
- }
-
Arc::new(A(Arc::new(options), cmd))
},
FnOrCommand::CommandWithOptions(cmd) => cmd,