Rust

Rust

Made by DeepSource

Found empty tuple struct or tuple variant RS-W1125

Anti-pattern
Minor

Empty tuple fields in structs or enum variants do not affect the program in a meaningful way other than making the variant or struct identifier a constructor type rather than a value type. Consider revisiting this definition.

Bad practice

struct Foo();

enum Bar {
    Baz()
}

fn foo() {
    let x: fn() -> Foo = Foo;
    let y: fn() -> Bar = Bar::Baz;
}

Recommended

struct Foo;

enum Bar {
    Baz
}

fn foo() {
    let x: Foo = Foo;
    let y: Bar = Bar::Baz;
}