Skip to content

Instantly share code, notes, and snippets.

@jimmycuadra
Created August 30, 2017 02:24
Show Gist options
  • Save jimmycuadra/f59871d00741a8445f17419485d0ba29 to your computer and use it in GitHub Desktop.
Save jimmycuadra/f59871d00741a8445f17419485d0ba29 to your computer and use it in GitHub Desktop.
error[E0119]: conflicting implementations of trait `convert::TryFrom<&str>`:
--> src/libcore/convert.rs:469:1
|
433 | / impl<T, U> TryFrom<U> for T where T: From<U> {
434 | | type Error = Infallible;
435 | |
436 | | fn try_from(value: U) -> Result<Self, Self::Error> {
437 | | Ok(T::from(value))
438 | | }
439 | | }
| |_- first implementation here
...
469 | / impl<'a, T> TryFrom<&'a str> for T where T: FromStr
470 | | {
471 | | type Error = <T as FromStr>::Err;
472 | |
... |
475 | | }
476 | | }
| |_^ conflicting implementation
// Infallible conversions are semantically equivalent to fallible conversions
// with an uninhabited error type.
#[unstable(feature = "try_from", issue = "33417")]
impl<T, U> TryFrom<U> for T where T: From<U> {
type Error = Infallible;
fn try_from(value: U) -> Result<Self, Self::Error> {
Ok(T::from(value))
}
}
// FromStr implies TryFrom<&str>
#[unstable(feature = "try_from", issue = "33417")]
impl<'a, T> TryFrom<&'a str> for T where T: FromStr
{
type Error = <T as FromStr>::Err;
fn try_from(s: &'a str) -> Result<T, Self::Error> {
FromStr::from_str(s)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment