When I run Clippy on Rust projects it will issue a new_without_default warning for any type with a
fn new() -> Self method and no implementation of
Default trait should be used when providing a default value is semantically required, such as
SomeOptions in the document, or for writing generic code as C#'s
default keyword does, but not in some arbitrary type with a no-arg constructor.
Rustonomicon even states
Default trait usage is “incredibly rare” and “basically only useful for generic programming” (https://doc.rust-lang.org/nomicon/constructors.html):
While Rust provides a Default trait for specifying the moral equivalent of a default constructor,
it’s incredibly rare for this trait to be used. This is because variables aren’t implicitly
initialized. Default is basically only useful for generic programming. In concrete contexts, a
type will provide a static new method for any kind of “default” constructor.
Now I’m confused about what are the cases when implementing
Default is expected.
Thanks for any suggestions.