diff options
| author | Niko Matsakis <niko@alum.mit.edu> | 2015-02-17 05:17:19 -0500 |
|---|---|---|
| committer | Niko Matsakis <niko@alum.mit.edu> | 2015-03-17 08:34:25 -0400 |
| commit | 5f5ed62298e5e366b931363b804631305178df5c (patch) | |
| tree | 4c434eeafbd58ab1bc9a67b46865c3e45cdaeb49 /src/libcore | |
| parent | bde09eea35113f25d4e0bcc4a8344de971f3069a (diff) | |
Remove subtyping for object types and replace with an *upcast* coercion.
This upcast coercion currently preserves the vtable for the object, but eventually it can be used to create a derived vtable. The upcast coercion is not introduced into method dispatch; see comment on #18737 for information about why. Fixes #18737.
Diffstat (limited to 'src/libcore')
| -rw-r--r-- | src/libcore/any.rs | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/src/libcore/any.rs b/src/libcore/any.rs index 462b6771b4a..6d3fac4c68d 100644 --- a/src/libcore/any.rs +++ b/src/libcore/any.rs @@ -71,6 +71,7 @@ #![stable(feature = "rust1", since = "1.0.0")] +use marker::Send; use mem::transmute; use option::Option::{self, Some, None}; use raw::TraitObject; @@ -154,6 +155,31 @@ impl Any { } } +#[cfg(not(stage0))] +impl Any+Send { + /// Forwards to the method defined on the type `Any`. + #[stable(feature = "rust1", since = "1.0.0")] + #[inline] + pub fn is<T: 'static>(&self) -> bool { + Any::is::<T>(self) + } + + /// Forwards to the method defined on the type `Any`. + #[stable(feature = "rust1", since = "1.0.0")] + #[inline] + pub fn downcast_ref<T: 'static>(&self) -> Option<&T> { + Any::downcast_ref::<T>(self) + } + + /// Forwards to the method defined on the type `Any`. + #[stable(feature = "rust1", since = "1.0.0")] + #[inline] + pub fn downcast_mut<T: 'static>(&mut self) -> Option<&mut T> { + Any::downcast_mut::<T>(self) + } +} + + /////////////////////////////////////////////////////////////////////////////// // TypeID and its methods /////////////////////////////////////////////////////////////////////////////// |
