@@ -146,8 +146,9 @@ pub const fn identity<T>(x: T) -> T {
146
146
/// let y: &i32 = &x;
147
147
/// ```
148
148
///
149
- /// Types which implement [`Deref`][core::ops::Deref] should consider implementing `AsRef` as
150
- /// follows:
149
+ /// Types which implement [`Deref`] should consider implementing `AsRef<T>` as follows:
150
+ ///
151
+ /// [`Deref`]: core::ops::Deref
151
152
///
152
153
/// ```
153
154
/// # use core::ops::Deref;
@@ -172,12 +173,14 @@ pub const fn identity<T>(x: T) -> T {
172
173
/// # Reflexivity
173
174
///
174
175
/// Ideally, `AsRef` would be reflexive, that is there is an `impl<T: ?Sized> AsRef<T> for T`, with
175
- /// [`as_ref`][AsRef::as_ref] simply returning its argument unchanged.
176
+ /// [`as_ref`] simply returning its argument unchanged.
176
177
/// Such a blanket implementation is currently *not* provided due to technical restrictions of
177
178
/// Rust's type system (it would be overlapping with another existing blanket implementation for
178
179
/// `&T where T: AsRef<U>` which allows `AsRef` to auto-dereference, see "Generic Implementations"
179
180
/// above).
180
181
///
182
+ /// [`as_ref`]: AsRef::as_ref
183
+ ///
181
184
/// A trivial implementation of `AsRef<T> for T` must be added explicitly for a particular type `T`
182
185
/// where needed or desired. Note, however, that not all types from `std` contain such an
183
186
/// implementation, and those cannot be added by external code due to orphan rules.
@@ -249,8 +252,10 @@ pub trait AsRef<T: ?Sized> {
249
252
/// let y: &mut i32 = &mut x;
250
253
/// ```
251
254
///
252
- /// Types which implement [`DerefMut`](core::ops::DerefMut) should consider to add an
253
- /// implementation of `AsMut` as follows:
255
+ /// Types which implement [`DerefMut`] should consider to add an implementation of `AsMut<T>` as
256
+ /// follows:
257
+ ///
258
+ /// [`DerefMut`]: core::ops::DerefMut
254
259
///
255
260
/// ```
256
261
/// # use core::ops::{Deref, DerefMut};
@@ -279,12 +284,14 @@ pub trait AsRef<T: ?Sized> {
279
284
/// # Reflexivity
280
285
///
281
286
/// Ideally, `AsMut` would be reflexive, that is there is an `impl<T: ?Sized> AsMut<T> for T`, with
282
- /// [`as_mut`][AsMut::as_mut] simply returning its argument unchanged.
287
+ /// [`as_mut`] simply returning its argument unchanged.
283
288
/// Such a blanket implementation is currently *not* provided due to technical restrictions of
284
289
/// Rust's type system (it would be overlapping with another existing blanket implementation for
285
290
/// `&mut T where T: AsMut<U>` which allows `AsMut` to auto-dereference, see "Generic
286
291
/// Implementations" above).
287
292
///
293
+ /// [`as_mut`]: AsMut::as_mut
294
+ ///
288
295
/// A trivial implementation of `AsMut<T> for T` must be added explicitly for a particular type `T`
289
296
/// where needed or desired. Note, however, that not all types from `std` contain such an
290
297
/// implementation, and those cannot be added by external code due to orphan rules.
@@ -298,7 +305,7 @@ pub trait AsRef<T: ?Sized> {
298
305
///
299
306
/// In the following, the example functions `caesar` and `null_terminate` provide a generic
300
307
/// interface which work with any type that can be converted by cheap mutable-to-mutable conversion
301
- /// into a byte slice or byte `Vec` , respectively.
308
+ /// into a byte slice (`[u8]`) or byte vector ( `Vec<u8>`) , respectively.
302
309
///
303
310
/// [dereference]: core::ops::DerefMut
304
311
/// [target type]: core::ops::Deref::Target
0 commit comments