From 9f68e3ef1b3bc0a7f1ce4d7ff7fc74bcaa2d42ad Mon Sep 17 00:00:00 2001 From: Jan Behrens Date: Tue, 19 Jul 2022 23:24:51 +0200 Subject: [PATCH] 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. --- library/core/src/convert/mod.rs | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) 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(x: T) -> T { /// follows: /// /// ``` +/// # use core::ops::Deref; +/// # struct SomeType; +/// # impl Deref for SomeType { +/// # type Target = [u8]; +/// # fn deref(&self) -> &[u8] { +/// # &[] +/// # } +/// # } /// impl AsRef for SomeType /// where /// T: ?Sized, @@ -245,6 +253,19 @@ pub trait AsRef { /// 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 AsMut for SomeType /// where /// ::Target: AsMut,