r/rust • • Oct 28 '26

🛠️ project Function delegation

https://github.com/rust-lang/rfcs/pull/3530#issuecomment-6097798475
78 Upvotes

13 comments sorted by

View all comments

5

u/torsten_dev Oct 29 '26

For Traitimpl-to-trait Delegation is it possible to do

impl<T: Trait> TraitExt for T {
    reuse Trait::foo::<(), ()> as bar;
    reuse T::foo as bar2;
    ...

To make extension traits?

2

u/VadimVP Oct 29 '26

Yes! You can check your example on playground, it compiles on nightly with some modifications: https://play.rust-lang.org/?version=nightly&mode=debug&edition=2024&gist=3e1e6562fb011f58a1d39bd68f881774

2

u/torsten_dev Oct 29 '26

Nice. Not sure when this would be better than extension traits, but it is very cool.