negate
negate is a simple attribute macro that negates a given function.
Usage
#[negate]
Given a function of the form is_* that returns a boolean value, the macro will create a is_not_* function that negates the given function.
;
let my_name = new;
assert!;
#[negate(name = "...")]
Using the name attribute allows you to set the name of the generated function. This also allows the usage of the [negate] macro with functions that do not start with is_.
use negate;
#[negate(docs = "...")]
Using the docs attribute allows you to customize the doc-string of the generated function.
use negate;
assert!;
How does the generated code look like?
Non-associated functions
Will expand to:
/// This is an automatically generated function that denies [`is_even`].
/// Consult the original function for more information.
Using generics is likewise not a problem
The generated negated function:
/// This is an automatically generated function that denies [`is_equal`].
/// Consult the original function for more information.
Associated functions
;
Becomes: