diff options
| author | acdenisSK <[email protected]> | 2017-09-25 17:29:16 +0200 |
|---|---|---|
| committer | acdenisSK <[email protected]> | 2017-09-25 17:29:16 +0200 |
| commit | 3a30ec2a322b66d4bc3616104eb5bd9b85bd0654 (patch) | |
| tree | 6ea87aea185649328801586b2a5212ad1e0ebc34 /src/framework | |
| parent | Switch to temporary rust-websocket fork (diff) | |
| download | serenity-3a30ec2a322b66d4bc3616104eb5bd9b85bd0654.tar.xz serenity-3a30ec2a322b66d4bc3616104eb5bd9b85bd0654.zip | |
Use display instead of std::error::Error
Kind of a bad decision but due to the compiler being a meany with impl conflicts for `From<&str>` and `From<String>`, it needs to be done. Plus it removes the useless custom struct.
Diffstat (limited to 'src/framework')
| -rw-r--r-- | src/framework/standard/command.rs | 31 |
1 files changed, 3 insertions, 28 deletions
diff --git a/src/framework/standard/command.rs b/src/framework/standard/command.rs index aa8f7d8..1415d9b 100644 --- a/src/framework/standard/command.rs +++ b/src/framework/standard/command.rs @@ -3,7 +3,6 @@ use super::{Args, Configuration}; use client::Context; use model::{Message, Permissions}; use std::collections::HashMap; -use std::error::Error as StdError; use std::fmt; pub type Check = Fn(&mut Context, &Message, &mut Args, &Arc<Command>) -> bool @@ -30,33 +29,9 @@ pub enum CommandOrAlias { #[derive(Clone, Debug)] pub struct Error(String); -impl fmt::Display for Error { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - fmt::Display::fmt(&self.0, f) - } -} - -impl<E: StdError> From<E> for Error { - fn from(e: E) -> Self { - Error(format!("{}", e)) - } -} - -impl From<Custom> for Error { - fn from(Custom(e): Custom) -> Self { - Error(e) - } -} - -/// A custom "variant" of [`Error`] -/// -/// [`Error`]: #struct.Error.html -#[derive(Clone, Debug)] -pub struct Custom(String); - -impl From<String> for Custom { - fn from(e: String) -> Custom { - Custom(e) +impl<D: fmt::Display> From<D> for Error { + fn from(d: D) -> Self { + Error(format!("{}", d)) } } |