Rust

Rust

Made by DeepSource

Found implementation of default() outside Default trait RS-E1022

Bug risk
Minor

Implementing the default() method outside of the Default trait is non-idiomatic. It also makes deriving Default on any subsequent types using this type impossible, despite the presence of an implementation for default().

Implement the Default trait for the given type instead.

Bad practice

impl Foo {
    fn default() -> Self {
        Self {
            // ...
        }
    }
}

Recommended

impl Default for Foo {
    fn default() -> Self {
        Self {
            // ...
        }
    }
}