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

#186 in Rust patterns

Download history 3786/week @ 2024-08-10 4499/week @ 2024-08-17 4054/week @ 2024-08-24 4169/week @ 2024-08-31 4638/week @ 2024-09-07 4862/week @ 2024-09-14 4398/week @ 2024-09-21 6104/week @ 2024-09-28 6444/week @ 2024-10-05 4997/week @ 2024-10-12 5986/week @ 2024-10-19 6283/week @ 2024-10-26 4138/week @ 2024-11-02 4965/week @ 2024-11-09 5809/week @ 2024-11-16 4997/week @ 2024-11-23

20,990 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