#disable #macro #shorthand

macro disable_macro

This simple crate lets us disable a block of code with an attribute #[disable]

3 unstable releases

0.3.6 Jun 21, 2024
0.3.1 Jun 21, 2024
0.1.0 Jun 21, 2024

#19 in #shorthand

32 downloads per month

MIT license

4KB

disable

disable is a Rust procedural macro that allows you to conditionally disable blocks of code by completely removing them. This can be useful for debugging, feature gating, or simply turning off certain functionalities during development.

Features

  • Completely remove the annotated item from the compiled code with a single attribute.
  • Easy integration into existing projects.

This is mostly useful (IMO) for easily disabling tests without block comments.

Usage

Add to Your Project

Add disable as a dependency in your Cargo.toml:

[dependencies]
disable = "*"

Example

Annotate the functions you want to disable with the #[disable] attribute

use disable::disable;

#[disable]
fn some_function() {
    println!("This code will not be compiled.");
}

// this will not compile, because `some_function` is disabled
fn main() {
    some_function(); 
}

License

This project is licensed under the MIT License. See the LICENSE file for details.

Dependencies

~1.5MB
~35K SLoC