hazmat 0.1.0

A collection of helpers for working with hazardous materials in Rust crates.
Documentation
  • Coverage
  • 100%
    1 out of 1 items documented0 out of 0 items with examples
  • Size
  • Source code size: 19.86 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 1.01 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 11s Average build duration of successful builds.
  • all releases: 11s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • str4d/hazmat
    2 1 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • str4d

hazmat Rust library

A collection of helpers for working with hazardous materials in Rust crates.

#[hazmat::suit]

Ever needed to expose an internal trait for downstream users to implement, that shouldn't be usable outside of your crate? Add the #[hazmat::suit] attribute to the trait and it becomes "implement-only":

#[hazmat::suit]
pub trait LowLevel {
    fn low_level(self) -> bool;
}

struct DownstreamType;

#[hazmat::suit]
impl LowLevel for DownstreamType {
    fn low_level(self, other: Self) -> bool {
        true
    }
}

fn use_low_level() {
    let a = DownstreamType;
    let b = DownstreamType;

    // This won't compile outside of the crate in which the trait is defined.
    assert!(a.low_level(b, LowLevelCap));
}

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.