From 778d5f2074b05c013e15fabc25daf4e37a174bf7 Mon Sep 17 00:00:00 2001 From: Clar Charr Date: Sat, 9 Sep 2017 16:48:40 -0400 Subject: [PATCH] Add Cow -> Box impls. --- src/libstd/error.rs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/libstd/error.rs b/src/libstd/error.rs index 401552a6ec417..6d64ea0d50332 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 { } } +#[stable(feature = "cow_box_error", since = "1.22.0")] +impl<'a, 'b> From> for Box { + fn from(err: Cow<'b, str>) -> Box { + From::from(String::from(err)) + } +} + +#[stable(feature = "cow_box_error", since = "1.22.0")] +impl<'a> From> for Box { + fn from(err: Cow<'a, str>) -> Box { + From::from(String::from(err)) + } +} + #[unstable(feature = "never_type_impls", issue = "35121")] impl Error for ! { fn description(&self) -> &str { *self }