Rust Keyword Generics Progress Report: February 2023
Rust Keyword Generics Progress Report: February 2023
Posted Feb 26, 2023 11:19 UTC (Sun) by mb (subscriber, #50428)In reply to: Rust Keyword Generics Progress Report: February 2023 by NYKevin
Parent article: Rust Keyword Generics Progress Report: February 2023
Yes. I completely agree. We must have separate functions that the caller explicitly chooses from, for mutability.
But I sometimes wish there would be some help from the language to make implementing these functions easier.
For example for simple reference-getter functions we basically just duplicate the function (with added mut).
I'd sometimes like to have something like this:
fn get{_ref|_mut}(& ?mut self) -> & ?mut Foo {
& ?mut self.foo
}
It would still generate two functions with two names, but I would only have to write one.
Yes, I can do that with macros, but support from the language in the form of syntactic sugar would feel much nicer to me.
