about summary refs log tree commit diff
path: root/src/libcore
diff options
context:
space:
mode:
authorMazdak Farrokhzad <twingoow@gmail.com>2019-01-21 02:21:53 +0100
committerGitHub <noreply@github.com>2019-01-21 02:21:53 +0100
commitebc70e2e9ecdd0920c5e78f53ed694f1c050c5ed (patch)
tree7b5c2dc6e750f5f8e0e9ca86920761b95cc8e534 /src/libcore
parente73069767f11d992f0dca7e31d53d7e1a77fd237 (diff)
parentea68b3ff3dd5a49c5984c476570fb5404c342079 (diff)
downloadrust-ebc70e2e9ecdd0920c5e78f53ed694f1c050c5ed.tar.gz
rust-ebc70e2e9ecdd0920c5e78f53ed694f1c050c5ed.zip
Rollup merge of #56796 - KrishnaSannasi:try_from_impl_change, r=shepmaster
Change bounds on `TryFrom` blanket impl to use `Into` instead of `From`

This is from this [comment](https://github.com/rust-lang/rust/issues/33417#issuecomment-447111156) I made.

This will expand the impls available for `TryFrom` and `TryInto`, without losing anything in the process.
Diffstat (limited to 'src/libcore')
-rw-r--r--src/libcore/convert.rs4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/libcore/convert.rs b/src/libcore/convert.rs
index 08b5ac06f72..203be541e49 100644
--- a/src/libcore/convert.rs
+++ b/src/libcore/convert.rs
@@ -463,11 +463,11 @@ impl<T, U> TryInto<U> for T where U: TryFrom<T>
 // 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> {
+impl<T, U> TryFrom<U> for T where U: Into<T> {
     type Error = !;
 
     fn try_from(value: U) -> Result<Self, Self::Error> {
-        Ok(T::from(value))
+        Ok(U::into(value))
     }
 }