default()
that returns Self
RS-A1008The default()
function in the Default
trait is used to create
a default instance of the type. While implementing this, if a function
call returns the same type, it could possibly create an infinite loop
by calling default()
itself.
Consider revisiting this implementation.
struct A(i32);
impl A {
fn new() -> Self {
Self::default()
}
}
impl Default for A {
fn default() -> Self {
// This call will create an infinite loop
Self::new()
}
}