about summary refs log tree commit diff
path: root/src/libstd/error.rs
diff options
context:
space:
mode:
authorClar Charr <clar@charr.xyz>2017-09-09 16:48:40 -0400
committerClar Charr <clar@charr.xyz>2017-09-10 13:21:34 -0400
commit778d5f2074b05c013e15fabc25daf4e37a174bf7 (patch)
tree47e45b0b039f353cce58fb58acefbdef5ad6ab70 /src/libstd/error.rs
parent18366f4e8aaec1d46282cf0a6e0fe1a0ab202530 (diff)
downloadrust-778d5f2074b05c013e15fabc25daf4e37a174bf7.tar.gz
rust-778d5f2074b05c013e15fabc25daf4e37a174bf7.zip
Add Cow<str> -> Box<Error> impls.
Diffstat (limited to 'src/libstd/error.rs')
-rw-r--r--src/libstd/error.rs15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/libstd/error.rs b/src/libstd/error.rs
index 401552a6ec4..6d64ea0d503 100644
--- a/src/libstd/error.rs
+++ b/src/libstd/error.rs
@@ -53,6 +53,7 @@
 
 use alloc::allocator;
 use any::TypeId;
+use borrow::Cow;
 use cell;
 use char;
 use fmt::{self, Debug, Display};
@@ -217,6 +218,20 @@ impl<'a> From<&'a str> for Box<Error> {
     }
 }
 
+#[stable(feature = "cow_box_error", since = "1.22.0")]
+impl<'a, 'b> From<Cow<'b, str>> for Box<Error + Send + Sync + 'a> {
+    fn from(err: Cow<'b, str>) -> Box<Error + Send + Sync + 'a> {
+        From::from(String::from(err))
+    }
+}
+
+#[stable(feature = "cow_box_error", since = "1.22.0")]
+impl<'a> From<Cow<'a, str>> for Box<Error> {
+    fn from(err: Cow<'a, str>) -> Box<Error> {
+        From::from(String::from(err))
+    }
+}
+
 #[unstable(feature = "never_type_impls", issue = "35121")]
 impl Error for ! {
     fn description(&self) -> &str { *self }