From 3a30ec2a322b66d4bc3616104eb5bd9b85bd0654 Mon Sep 17 00:00:00 2001 From: acdenisSK Date: Mon, 25 Sep 2017 17:29:16 +0200 Subject: 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`, it needs to be done. Plus it removes the useless custom struct. --- src/framework/standard/command.rs | 31 +++---------------------------- 1 file changed, 3 insertions(+), 28 deletions(-) (limited to 'src/framework') 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) -> 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 From for Error { - fn from(e: E) -> Self { - Error(format!("{}", e)) - } -} - -impl From 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 for Custom { - fn from(e: String) -> Custom { - Custom(e) +impl From for Error { + fn from(d: D) -> Self { + Error(format!("{}", d)) } } -- cgit v1.2.3