5 unstable releases

0.3.1 Sep 23, 2023
0.3.0 Feb 20, 2022
0.2.1 Dec 12, 2021
0.2.0 Apr 18, 2020
0.1.0 Apr 18, 2020

#181 in Rust patterns

Download history 4582/week @ 2024-07-21 4346/week @ 2024-07-28 3569/week @ 2024-08-04 3863/week @ 2024-08-11 4439/week @ 2024-08-18 4213/week @ 2024-08-25 4016/week @ 2024-09-01 4780/week @ 2024-09-08 4791/week @ 2024-09-15 4400/week @ 2024-09-22 6012/week @ 2024-09-29 6496/week @ 2024-10-06 5038/week @ 2024-10-13 6059/week @ 2024-10-20 6166/week @ 2024-10-27 4288/week @ 2024-11-03

21,785 downloads per month
Used in 74 crates (23 directly)

MIT/Apache

7KB

as-any

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.


lib.rs:

This library provides some utility traits to make working with [Any] smoother. This crate contains similiar functionality to the downcast crate, but simpler, e.g. it isn't necessary to call some macro to instantiate the downcast methods.

Usage example

use as_any::{AsAny, Downcast};

struct Test;

trait Custom: AsAny {
// whatever you like to put inside of your trait
}

impl Custom for Test {}

fn lol() {
let x = Test;
let y: &dyn Custom = &x;
// With (extension) trait `Downcast` in scope.
y.downcast_ref::<Test>().unwrap();
}

No runtime deps