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

#174 in Rust patterns

Download history 2491/week @ 2023-11-20 3573/week @ 2023-11-27 3565/week @ 2023-12-04 2712/week @ 2023-12-11 1783/week @ 2023-12-18 1538/week @ 2023-12-25 3542/week @ 2024-01-01 3902/week @ 2024-01-08 3822/week @ 2024-01-15 3279/week @ 2024-01-22 2852/week @ 2024-01-29 3635/week @ 2024-02-05 4400/week @ 2024-02-12 3192/week @ 2024-02-19 4211/week @ 2024-02-26 4812/week @ 2024-03-04

16,818 downloads per month
Used in 62 crates (21 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