diff options
| author | Jan Behrens <jbe@magnetkern.de> | 2022-07-19 23:24:51 +0200 |
|---|---|---|
| committer | Jan Behrens <jbe@magnetkern.de> | 2022-07-19 23:24:51 +0200 |
| commit | 9f68e3ef1b3bc0a7f1ce4d7ff7fc74bcaa2d42ad (patch) | |
| tree | 3a50b92ad861e5913b4e1554ee234222e37feefa | |
| parent | 551d921de0f13c54093ab4f6a3adbe69292e091a (diff) | |
| download | rust-9f68e3ef1b3bc0a7f1ce4d7ff7fc74bcaa2d42ad.tar.gz rust-9f68e3ef1b3bc0a7f1ce4d7ff7fc74bcaa2d42ad.zip | |
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.
| -rw-r--r-- | library/core/src/convert/mod.rs | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/library/core/src/convert/mod.rs b/library/core/src/convert/mod.rs index dd0d6478c3a..e75e32855d1 100644 --- a/library/core/src/convert/mod.rs +++ b/library/core/src/convert/mod.rs @@ -150,6 +150,14 @@ pub const fn identity<T>(x: T) -> T { /// follows: /// /// ``` +/// # use core::ops::Deref; +/// # struct SomeType; +/// # impl Deref for SomeType { +/// # type Target = [u8]; +/// # fn deref(&self) -> &[u8] { +/// # &[] +/// # } +/// # } /// impl<T> AsRef<T> for SomeType /// where /// T: ?Sized, @@ -245,6 +253,19 @@ pub trait AsRef<T: ?Sized> { /// implementation of `AsMut` as follows: /// /// ``` +/// # use core::ops::{Deref, DerefMut}; +/// # struct SomeType; +/// # impl Deref for SomeType { +/// # type Target = [u8]; +/// # fn deref(&self) -> &[u8] { +/// # &[] +/// # } +/// # } +/// # impl DerefMut for SomeType { +/// # fn deref_mut(&mut self) -> &mut [u8] { +/// # &mut [] +/// # } +/// # } /// impl<T> AsMut<T> for SomeType /// where /// <SomeType as Deref>::Target: AsMut<T>, |
