Skip to content

Commit 9f68e3e

Browse files
committed
fixup! docs: Improve AsRef / AsMut docs on blanket impls
Fixed examples in sections "Generic Implementations" of `AsRef`'s and `AsMut`'s doc comments, which failed tests.
1 parent 551d921 commit 9f68e3e

File tree

1 file changed

+21
-0
lines changed
  • library/core/src/convert

1 file changed

+21
-0
lines changed

library/core/src/convert/mod.rs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,14 @@ pub const fn identity<T>(x: T) -> T {
150150
/// follows:
151151
///
152152
/// ```
153+
/// # use core::ops::Deref;
154+
/// # struct SomeType;
155+
/// # impl Deref for SomeType {
156+
/// # type Target = [u8];
157+
/// # fn deref(&self) -> &[u8] {
158+
/// # &[]
159+
/// # }
160+
/// # }
153161
/// impl<T> AsRef<T> for SomeType
154162
/// where
155163
/// T: ?Sized,
@@ -245,6 +253,19 @@ pub trait AsRef<T: ?Sized> {
245253
/// implementation of `AsMut` as follows:
246254
///
247255
/// ```
256+
/// # use core::ops::{Deref, DerefMut};
257+
/// # struct SomeType;
258+
/// # impl Deref for SomeType {
259+
/// # type Target = [u8];
260+
/// # fn deref(&self) -> &[u8] {
261+
/// # &[]
262+
/// # }
263+
/// # }
264+
/// # impl DerefMut for SomeType {
265+
/// # fn deref_mut(&mut self) -> &mut [u8] {
266+
/// # &mut []
267+
/// # }
268+
/// # }
248269
/// impl<T> AsMut<T> for SomeType
249270
/// where
250271
/// <SomeType as Deref>::Target: AsMut<T>,

0 commit comments

Comments
 (0)