You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Specialization should allow for delegation to default trait method implementation #68309
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>TraitforT{defaultfntest(&self);}
Reacted by Ellen Emilia Anna Zscheile and Jeriel Baptista Verissimo
Yup, sounds reasonable to me. I noticed the amount of repetition when working on that PR too:
One annoyance with doing this is that it sometimes requires users to copy-paste a provided trait method into an impl just to mark it default (ie. there is no syntax to forward this impl method to the provided trait method).
Syntactic support for default fn test(&self); in an impl should already be there after #67131. To support it semantically we would need changes in lowering and beyond.
Activity
jazzfool commentedon Jan 17, 2020
cc @Centril
Centril commentedon Jan 17, 2020
I believe this is intentional fallout from #64564 (cc @jonas-schievink).
Having some sort of forwarding syntax to recover DRY seems reasonable and
default fn test(&self);isn't a bad one.jonas-schievink commentedon Jan 17, 2020
Yup, sounds reasonable to me. I noticed the amount of repetition when working on that PR too:
Centril commentedon Jan 17, 2020
Syntactic support for
default fn test(&self);in animplshould already be there after #67131. To support it semantically we would need changes in lowering and beyond.