Skip to content

Commit ac71a7f

Browse files
authored
Rollup merge of rust-lang#63999 - GuillaumeGomez:as-ref-missing-links, r=Mark-Simulacrum
Add missing links on AsRef trait cc @rust-lang/docs
2 parents 5f07ff7 + 0e74246 commit ac71a7f

File tree

1 file changed

+13
-11
lines changed

1 file changed

+13
-11
lines changed

src/libcore/convert.rs

+13-11
Original file line numberDiff line numberDiff line change
@@ -104,22 +104,17 @@ pub const fn identity<T>(x: T) -> T { x }
104104
/// If you need to do a costly conversion it is better to implement [`From`] with type
105105
/// `&T` or write a custom function.
106106
///
107-
/// `AsRef` has the same signature as [`Borrow`], but `Borrow` is different in few aspects:
107+
/// `AsRef` has the same signature as [`Borrow`], but [`Borrow`] is different in few aspects:
108108
///
109-
/// - Unlike `AsRef`, `Borrow` has a blanket impl for any `T`, and can be used to accept either
109+
/// - Unlike `AsRef`, [`Borrow`] has a blanket impl for any `T`, and can be used to accept either
110110
/// a reference or a value.
111-
/// - `Borrow` also requires that `Hash`, `Eq` and `Ord` for borrowed value are
111+
/// - [`Borrow`] also requires that [`Hash`], [`Eq`] and [`Ord`] for borrowed value are
112112
/// equivalent to those of the owned value. For this reason, if you want to
113-
/// borrow only a single field of a struct you can implement `AsRef`, but not `Borrow`.
114-
///
115-
/// [`Borrow`]: ../../std/borrow/trait.Borrow.html
113+
/// borrow only a single field of a struct you can implement `AsRef`, but not [`Borrow`].
116114
///
117115
/// **Note: This trait must not fail**. If the conversion can fail, use a
118116
/// dedicated method which returns an [`Option<T>`] or a [`Result<T, E>`].
119117
///
120-
/// [`Option<T>`]: ../../std/option/enum.Option.html
121-
/// [`Result<T, E>`]: ../../std/result/enum.Result.html
122-
///
123118
/// # Generic Implementations
124119
///
125120
/// - `AsRef` auto-dereferences if the inner type is a reference or a mutable
@@ -132,9 +127,16 @@ pub const fn identity<T>(x: T) -> T { x }
132127
/// converted to the specified type `T`.
133128
///
134129
/// For example: By creating a generic function that takes an `AsRef<str>` we express that we
135-
/// want to accept all references that can be converted to `&str` as an argument.
136-
/// Since both [`String`] and `&str` implement `AsRef<str>` we can accept both as input argument.
130+
/// want to accept all references that can be converted to [`&str`] as an argument.
131+
/// Since both [`String`] and [`&str`] implement `AsRef<str>` we can accept both as input argument.
137132
///
133+
/// [`Option<T>`]: ../../std/option/enum.Option.html
134+
/// [`Result<T, E>`]: ../../std/result/enum.Result.html
135+
/// [`Borrow`]: ../../std/borrow/trait.Borrow.html
136+
/// [`Hash`]: ../../std/hash/trait.Hash.html
137+
/// [`Eq`]: ../../std/cmp/trait.Eq.html
138+
/// [`Ord`]: ../../std/cmp/trait.Ord.html
139+
/// [`&str`]: ../../std/primitive.str.html
138140
/// [`String`]: ../../std/string/struct.String.html
139141
///
140142
/// ```

0 commit comments

Comments
 (0)