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
21,785 downloads per month
Used in 74 crates
(23 directly)
7KB
as-any
License
Licensed under either of
- Apache License, Version 2.0 (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
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();
}