]> git.lizzy.rs Git - rust.git/commitdiff
std: impl From<String> for Box<Error + Send>
authorKevin Butler <haqkrs@gmail.com>
Thu, 2 Apr 2015 20:10:25 +0000 (21:10 +0100)
committerKevin Butler <haqkrs@gmail.com>
Thu, 2 Apr 2015 20:10:25 +0000 (21:10 +0100)
src/libstd/error.rs

index 150ffcdd77a9f3ef523b5c07a5d7d89060a67136..c9babeb32301ada23125b1e610d2c215c13d37ea 100644 (file)
@@ -88,8 +88,8 @@ fn from(err: E) -> Box<Error + Send + 'a> {
 }
 
 #[stable(feature = "rust1", since = "1.0.0")]
-impl<'a, 'b> From<&'b str> for Box<Error + Send + 'a> {
-    fn from(err: &'b str) -> Box<Error + Send + 'a> {
+impl From<String> for Box<Error + Send> {
+    fn from(err: String) -> Box<Error + Send> {
         #[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<Error + Send + 'a> {
+    fn from(err: &'b str) -> Box<Error + Send + 'a> {
+        From::from(String::from_str(err))
     }
 }