diff options
| author | Mark Rousskov <mark.simulacrum@gmail.com> | 2019-07-03 09:59:15 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-07-03 09:59:15 -0400 |
| commit | d9dfed8ca2edfcc2a845eca35f12c085fb3fb20f (patch) | |
| tree | c0bd2532bc98f24e4db8b4ace3f8fd7644c1db9a /src/libcore | |
| parent | 25640092c7ca5f0e980d24f2024fab8dd4ae718e (diff) | |
| parent | dfb9f5be30c7fefbe4458fb873c2bdc0604f9a17 (diff) | |
| download | rust-d9dfed8ca2edfcc2a845eca35f12c085fb3fb20f.tar.gz rust-d9dfed8ca2edfcc2a845eca35f12c085fb3fb20f.zip | |
Rollup merge of #62161 - GuillaumeGomez:add-missing-tryfrom-links, r=docs
Add missing links for TryFrom docs r? @rust-lang/docs
Diffstat (limited to 'src/libcore')
| -rw-r--r-- | src/libcore/convert.rs | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/src/libcore/convert.rs b/src/libcore/convert.rs index a697b7bd6e5..34d19748e56 100644 --- a/src/libcore/convert.rs +++ b/src/libcore/convert.rs @@ -410,12 +410,12 @@ pub trait TryInto<T>: Sized { /// /// This is useful when you are doing a type conversion that may /// trivially succeed but may also need special handling. -/// For example, there is no way to convert an `i64` into an `i32` -/// using the [`From`] trait, because an `i64` may contain a value -/// that an `i32` cannot represent and so the conversion would lose data. -/// This might be handled by truncating the `i64` to an `i32` (essentially -/// giving the `i64`'s value modulo `i32::MAX`) or by simply returning -/// `i32::MAX`, or by some other method. The `From` trait is intended +/// For example, there is no way to convert an [`i64`] into an [`i32`] +/// using the [`From`] trait, because an [`i64`] may contain a value +/// that an [`i32`] cannot represent and so the conversion would lose data. +/// This might be handled by truncating the [`i64`] to an [`i32`] (essentially +/// giving the [`i64`]'s value modulo [`i32::MAX`]) or by simply returning +/// [`i32::MAX`], or by some other method. The [`From`] trait is intended /// for perfect conversions, so the `TryFrom` trait informs the /// programmer when a type conversion could go bad and lets them /// decide how to handle it. @@ -425,8 +425,8 @@ pub trait TryInto<T>: Sized { /// - `TryFrom<T> for U` implies [`TryInto`]`<U> for T` /// - [`try_from`] is reflexive, which means that `TryFrom<T> for T` /// is implemented and cannot fail -- the associated `Error` type for -/// calling `T::try_from()` on a value of type `T` is `Infallible`. -/// When the `!` type is stablized `Infallible` and `!` will be +/// calling `T::try_from()` on a value of type `T` is [`Infallible`]. +/// When the [`!`] type is stablized [`Infallible`] and [`!`] will be /// equivalent. /// /// `TryFrom<T>` can be implemented as follows: @@ -451,7 +451,7 @@ pub trait TryInto<T>: Sized { /// /// # Examples /// -/// As described, [`i32`] implements `TryFrom<i64>`: +/// As described, [`i32`] implements `TryFrom<`[`i64`]`>`: /// /// ``` /// use std::convert::TryFrom; @@ -474,6 +474,8 @@ pub trait TryInto<T>: Sized { /// /// [`try_from`]: trait.TryFrom.html#tymethod.try_from /// [`TryInto`]: trait.TryInto.html +/// [`i32::MAX`]: ../../std/i32/constant.MAX.html +/// [`!`]: ../../std/primitive.never.html #[stable(feature = "try_from", since = "1.34.0")] pub trait TryFrom<T>: Sized { /// The type returned in the event of a conversion error. |
