[][src]Crate exclusive

Create exclusive contexts around your code that should not collide with other calls to exclusive!.

The exclusive! macro works by making a "unique" ID for each call site and using that ID to create a unique const declaration.


This project was made to be used by static_assertions to prevent different assertions from colliding with the same identifier.


This crate is available on crates.io and can be used by adding the following to your project's Cargo.toml:

exclusive = "0.1"

and this to your crate root (main.rs or lib.rs):

extern crate exclusive;

Then, when calling the macro, you can place any code you want inside it!

exclusive! {
    let x = 20;
    let y = 30;

exclusive! {
    // This code doesn't actually run
    println!("Hello, world!");

With the nightly feature enabled, a const the identifier _ is used internally instead. This simply avoids having to generate a new identifier each time.

This example is not tested

exclusive! {
    // Do stuff here

exclusive! {
    // Do other stuff here



Creates an exclusive context. 😎