diff options
| author | Manish Goregaokar <manishsmail@gmail.com> | 2020-07-16 00:01:02 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-07-16 00:01:02 -0700 |
| commit | 31121cbec3a341cfc7b2823f30e8a52c11b06047 (patch) | |
| tree | 672736dc2367fb80253bec7a71e5063a347c830a /src/libcore | |
| parent | e2e29de5e8a2908260d54182638241ff086a26c2 (diff) | |
| parent | d2fe7a7c761d625051a875e320b6e50fe7e33c41 (diff) | |
Rollup merge of #73421 - janikrabe:master, r=joshtriplett
Clarify effect of orphan rule changes on From/Into Updated documentation for `std::convert` and `std::convert::From` to reflect changes to orphan rule in Rust 1.41. It should no longer be necessary to implement `Into` directly, unless targeting an older version. r? @steveklabnik
Diffstat (limited to 'src/libcore')
| -rw-r--r-- | src/libcore/convert/mod.rs | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/src/libcore/convert/mod.rs b/src/libcore/convert/mod.rs index 8ff1ced53b0..94f7ff5c1f7 100644 --- a/src/libcore/convert/mod.rs +++ b/src/libcore/convert/mod.rs @@ -18,8 +18,9 @@ //! [`TryFrom<T>`][`TryFrom`] rather than [`Into<U>`][`Into`] or [`TryInto<U>`][`TryInto`], //! as [`From`] and [`TryFrom`] provide greater flexibility and offer //! equivalent [`Into`] or [`TryInto`] implementations for free, thanks to a -//! blanket implementation in the standard library. Only implement [`Into`] or [`TryInto`] -//! when a conversion to a type outside the current crate is required. +//! blanket implementation in the standard library. When targeting a version prior to Rust 1.41, it +//! may be necessary to implement [`Into`] or [`TryInto`] directly when converting to a type +//! outside the current crate. //! //! # Generic Implementations //! @@ -298,8 +299,10 @@ pub trait Into<T>: Sized { /// because implementing `From` automatically provides one with an implementation of [`Into`] /// thanks to the blanket implementation in the standard library. /// -/// Only implement [`Into`] if a conversion to a type outside the current crate is required. -/// `From` cannot do these type of conversions because of Rust's orphaning rules. +/// Only implement [`Into`] when targeting a version prior to Rust 1.41 and converting to a type +/// outside the current crate. +/// `From` was not able to do these types of conversions in earlier versions because of Rust's +/// orphaning rules. /// See [`Into`] for more details. /// /// Prefer using [`Into`] over using `From` when specifying trait bounds on a generic function. |
