Skip to content

Commit 31121cb

Browse files
authored
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
2 parents e2e29de + d2fe7a7 commit 31121cb

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

src/libcore/convert/mod.rs

+7-4
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,9 @@
1818
//! [`TryFrom<T>`][`TryFrom`] rather than [`Into<U>`][`Into`] or [`TryInto<U>`][`TryInto`],
1919
//! as [`From`] and [`TryFrom`] provide greater flexibility and offer
2020
//! equivalent [`Into`] or [`TryInto`] implementations for free, thanks to a
21-
//! blanket implementation in the standard library. Only implement [`Into`] or [`TryInto`]
22-
//! when a conversion to a type outside the current crate is required.
21+
//! blanket implementation in the standard library. When targeting a version prior to Rust 1.41, it
22+
//! may be necessary to implement [`Into`] or [`TryInto`] directly when converting to a type
23+
//! outside the current crate.
2324
//!
2425
//! # Generic Implementations
2526
//!
@@ -298,8 +299,10 @@ pub trait Into<T>: Sized {
298299
/// because implementing `From` automatically provides one with an implementation of [`Into`]
299300
/// thanks to the blanket implementation in the standard library.
300301
///
301-
/// Only implement [`Into`] if a conversion to a type outside the current crate is required.
302-
/// `From` cannot do these type of conversions because of Rust's orphaning rules.
302+
/// Only implement [`Into`] when targeting a version prior to Rust 1.41 and converting to a type
303+
/// outside the current crate.
304+
/// `From` was not able to do these types of conversions in earlier versions because of Rust's
305+
/// orphaning rules.
303306
/// See [`Into`] for more details.
304307
///
305308
/// Prefer using [`Into`] over using `From` when specifying trait bounds on a generic function.

0 commit comments

Comments
 (0)