Skip to content

Commit b712f74

Browse files
Add missing urls into convert module
1 parent e4791e0 commit b712f74

File tree

1 file changed

+39
-16
lines changed

1 file changed

+39
-16
lines changed

src/libcore/convert.rs

+39-16
Original file line numberDiff line numberDiff line change
@@ -42,17 +42,23 @@
4242

4343
/// A cheap, reference-to-reference conversion.
4444
///
45-
/// `AsRef` is very similar to, but different than, `Borrow`. See
45+
/// `AsRef` is very similar to, but different than, [`Borrow`]. See
4646
/// [the book][book] for more.
4747
///
4848
/// [book]: ../../book/borrow-and-asref.html
49+
/// [`Borrow`]: ../../std/borrow/trait.Borrow.html
4950
///
5051
/// **Note: this trait must not fail**. If the conversion can fail, use a dedicated method which
51-
/// returns an `Option<T>` or a `Result<T, E>`.
52+
/// returns an [`Option<T>`] or a [`Result<T, E>`].
53+
///
54+
/// [`Option<T>`]: ../../std/option/enum.Option.html
55+
/// [`Result<T, E>`]: ../../std/result/enum.Result.html
5256
///
5357
/// # Examples
5458
///
55-
/// Both `String` and `&str` implement `AsRef<str>`:
59+
/// Both [`String`] and `&str` implement `AsRef<str>`:
60+
///
61+
/// [`String`]: ../../std/string/struct.String.html
5662
///
5763
/// ```
5864
/// fn is_hello<T: AsRef<str>>(s: T) {
@@ -81,7 +87,10 @@ pub trait AsRef<T: ?Sized> {
8187
/// A cheap, mutable reference-to-mutable reference conversion.
8288
///
8389
/// **Note: this trait must not fail**. If the conversion can fail, use a dedicated method which
84-
/// returns an `Option<T>` or a `Result<T, E>`.
90+
/// returns an [`Option<T>`] or a [`Result<T, E>`].
91+
///
92+
/// [`Option<T>`]: ../../std/option/enum.Option.html
93+
/// [`Result<T, E>`]: ../../std/result/enum.Result.html
8594
///
8695
/// # Generic Impls
8796
///
@@ -97,16 +106,16 @@ pub trait AsMut<T: ?Sized> {
97106

98107
/// A conversion that consumes `self`, which may or may not be expensive.
99108
///
100-
/// **Note: this trait must not fail**. If the conversion can fail, use `TryInto` or a dedicated
101-
/// method which returns an `Option<T>` or a `Result<T, E>`.
109+
/// **Note: this trait must not fail**. If the conversion can fail, use [`TryInto`] or a dedicated
110+
/// method which returns an [`Option<T>`] or a [`Result<T, E>`].
102111
///
103112
/// Library authors should not directly implement this trait, but should prefer implementing
104-
/// the `From` trait, which offers greater flexibility and provides an equivalent `Into`
113+
/// the [`From`][From] trait, which offers greater flexibility and provides an equivalent `Into`
105114
/// implementation for free, thanks to a blanket implementation in the standard library.
106115
///
107116
/// # Examples
108117
///
109-
/// `String` implements `Into<Vec<u8>>`:
118+
/// [`String`] implements `Into<Vec<u8>>`:
110119
///
111120
/// ```
112121
/// fn is_hello<T: Into<Vec<u8>>>(s: T) {
@@ -120,9 +129,15 @@ pub trait AsMut<T: ?Sized> {
120129
///
121130
/// # Generic Impls
122131
///
123-
/// - `From<T> for U` implies `Into<U> for T`
124-
/// - `into()` is reflexive, which means that `Into<T> for T` is implemented
132+
/// - `[From<T>][From] for U` implies `Into<U> for T`
133+
/// - [`into()`] is reflexive, which means that `Into<T> for T` is implemented
125134
///
135+
/// [`TryInto`]: trait.TryInto.html
136+
/// [`Option<T>`]: ../../std/option/enum.Option.html
137+
/// [`Result<T, E>`]: ../../std/result/enum.Result.html
138+
/// [`String`]: ../../std/string/struct.String.html
139+
/// [From]: trait.From.html
140+
/// [`into()`]: trait.Into.html#tymethod.into
126141
#[stable(feature = "rust1", since = "1.0.0")]
127142
pub trait Into<T>: Sized {
128143
/// Performs the conversion.
@@ -132,12 +147,12 @@ pub trait Into<T>: Sized {
132147

133148
/// Construct `Self` via a conversion.
134149
///
135-
/// **Note: this trait must not fail**. If the conversion can fail, use `TryFrom` or a dedicated
136-
/// method which returns an `Option<T>` or a `Result<T, E>`.
150+
/// **Note: this trait must not fail**. If the conversion can fail, use [`TryFrom`] or a dedicated
151+
/// method which returns an [`Option<T>`] or a [`Result<T, E>`].
137152
///
138153
/// # Examples
139154
///
140-
/// `String` implements `From<&str>`:
155+
/// [`String`] implements `From<&str>`:
141156
///
142157
/// ```
143158
/// let string = "hello".to_string();
@@ -147,9 +162,15 @@ pub trait Into<T>: Sized {
147162
/// ```
148163
/// # Generic impls
149164
///
150-
/// - `From<T> for U` implies `Into<U> for T`
151-
/// - `from()` is reflexive, which means that `From<T> for T` is implemented
165+
/// - `From<T> for U` implies `[Into<U>] for T`
166+
/// - [`from()`] is reflexive, which means that `From<T> for T` is implemented
152167
///
168+
/// [`TryFrom`]: trait.TryFrom.html
169+
/// [`Option<T>`]: ../../std/option/enum.Option.html
170+
/// [`Result<T, E>`]: ../../std/result/enum.Result.html
171+
/// [`String`]: ../../std/string/struct.String.html
172+
/// [Into<U>]: trait.Into.html
173+
/// [`from()`]: trait.From.html#tymethod.from
153174
#[stable(feature = "rust1", since = "1.0.0")]
154175
pub trait From<T>: Sized {
155176
/// Performs the conversion.
@@ -160,8 +181,10 @@ pub trait From<T>: Sized {
160181
/// An attempted conversion that consumes `self`, which may or may not be expensive.
161182
///
162183
/// Library authors should not directly implement this trait, but should prefer implementing
163-
/// the `TryFrom` trait, which offers greater flexibility and provides an equivalent `TryInto`
184+
/// the [`TryFrom`] trait, which offers greater flexibility and provides an equivalent `TryInto`
164185
/// implementation for free, thanks to a blanket implementation in the standard library.
186+
///
187+
/// [`TryFrom`]: trait.TryFrom.html
165188
#[unstable(feature = "try_from", issue = "33417")]
166189
pub trait TryInto<T>: Sized {
167190
/// The type returned in the event of a conversion error.

0 commit comments

Comments
 (0)