diff options
| author | bors <bors@rust-lang.org> | 2017-09-29 22:35:23 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2017-09-29 22:35:23 +0000 |
| commit | b7041bfab3a83702a8026fb7a18d8ea7d54cc648 (patch) | |
| tree | 7f22fe35983186a4d48ea90d70c6461d11ef1269 /src/libcore/str | |
| parent | 6f87d20a7cce70b8cc59a1adf3037d14bc83f237 (diff) | |
| parent | 27d95d3645761252caf42c77fc53b76b4278520a (diff) | |
| download | rust-b7041bfab3a83702a8026fb7a18d8ea7d54cc648.tar.gz rust-b7041bfab3a83702a8026fb7a18d8ea7d54cc648.zip | |
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
Diffstat (limited to 'src/libcore/str')
| -rw-r--r-- | src/libcore/str/mod.rs | 7 |
1 files changed, 2 insertions, 5 deletions
diff --git a/src/libcore/str/mod.rs b/src/libcore/str/mod.rs index 62367b051fc..0af9fcf0a3d 100644 --- a/src/libcore/str/mod.rs +++ b/src/libcore/str/mod.rs @@ -18,7 +18,6 @@ use self::pattern::Pattern; use self::pattern::{Searcher, ReverseSearcher, DoubleEndedSearcher}; use char; -use convert::TryFrom; use fmt; use iter::{Map, Cloned, FusedIterator, TrustedLen}; use iter_private::TrustedRandomAccess; @@ -2198,7 +2197,7 @@ pub trait StrExt { #[stable(feature = "core", since = "1.6.0")] fn is_empty(&self) -> bool; #[stable(feature = "core", since = "1.6.0")] - fn parse<'a, T: TryFrom<&'a str>>(&'a self) -> Result<T, T::Error>; + fn parse<T: FromStr>(&self) -> Result<T, T::Err>; } // truncate `&str` to length at most equal to `max` @@ -2518,9 +2517,7 @@ impl StrExt for str { fn is_empty(&self) -> bool { self.len() == 0 } #[inline] - fn parse<'a, T>(&'a self) -> Result<T, T::Error> where T: TryFrom<&'a str> { - T::try_from(self) - } + fn parse<T: FromStr>(&self) -> Result<T, T::Err> { FromStr::from_str(self) } } #[stable(feature = "rust1", since = "1.0.0")] |
