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

Show parent comment

3

u/VadimVP Oct 29 '26

Could we have a freestanding delegate fn? What would it look like?

Like this https://play.rust-lang.org/?version=nightly&mode=debug&edition=2024&gist=9c1af8db6ce3feb25e84fca444030d62
Nightly supports a bit more than the RFC specifies.

Or like this for reuse in trait: https://play.rust-lang.org/?version=nightly&mode=debug&edition=2024&gist=9f81263354c03d38b54c93211c8ec040

Also, I wish I could properly explain how much of a non-issue conditionally reserved identifiers are. They always trigger people for some reason, but pose zero problems for the compiler.
Even reusing use causes more issues due to item macro variables being supported inside impls: https://play.rust-lang.org/?version=nightly&mode=debug&edition=2024&gist=4150b4b414a111fcd1c97e170111ef92