Crate breaking_attr

Crate breaking_attr 

Source
Expand description

Crates.io Version docs.rs GitHub Actions Workflow Status

An attribute macro that enforces per-version invariants on items.

use breaking_attr::breaking;

#[cfg_attr(test, test)]
fn hash_impl_did_not_change() {
    #[breaking(sha2 = "zEk8F98i1LX-Rr070lCztGerzO1-qlLbosetY1UvSww=")]
    const SEED: &str = "This value must not change between minor versions.";

    #[breaking("cD1v24qkrBpNJl2awl4hTkYqrOHy3L3_IKMQSjN_LXo=")] // defaults to `blake3`
    const HASH: u64 = 5201689092505688044;

    // Just for example:
    let mut hasher = std::hash::DefaultHasher::new();
    hasher.write(SEED.as_bytes());
    debug_assert_eq!(hasher.finish(), HASH);
}

See the documentation on breaking

Attribute Macrosยง

breaking
Marks an item that will break the public API if it is changed.