File: README.md

package info (click to toggle)
rust-unsafe-any-ors 1.0.0-1
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 116 kB
  • sloc: makefile: 11
file content (25 lines) | stat: -rwxr-xr-x 787 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# unsafe-any-ors [![CI](https://github.com/orphanage-rs/rust-unsafe-any/actions/workflows/general.yaml/badge.svg)](https://github.com/orphanage-rs/rust-unsafe-any/actions/workflows/general.yaml)

> 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:

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

## License

MIT