I have a trait method with a default implementation that works for most types. I'm trying to specialize it for a particular type and have the specialization call the default implementation, but it doesn't seem to be possible.
trait Trait {
fn method(&self) {
println!("default");
}
}
struct Thing;
impl Trait for Thing {
fn method(&self) {
println!("specialized");
Trait::method(self);
}
}
pub fn main() {
let thing = Thing;
thing.method();
}
I want this to print specialized
, default
, but instead it recurses forever printing specialized
until the stack overflows.
Is there some syntax to call the default implementation or am I out of luck?
Stack Overflow says: