-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Open
Labels
A-specializationArea: Trait impl specializationArea: Trait impl specializationC-feature-requestCategory: A feature request, i.e: not implemented / a PR.Category: A feature request, i.e: not implemented / a PR.F-associated_type_defaults`#![feature(associated_type_defaults)]``#![feature(associated_type_defaults)]`F-specialization`#![feature(specialization)]``#![feature(specialization)]`T-langRelevant to the language teamRelevant to the language team
Description
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);
}
fogti and jerielverissimo
Metadata
Metadata
Assignees
Labels
A-specializationArea: Trait impl specializationArea: Trait impl specializationC-feature-requestCategory: A feature request, i.e: not implemented / a PR.Category: A feature request, i.e: not implemented / a PR.F-associated_type_defaults`#![feature(associated_type_defaults)]``#![feature(associated_type_defaults)]`F-specialization`#![feature(specialization)]``#![feature(specialization)]`T-langRelevant to the language teamRelevant to the language team