Add Cow<str> -> Box<Error> impls.
This commit is contained in:
@@ -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 }
|
||||
|
||||
Reference in New Issue
Block a user