diff --git a/library/core/src/cell.rs b/library/core/src/cell.rs index fb4454c94cb33..137a6fa6191a4 100644 --- a/library/core/src/cell.rs +++ b/library/core/src/cell.rs @@ -1342,6 +1342,22 @@ impl Deref for Ref<'_, T> { } } +#[stable(feature = "borrow_ref", since = "1.65.0")] +impl crate::convert::AsRef for Ref<'_, T> { + #[inline] + fn as_ref(&self) -> &T { + self + } +} + +#[stable(feature = "borrow_ref", since = "1.65.0")] +impl crate::borrow::Borrow for Ref<'_, T> { + #[inline] + fn borrow(&self) -> &T { + self + } +} + impl<'b, T: ?Sized> Ref<'b, T> { /// Copies a `Ref`. /// @@ -1733,6 +1749,38 @@ impl DerefMut for RefMut<'_, T> { } } +#[stable(feature = "borrow_ref", since = "1.65.0")] +impl crate::convert::AsRef for RefMut<'_, T> { + #[inline] + fn as_ref(&self) -> &T { + self + } +} + +#[stable(feature = "borrow_ref", since = "1.65.0")] +impl crate::convert::AsMut for RefMut<'_, T> { + #[inline] + fn as_mut(&mut self) -> &mut T { + self + } +} + +#[stable(feature = "borrow_ref", since = "1.65.0")] +impl crate::borrow::Borrow for RefMut<'_, T> { + #[inline] + fn borrow(&self) -> &T { + self + } +} + +#[stable(feature = "borrow_ref", since = "1.65.0")] +impl crate::borrow::BorrowMut for RefMut<'_, T> { + #[inline] + fn borrow_mut(&mut self) -> &mut T { + self + } +} + #[unstable(feature = "coerce_unsized", issue = "27732")] impl<'b, T: ?Sized + Unsize, U: ?Sized> CoerceUnsized> for RefMut<'b, T> {}