diff --git a/src/libcore/convert.rs b/src/libcore/convert.rs index 8e7e2abfc1e17..5191cd7601064 100644 --- a/src/libcore/convert.rs +++ b/src/libcore/convert.rs @@ -42,17 +42,23 @@ /// A cheap, reference-to-reference conversion. /// -/// `AsRef` is very similar to, but different than, `Borrow`. See +/// `AsRef` is very similar to, but different than, [`Borrow`]. See /// [the book][book] for more. /// /// [book]: ../../book/borrow-and-asref.html +/// [`Borrow`]: ../../std/borrow/trait.Borrow.html /// /// **Note: this trait must not fail**. If the conversion can fail, use a dedicated method which -/// returns an `Option` or a `Result`. +/// returns an [`Option`] or a [`Result`]. +/// +/// [`Option`]: ../../std/option/enum.Option.html +/// [`Result`]: ../../std/result/enum.Result.html /// /// # Examples /// -/// Both `String` and `&str` implement `AsRef`: +/// Both [`String`] and `&str` implement `AsRef`: +/// +/// [`String`]: ../../std/string/struct.String.html /// /// ``` /// fn is_hello>(s: T) { @@ -81,7 +87,10 @@ pub trait AsRef { /// A cheap, mutable reference-to-mutable reference conversion. /// /// **Note: this trait must not fail**. If the conversion can fail, use a dedicated method which -/// returns an `Option` or a `Result`. +/// returns an [`Option`] or a [`Result`]. +/// +/// [`Option`]: ../../std/option/enum.Option.html +/// [`Result`]: ../../std/result/enum.Result.html /// /// # Generic Impls /// @@ -97,16 +106,16 @@ pub trait AsMut { /// A conversion that consumes `self`, which may or may not be expensive. /// -/// **Note: this trait must not fail**. If the conversion can fail, use `TryInto` or a dedicated -/// method which returns an `Option` or a `Result`. +/// **Note: this trait must not fail**. If the conversion can fail, use [`TryInto`] or a dedicated +/// method which returns an [`Option`] or a [`Result`]. /// /// Library authors should not directly implement this trait, but should prefer implementing -/// the `From` trait, which offers greater flexibility and provides an equivalent `Into` +/// the [`From`][From] trait, which offers greater flexibility and provides an equivalent `Into` /// implementation for free, thanks to a blanket implementation in the standard library. /// /// # Examples /// -/// `String` implements `Into>`: +/// [`String`] implements `Into>`: /// /// ``` /// fn is_hello>>(s: T) { @@ -120,9 +129,15 @@ pub trait AsMut { /// /// # Generic Impls /// -/// - `From for U` implies `Into for T` -/// - `into()` is reflexive, which means that `Into for T` is implemented +/// - `[From][From] for U` implies `Into for T` +/// - [`into()`] is reflexive, which means that `Into for T` is implemented /// +/// [`TryInto`]: trait.TryInto.html +/// [`Option`]: ../../std/option/enum.Option.html +/// [`Result`]: ../../std/result/enum.Result.html +/// [`String`]: ../../std/string/struct.String.html +/// [From]: trait.From.html +/// [`into()`]: trait.Into.html#tymethod.into #[stable(feature = "rust1", since = "1.0.0")] pub trait Into: Sized { /// Performs the conversion. @@ -132,12 +147,12 @@ pub trait Into: Sized { /// Construct `Self` via a conversion. /// -/// **Note: this trait must not fail**. If the conversion can fail, use `TryFrom` or a dedicated -/// method which returns an `Option` or a `Result`. +/// **Note: this trait must not fail**. If the conversion can fail, use [`TryFrom`] or a dedicated +/// method which returns an [`Option`] or a [`Result`]. /// /// # Examples /// -/// `String` implements `From<&str>`: +/// [`String`] implements `From<&str>`: /// /// ``` /// let string = "hello".to_string(); @@ -147,9 +162,15 @@ pub trait Into: Sized { /// ``` /// # Generic impls /// -/// - `From for U` implies `Into for T` -/// - `from()` is reflexive, which means that `From for T` is implemented +/// - `From for U` implies `[Into] for T` +/// - [`from()`] is reflexive, which means that `From for T` is implemented /// +/// [`TryFrom`]: trait.TryFrom.html +/// [`Option`]: ../../std/option/enum.Option.html +/// [`Result`]: ../../std/result/enum.Result.html +/// [`String`]: ../../std/string/struct.String.html +/// [Into]: trait.Into.html +/// [`from()`]: trait.From.html#tymethod.from #[stable(feature = "rust1", since = "1.0.0")] pub trait From: Sized { /// Performs the conversion. @@ -160,8 +181,10 @@ pub trait From: Sized { /// An attempted conversion that consumes `self`, which may or may not be expensive. /// /// Library authors should not directly implement this trait, but should prefer implementing -/// the `TryFrom` trait, which offers greater flexibility and provides an equivalent `TryInto` +/// the [`TryFrom`] trait, which offers greater flexibility and provides an equivalent `TryInto` /// implementation for free, thanks to a blanket implementation in the standard library. +/// +/// [`TryFrom`]: trait.TryFrom.html #[unstable(feature = "try_from", issue = "33417")] pub trait TryInto: Sized { /// The type returned in the event of a conversion error.