disable_macro

Crates.iodisable_macro
lib.rsdisable_macro
version0.3.6
sourcesrc
created_at2024-06-21 20:14:31.987059
updated_at2024-06-21 21:40:42.204892
descriptionThis simple crate lets us disable a block of code with an attribute #[disable].
homepage
repositoryhttps://github.com/klebs6/klebs-general
max_upload_size
id1279898
size4,124
(klebs6)

documentation

README

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.

Commit count: 110

cargo fmt