#attributes #proc-macro #function #proc #macro

macro no-std must_be_empty

Makes sure that an specific function is empty. With no statements

2 releases

0.1.1 Jan 1, 2023
0.1.0 Dec 28, 2022

#6 in #attribute

MIT license

5KB
50 lines

Must be empty

This attribute checks that a given function is empty. It is just that. This can be useful for debugging, when you're just using using cargo test and want to assure that nobody in a repository puts content in the main function, for example.

Example

use must_be_empty::must_be_empty;

#[must_be_empty]
fn main() {}

If you were to put something in that main function, it would give a warning or an error, depending on your configuration.

Installation

Put this in your Cargo.toml file:

[dependencies]
must_be_empty = "0.1.0"

Features

  • warn (Default): Warns, instead of outputing a hard-error.
  • only_on_release: Only works in release mode (--release)
  • only_on_debug: Only works in debug mode.

lib.rs:

Must be empty

This attribute checks that a given function is empty. It is just that. This can be useful for debugging, when you're just using using cargo test and want to assure that nobody

Example

use must_be_empty::must_be_empty;

#[must_be_empty]
fn main() {}

Installation

Put this in your Cargo.toml file:

[dependencies]
must_be_empty = "0.1.0"

Dependencies

~1.5MB
~36K SLoC