Skip to main content

make_unit

Attribute Macro make_unit 

Source
#[make_unit]
Expand description

Strips a struct’s fields, turning it into a unit struct.

Applied to a struct with named fields (struct Foo { .. }) or a tuple struct (struct Foo(..)), it discards every field, leaving struct Foo;. Attributes, visibility, and generics are preserved; an already-unit struct is left unchanged.

Applying it to anything other than a struct is an error.

use make_noop::make_unit;

#[make_unit]
struct Config {
    verbose: bool,
    retries: u32,
}
// Expands to `struct Config;`