#unsafe #warnings #unsafe-any

unsafe-any

Traits and implementations for unchecked downcasting

12 releases

Uses old Rust 2015

0.4.2 May 25, 2017
0.4.1 Apr 23, 2015
0.3.0 Apr 18, 2015
0.2.5 Apr 18, 2015
0.1.1 Nov 28, 2014

#1480 in Rust patterns

Download history 17975/week @ 2024-12-14 10844/week @ 2024-12-21 10731/week @ 2024-12-28 20285/week @ 2025-01-04 21339/week @ 2025-01-11 19857/week @ 2025-01-18 17801/week @ 2025-01-25 25490/week @ 2025-02-01 14920/week @ 2025-02-08 7420/week @ 2025-02-15 8492/week @ 2025-02-22 7095/week @ 2025-03-01 8950/week @ 2025-03-08 10120/week @ 2025-03-15 9305/week @ 2025-03-22 7641/week @ 2025-03-29

37,182 downloads per month
Used in 275 crates (9 directly)

MIT license

7KB
87 lines

Unsafe-Any Build Status

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

Dependencies

~7KB