Expand description
§::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)] pub trait Foo { fn whoops (); }#[macro_use] extern crate dyn_safe; #[dyn_safe(false)] pub trait Foo { fn ok (); } -
ⓘ
#[macro_use] extern crate dyn_safe; #[dyn_safe(false)] pub trait Foo { // … } let _: dyn Foo; // Whoops#[macro_use] extern crate dyn_safe; #[dyn_safe(true)] pub trait Foo { // … } let _: dyn Foo; // Ok
-
Traits§
- NotObject
Safe - “Marker” (super-)trait used to opt-out of object safety.