3 #[cfg(feature = "nightly")]
4 use std
::raw
::TraitObject
;
6 #[cfg(not(feature = "nightly"))]
8 #[allow(raw_pointer_derive)]
15 #[allow(missing_docs)] // Bogus warning (it’s not public outside the crate), ☹
16 pub trait UncheckedAnyExt
{
17 unsafe fn downcast_ref_unchecked
<T
: '
static>(&self) -> &T
;
18 unsafe fn downcast_mut_unchecked
<T
: '
static>(&mut self) -> &mut T
;
19 unsafe fn downcast_unchecked
<T
: '
static>(self: Box
<Self>) -> Box
<T
>;
22 impl UncheckedAnyExt
for Any
{
23 unsafe fn downcast_ref_unchecked
<T
: '
static>(&self) -> &T
{
24 mem
::transmute(mem
::transmute
::<_
, TraitObject
>(self).data
)
27 unsafe fn downcast_mut_unchecked
<T
: '
static>(&mut self) -> &mut T
{
28 mem
::transmute(mem
::transmute
::<_
, TraitObject
>(self).data
)
31 unsafe fn downcast_unchecked
<T
: '
static>(self: Box
<Any
>) -> Box
<T
> {
32 mem
::transmute(mem
::transmute
::<_
, TraitObject
>(self).data
)