diff --git a/src/liballoc/arc.rs b/src/liballoc/arc.rs index ceca44fc1ac29..f66f1f13dcb23 100644 --- a/src/liballoc/arc.rs +++ b/src/liballoc/arc.rs @@ -1148,3 +1148,8 @@ impl borrow::Borrow for Arc { &**self } } + +#[stable(since = "1.5.0", feature = "smart_ptr_as_ref")] +impl AsRef for Arc { + fn as_ref(&self) -> &T { &**self } +} diff --git a/src/liballoc/boxed.rs b/src/liballoc/boxed.rs index 1529187da064c..629adf4649d38 100644 --- a/src/liballoc/boxed.rs +++ b/src/liballoc/boxed.rs @@ -594,3 +594,13 @@ impl borrow::BorrowMut for Box { &mut **self } } + +#[stable(since = "1.5.0", feature = "smart_ptr_as_ref")] +impl AsRef for Box { + fn as_ref(&self) -> &T { &**self } +} + +#[stable(since = "1.5.0", feature = "smart_ptr_as_ref")] +impl AsMut for Box { + fn as_mut(&mut self) -> &mut T { &mut **self } +} diff --git a/src/liballoc/rc.rs b/src/liballoc/rc.rs index 3507f123a6f15..2f0bf1281b344 100644 --- a/src/liballoc/rc.rs +++ b/src/liballoc/rc.rs @@ -1117,3 +1117,8 @@ impl borrow::Borrow for Rc { &**self } } + +#[stable(since = "1.5.0", feature = "smart_ptr_as_ref")] +impl AsRef for Rc { + fn as_ref(&self) -> &T { &**self } +}