|
18 | 18 | //! support arguments of multiple types.
|
19 | 19 | //!
|
20 | 20 | //! - Impl the `As*` traits for reference-to-reference conversions
|
21 |
| -//! - Impl the `Into` trait when you want to consume the value in the conversion |
22 |
| -//! - The `From` trait is the most flexible, useful for value _and_ reference conversions |
23 |
| -//! - The `TryFrom` and `TryInto` traits behave like `From` and `Into`, but allow for the |
| 21 | +//! - Impl the [`Into`] trait when you want to consume the value in the conversion |
| 22 | +//! - The [`From`] trait is the most flexible, useful for value _and_ reference conversions |
| 23 | +//! - The [`TryFrom`] and [`TryInto`] traits behave like [`From`] and [`Into`], but allow for the |
24 | 24 | //! conversion to fail
|
25 | 25 | //!
|
26 |
| -//! As a library author, you should prefer implementing `From<T>` or `TryFrom<T>` rather than |
27 |
| -//! `Into<U>` or `TryInto<U>`, as `From` and `TryFrom` provide greater flexibility and offer |
28 |
| -//! equivalent `Into` or `TryInto` implementations for free, thanks to a blanket implementation |
| 26 | +//! As a library author, you should prefer implementing [`From<T>`][`From`] or |
| 27 | +//! [`TryFrom<T>`][`TryFrom`] rather than [`Into<U>`][`Into`] or [`TryInto<U>`][`TryInto`], |
| 28 | +//! as [`From`] and [`TryFrom`] provide greater flexibility and offer |
| 29 | +//! equivalent [`Into`] or [`TryInto`] implementations for free, thanks to a blanket implementation |
29 | 30 | //! in the standard library.
|
30 | 31 | //!
|
31 | 32 | //! # Generic impl
|
32 | 33 | //!
|
33 |
| -//! - `AsRef` and `AsMut` auto-dereference if the inner type is a reference |
34 |
| -//! - `From<U> for T` implies `Into<T> for U` |
35 |
| -//! - `TryFrom<U> for T` implies `TryInto<T> for U` |
36 |
| -//! - `From` and `Into` are reflexive, which means that all types can `into()` |
| 34 | +//! - [`AsRef`] and [`AsMut`] auto-dereference if the inner type is a reference |
| 35 | +//! - [`From`]`<U> for T` implies [`Into`]`<T> for U` |
| 36 | +//! - [`TryFrom`]`<U> for T` implies [`TryInto`]`<T> for U` |
| 37 | +//! - [`From`] and [`Into`] are reflexive, which means that all types can `into()` |
37 | 38 | //! themselves and `from()` themselves
|
38 | 39 | //!
|
39 | 40 | //! See each trait for usage examples.
|
| 41 | +//! |
| 42 | +//! [`Into`]: trait.Into.html |
| 43 | +//! [`From`]: trait.From.html |
| 44 | +//! [`TryFrom`]: trait.TryFrom.html |
| 45 | +//! [`TryInto`]: trait.TryInto.html |
| 46 | +//! [`AsRef`]: trait.AsRef.html |
| 47 | +//! [`AsMut`]: trait.AsMut.html |
40 | 48 |
|
41 | 49 | #![stable(feature = "rust1", since = "1.0.0")]
|
42 | 50 |
|
|
0 commit comments