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

#170 in Rust patterns

Download history 5008/week @ 2024-06-13 4887/week @ 2024-06-20 3602/week @ 2024-06-27 3145/week @ 2024-07-04 3279/week @ 2024-07-11 4545/week @ 2024-07-18 4133/week @ 2024-07-25 4237/week @ 2024-08-01 3760/week @ 2024-08-08 3850/week @ 2024-08-15 4318/week @ 2024-08-22 4421/week @ 2024-08-29 4112/week @ 2024-09-05 5419/week @ 2024-09-12 3950/week @ 2024-09-19 5021/week @ 2024-09-26

19,571 downloads per month
Used in 73 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