Skip to content
Merged
Show file tree
Hide file tree
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
9 changes: 9 additions & 0 deletions src/liballoc/arc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,15 @@ impl<T: ?Sized> Deref for Arc<T> {
}
}

#[stable(feature = "rc_arc_as_ref", since = "1.2.0")]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this be rust1?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We actually have a lint to ensure that the same feature name (e.g. rust) is not stabilized in multiple different versions. This allows us to know that feature names are entirely stabilized all at once in only one version (useful for future analysis)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aha! Yeah I thought I grepped to check but I must have misgrepped, I see that in the codebase now.

impl<T: ?Sized> AsRef<T> for Arc<T> {

#[inline]
fn as_ref(&self) -> &T {
&self.inner().data
}
}

impl<T: Clone> Arc<T> {
/// Make a mutable reference from the given `Arc<T>`.
///
Expand Down
10 changes: 10 additions & 0 deletions src/liballoc/rc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ use std::boxed;
use core::cell::Cell;
use core::clone::Clone;
use core::cmp::{PartialEq, PartialOrd, Eq, Ord, Ordering};
use core::convert::AsRef;
use core::default::Default;
use core::fmt;
use core::hash::{Hasher, Hash};
Expand Down Expand Up @@ -379,6 +380,15 @@ impl<T: ?Sized> Deref for Rc<T> {
}
}

#[stable(feature = "rc_arc_as_ref", since = "1.2.0")]
impl<T: ?Sized> AsRef<T> for Rc<T> {

#[inline(always)]
fn as_ref(&self) -> &T {
&self.inner().value
}
}

#[stable(feature = "rust1", since = "1.0.0")]
impl<T: ?Sized> Drop for Rc<T> {
/// Drops the `Rc<T>`.
Expand Down