Specialization should allow for delegation to default trait method implementation #68309
Open
Description
opened on Jan 17, 2020
Given the following trait:
trait Trait {
fn test(&self) { println!("default implementation"); }
}
To provide a default specialization on Trait::test
, test
must be redefined;
impl<T> Trait for T {
default fn test(&self) { println!("default implementation"); }
}
However this violates the DRY principle. The solution here would be to provide a way to delegate the implementation of test
to the already existing default implementation found in the trait definition.
Proposed syntax to allow for this delegation:
impl<T> Trait for T {
default fn test(&self);
}
Activity