Call default trait method impl from specialized impl

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();
}

Playground

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:

1 Like

There's still no syntax for that, correct.

Many various alternatives exist, like splitting into multiple methods or separating a strategy trait from the glue part or ...

1 Like

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.