From dfb9f5be30c7fefbe4458fb873c2bdc0604f9a17 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Sat, 29 Jun 2019 22:24:32 +0200 Subject: [PATCH] Add missing links for TryFrom docs --- src/libcore/convert.rs | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/src/libcore/convert.rs b/src/libcore/convert.rs index a697b7bd6e589..34d19748e5609 100644 --- a/src/libcore/convert.rs +++ b/src/libcore/convert.rs @@ -410,12 +410,12 @@ pub trait TryInto: 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: Sized { /// - `TryFrom for U` implies [`TryInto`]` for T` /// - [`try_from`] is reflexive, which means that `TryFrom 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` can be implemented as follows: @@ -451,7 +451,7 @@ pub trait TryInto: Sized { /// /// # Examples /// -/// As described, [`i32`] implements `TryFrom`: +/// As described, [`i32`] implements `TryFrom<`[`i64`]`>`: /// /// ``` /// use std::convert::TryFrom; @@ -474,6 +474,8 @@ pub trait TryInto: 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: Sized { /// The type returned in the event of a conversion error.