Auto merge of #44174 - jimmycuadra:try-from-infallible, r=sfackler
Add blanket TryFrom impl when From is implemented. Adds `impl<T, U> TryFrom<T> for U where U: From<T>`. Removes `impl<'a, T> TryFrom<&'a str> for T where T: FromStr` (originally added in #40281) due to overlapping impls caused by the new blanket impl. This removal is to be discussed further on the tracking issue for TryFrom. Refs #33417. /cc @sfackler, @scottmcm (thank you for the help!), and @aturon
This commit is contained in:
commit
b7041bfab3
7 changed files with 71 additions and 48 deletions
|
|
@ -56,6 +56,7 @@ use any::TypeId;
|
|||
use borrow::Cow;
|
||||
use cell;
|
||||
use char;
|
||||
use convert;
|
||||
use fmt::{self, Debug, Display};
|
||||
use mem::transmute;
|
||||
use num;
|
||||
|
|
@ -362,6 +363,13 @@ impl Error for char::ParseCharError {
|
|||
}
|
||||
}
|
||||
|
||||
#[unstable(feature = "try_from", issue = "33417")]
|
||||
impl Error for convert::Infallible {
|
||||
fn description(&self) -> &str {
|
||||
match *self {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// copied from any.rs
|
||||
impl Error + 'static {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue