Skip to content

Commit 2d0c1d4

Browse files
Rollup merge of rust-lang#62161 - GuillaumeGomez:add-missing-tryfrom-links, r=docs
Add missing links for TryFrom docs r? @rust-lang/docs
2 parents a1c1d11 + dfb9f5b commit 2d0c1d4

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

src/libcore/convert.rs

+11-9
Original file line numberDiff line numberDiff line change
@@ -410,12 +410,12 @@ pub trait TryInto<T>: Sized {
410410
///
411411
/// This is useful when you are doing a type conversion that may
412412
/// trivially succeed but may also need special handling.
413-
/// For example, there is no way to convert an `i64` into an `i32`
414-
/// using the [`From`] trait, because an `i64` may contain a value
415-
/// that an `i32` cannot represent and so the conversion would lose data.
416-
/// This might be handled by truncating the `i64` to an `i32` (essentially
417-
/// giving the `i64`'s value modulo `i32::MAX`) or by simply returning
418-
/// `i32::MAX`, or by some other method. The `From` trait is intended
413+
/// For example, there is no way to convert an [`i64`] into an [`i32`]
414+
/// using the [`From`] trait, because an [`i64`] may contain a value
415+
/// that an [`i32`] cannot represent and so the conversion would lose data.
416+
/// This might be handled by truncating the [`i64`] to an [`i32`] (essentially
417+
/// giving the [`i64`]'s value modulo [`i32::MAX`]) or by simply returning
418+
/// [`i32::MAX`], or by some other method. The [`From`] trait is intended
419419
/// for perfect conversions, so the `TryFrom` trait informs the
420420
/// programmer when a type conversion could go bad and lets them
421421
/// decide how to handle it.
@@ -425,8 +425,8 @@ pub trait TryInto<T>: Sized {
425425
/// - `TryFrom<T> for U` implies [`TryInto`]`<U> for T`
426426
/// - [`try_from`] is reflexive, which means that `TryFrom<T> for T`
427427
/// is implemented and cannot fail -- the associated `Error` type for
428-
/// calling `T::try_from()` on a value of type `T` is `Infallible`.
429-
/// When the `!` type is stablized `Infallible` and `!` will be
428+
/// calling `T::try_from()` on a value of type `T` is [`Infallible`].
429+
/// When the [`!`] type is stablized [`Infallible`] and [`!`] will be
430430
/// equivalent.
431431
///
432432
/// `TryFrom<T>` can be implemented as follows:
@@ -451,7 +451,7 @@ pub trait TryInto<T>: Sized {
451451
///
452452
/// # Examples
453453
///
454-
/// As described, [`i32`] implements `TryFrom<i64>`:
454+
/// As described, [`i32`] implements `TryFrom<`[`i64`]`>`:
455455
///
456456
/// ```
457457
/// use std::convert::TryFrom;
@@ -474,6 +474,8 @@ pub trait TryInto<T>: Sized {
474474
///
475475
/// [`try_from`]: trait.TryFrom.html#tymethod.try_from
476476
/// [`TryInto`]: trait.TryInto.html
477+
/// [`i32::MAX`]: ../../std/i32/constant.MAX.html
478+
/// [`!`]: ../../std/primitive.never.html
477479
#[stable(feature = "try_from", since = "1.34.0")]
478480
pub trait TryFrom<T>: Sized {
479481
/// The type returned in the event of a conversion error.

0 commit comments

Comments
 (0)