Navigation Menu

Skip to content

Commit

Permalink
Remove core::any::AnyPrivate
Browse files Browse the repository at this point in the history
[Previously](e5da6a7),
the `Any` trait was split into a private portion and an (empty) public
portion, in order to hide the implementation strategy used for
downcasting. However, the [new
rules](e9ad12c)
for privacy forbid `AnyPrivate` from actually being private.

This patch thus reverts the introduction of `AnyPrivate`.

Although this is unlikely to break any real code, it removes a public
trait and is therefore a:

[breaking-change]
  • Loading branch information
aturon committed Oct 6, 2014
1 parent b5ba2f5 commit 07cfc25
Showing 1 changed file with 2 additions and 7 deletions.
9 changes: 2 additions & 7 deletions src/libcore/any.rs
Expand Up @@ -91,20 +91,15 @@ pub enum Void { }
/// Every type with no non-`'static` references implements `Any`, so `Any` can
/// be used as a trait object to emulate the effects dynamic typing.
#[stable]
pub trait Any: AnyPrivate + 'static {}

/// An inner trait to ensure that only this module can call `get_type_id()`.
pub trait AnyPrivate {
pub trait Any: 'static {
/// Get the `TypeId` of `self`
fn get_type_id(&self) -> TypeId;
}

impl<T: 'static> AnyPrivate for T {
impl<T: 'static> Any for T {
fn get_type_id(&self) -> TypeId { TypeId::of::<T>() }
}

impl<T: 'static + AnyPrivate> Any for T {}

///////////////////////////////////////////////////////////////////////////////
// Extension methods for Any trait objects.
// Implemented as three extension traits so that the methods can be generic.
Expand Down

0 comments on commit 07cfc25

Please sign in to comment.