Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 48 additions & 0 deletions library/core/src/cell.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1342,6 +1342,22 @@ impl<T: ?Sized> Deref for Ref<'_, T> {
}
}

#[stable(feature = "borrow_ref", since = "1.65.0")]
impl<T: ?Sized> crate::convert::AsRef<T> for Ref<'_, T> {
#[inline]
fn as_ref(&self) -> &T {
self
}
}

#[stable(feature = "borrow_ref", since = "1.65.0")]
impl<T: ?Sized> crate::borrow::Borrow<T> for Ref<'_, T> {
#[inline]
fn borrow(&self) -> &T {
self
}
}

impl<'b, T: ?Sized> Ref<'b, T> {
/// Copies a `Ref`.
///
Expand Down Expand Up @@ -1733,6 +1749,38 @@ impl<T: ?Sized> DerefMut for RefMut<'_, T> {
}
}

#[stable(feature = "borrow_ref", since = "1.65.0")]
impl<T: ?Sized> crate::convert::AsRef<T> for RefMut<'_, T> {
#[inline]
fn as_ref(&self) -> &T {
self
}
}

#[stable(feature = "borrow_ref", since = "1.65.0")]
impl<T: ?Sized> crate::convert::AsMut<T> for RefMut<'_, T> {
#[inline]
fn as_mut(&mut self) -> &mut T {
self
}
}

#[stable(feature = "borrow_ref", since = "1.65.0")]
impl<T: ?Sized> crate::borrow::Borrow<T> for RefMut<'_, T> {
#[inline]
fn borrow(&self) -> &T {
self
}
}

#[stable(feature = "borrow_ref", since = "1.65.0")]
impl<T: ?Sized> crate::borrow::BorrowMut<T> for RefMut<'_, T> {
#[inline]
fn borrow_mut(&mut self) -> &mut T {
self
}
}

#[unstable(feature = "coerce_unsized", issue = "27732")]
impl<'b, T: ?Sized + Unsize<U>, U: ?Sized> CoerceUnsized<RefMut<'b, U>> for RefMut<'b, T> {}

Expand Down