From 8b719eefc0a772986dc33d6d9193c2cfd04b82f7 Mon Sep 17 00:00:00 2001 From: Kevin Butler Date: Thu, 2 Apr 2015 21:10:25 +0100 Subject: [PATCH] std: impl From for Box --- src/libstd/error.rs | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/libstd/error.rs b/src/libstd/error.rs index 150ffcdd77a..c9babeb3230 100644 --- a/src/libstd/error.rs +++ b/src/libstd/error.rs @@ -88,8 +88,8 @@ fn from(err: E) -> Box { } #[stable(feature = "rust1", since = "1.0.0")] -impl<'a, 'b> From<&'b str> for Box { - fn from(err: &'b str) -> Box { +impl From for Box { + fn from(err: String) -> Box { #[derive(Debug)] struct StringError(String); @@ -103,7 +103,14 @@ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { } } - Box::new(StringError(String::from_str(err))) + Box::new(StringError(err)) + } +} + +#[stable(feature = "rust1", since = "1.0.0")] +impl<'a, 'b> From<&'b str> for Box { + fn from(err: &'b str) -> Box { + From::from(String::from_str(err)) } }