From 234ca5477f436f9a2e26b8b403f07bb695166bf3 Mon Sep 17 00:00:00 2001 From: Rodolphe Breard Date: Sat, 29 Dec 2018 20:26:23 +0100 Subject: [PATCH] Remove the useless from_string method in Error --- src/errors.rs | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/src/errors.rs b/src/errors.rs index 02803a7..afe293d 100644 --- a/src/errors.rs +++ b/src/errors.rs @@ -11,10 +11,6 @@ impl Error { } } - pub fn from_string(msg: &String) -> Self { - Error::new(&msg) - } - pub fn display(&self) { eprintln!("Error: {}", self.message); } @@ -22,7 +18,7 @@ impl Error { impl From for Error { fn from(error: std::io::Error) -> Self { - Error::from_string(&format!("IO error: {}", error)) + Error::new(&format!("IO error: {}", error)) } } @@ -33,12 +29,12 @@ impl From> for Error { nom::Err::Error(c) => format!("{:?}", c), nom::Err::Failure(c) => format!("{:?}", c), }; - Error::from_string(&format!("Parsing error: {}", msg)) + Error::new(&format!("Parsing error: {}", msg)) } } impl From> for Error { fn from(error: std::sync::mpsc::SendError) -> Self { - Error::from_string(&format!("IO error: {}", error)) + Error::new(&format!("IO error: {}", error)) } }