Skip to content

Commit

Permalink
Abstract CommandResult type (serenity-rs#934)
Browse files Browse the repository at this point in the history
CommandResult currently hardcodes to returning a Result with type ().

Doing this limits the usability of CommandResult since users can't
use this type alias with functions that return Results that don't use
type ().

Since Rust has type defaults, abstract CommandResult to accept type T
with a default type of () which doesn't compromise the existing usage
of CommandResult, but adds onto it.

Signed-off-by: kingbri <bdashore3@gmail.com>
  • Loading branch information
bdashore3 authored and arqunis committed Nov 9, 2020
1 parent 5a77311 commit 4982284
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/framework/standard/structures/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ pub struct CommandOptions {
}

pub type CommandError = Box<dyn StdError + Send + Sync>;
pub type CommandResult = std::result::Result<(), CommandError>;
pub type CommandResult<T = ()> = std::result::Result<T, CommandError>;
pub type CommandFn = for<'fut> fn(&'fut Context, &'fut Message, Args) -> BoxFuture<'fut, CommandResult>;

pub struct Command {
Expand Down

0 comments on commit 4982284

Please sign in to comment.