dyn_safe

Crates.iodyn_safe
lib.rsdyn_safe
version0.0.4
sourcesrc
created_at2020-11-20 20:27:42.762297
updated_at2022-07-17 12:08:01.913071
descriptionTake control of the Semver hazard of the `dyn` safety of your traits!
homepagehttps://crates.io/crates/dyn_safe
repositoryhttps://github.com/danielhenrymantilla/dyn_safe.rs
max_upload_size
id314448
size20,140
Daniel Henry-Mantilla (danielhenrymantilla)

documentation

https://docs.rs/dyn_safe

README

::dyn_safe

Repository Latest version Documentation MSRV unsafe forbidden License

Take control of the Semver hazard of the dyn safety of your traits!

Usage
  1. cargo add dyn_safe, or add the following to your Cargo.toml file:

    [dependencies]
    dyn_safe = "x.y.z"
    
    • where you can find the version using cargo search dyn_safe
  2. Add the following to your lib.rs file:

    #[macro_use]
    extern crate dyn_safe;
    
  3. Use #[dyn_safe(true)] or #[dyn_safe(false)] to, respectively, assert that the trait object is dyn-safe or that the trait object should not be dyn-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
      
Commit count: 4

cargo fmt