Rust

Rust

Made by DeepSource

Found trivial implementation of default() RS-W1111

Anti-pattern
Minor

An implementation of default() where every struct member is initialised with its default value is equivalent to deriving the Default trait.

Use #[derive(Default)] instead.

Bad practice

struct Foo {
    bar: i32,
    baz: String,
}

impl Default for Foo {
    fn default() -> Self {
        Self {
            bar: i32::default(),
            baz: String::default(),
        }
    }
}

Recommended

#[derive(Default)]
struct Foo {
    bar: i32,
    baz: String,
}