unsafe-any-ors

Crates.iounsafe-any-ors
lib.rsunsafe-any-ors
version1.0.0
sourcesrc
created_at2022-09-03 13:53:10.90884
updated_at2022-09-03 13:53:10.90884
descriptionTraits and implementations for unchecked downcasting.
homepage
repositoryhttps://github.com/orphanage-rs/rust-unsafe-any
max_upload_size
id657902
size8,971
Anton Whalley (No9)

documentation

README

unsafe-any-ors CI

Convenience traits for unsafe downcasting from trait objects to concrete types.

Overview

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.

Example:

let a = box 7u as Box<Any>;
unsafe { assert_eq!(*a.downcast_ref_unchecked::<uint>(), 7u); }

License

MIT

Commit count: 37

cargo fmt