use core::cmp::{PartialEq, PartialOrd, Eq, Ord, Ordering};
use core::default::Default;
use core::fmt;
-use core::intrinsics;
use core::kinds::Sized;
use core::mem;
use core::option::Option;
}
#[stable]
-impl BoxAny for Box<Any+'static> {
+impl BoxAny for Box<Any> {
#[inline]
- fn downcast<T: 'static>(self) -> Result<Box<T>, Box<Any+'static>> {
+ fn downcast<T: 'static>(self) -> Result<Box<T>, Box<Any>> {
if self.is::<T>() {
unsafe {
// Get the raw representation of the trait object
let to: TraitObject =
- *mem::transmute::<&Box<Any>, &TraitObject>(&self);
-
- // Prevent destructor on self being run
- intrinsics::forget(self);
+ mem::transmute::<Box<Any>, TraitObject>(self);
// Extract the data pointer
Ok(mem::transmute(to.data))
#![stable]
-use mem::{transmute, transmute_copy};
+use mem::{transmute};
use option::{Option, Some, None};
use raw::TraitObject;
use intrinsics::TypeId;
if self.is::<T>() {
unsafe {
// Get the raw representation of the trait object
- let to: TraitObject = transmute_copy(&self);
+ let to: TraitObject = transmute(self);
// Extract the data pointer
Some(transmute(to.data))
if self.is::<T>() {
unsafe {
// Get the raw representation of the trait object
- let to: TraitObject = transmute_copy(&self);
+ let to: TraitObject = transmute(self);
// Extract the data pointer
Some(transmute(to.data))