Crates.io | unsafe-any-ors |
lib.rs | unsafe-any-ors |
version | 1.0.0 |
source | src |
created_at | 2022-09-03 13:53:10.90884 |
updated_at | 2022-09-03 13:53:10.90884 |
description | Traits and implementations for unchecked downcasting. |
homepage | |
repository | https://github.com/orphanage-rs/rust-unsafe-any |
max_upload_size | |
id | 657902 |
size | 8,971 |
Convenience traits for unsafe downcasting from trait objects to concrete types.
This crate defines two new traits UncheckedAnyDowncast
and UncheckedAnyMutDowncast
,
which define methods for downcasting to any type that implements Any
from
implemented trait objects.
It also defines two convenience implementations of these traits for &'a Any
and &'a mut Any
, which are the most common trait objects that you might
downcast from.
let a = box 7u as Box<Any>;
unsafe { assert_eq!(*a.downcast_ref_unchecked::<uint>(), 7u); }
MIT