5 releases
| 0.1.0 | Aug 20, 2025 |
|---|---|
| 0.0.4 | Jul 17, 2022 |
| 0.0.3 | Jul 17, 2022 |
| 0.0.2 | Nov 20, 2020 |
| 0.0.1 | Nov 20, 2020 |
#1228 in Rust patterns
23 downloads per month
Used in 3 crates
(via xwt-dyn)
9KB
::dyn_safe
Take control of the Semver hazard of the dyn safety of your traits!
Usage
-
cargo add dyn_safe, or add the following to yourCargo.tomlfile:[dependencies] dyn_safe = "x.y.z"- where you can find the version using
cargo search dyn_safe
- where you can find the version using
-
Add the following to your
lib.rsfile:#[macro_use] extern crate dyn_safe; -
Use
#[dyn_safe(true)]or#[dyn_safe(false)]to, respectively, assert that the trait object isdyn-safe or that the trait object should not bedyn-safe.-
#[macro_use] extern crate dyn_safe; #[dyn_safe(true)] trait Foo { fn whoops (); } -
#[macro_use] extern crate dyn_safe; #[dyn_safe(false)] trait Foo { // … } let _: dyn Foo; // Whoops
-