Placing Functions(blog.yoshuawuyts.com) |
Placing Functions(blog.yoshuawuyts.com) |
C deals with it via passing outparams, C++ deals with it via a bunch of machinery that literally has multiple entire Wikipedia articles dedicated to it ( https://en.wikipedia.org/wiki/Placement_syntax and https://en.wikipedia.org/wiki/Copy_elision ), and Rust has historically sought for a solution that's less explicit than C's and less fraught than C++'s, so far to little success, because (to reiterate) functions don't particularly want to work that way.
Rust doesn't have overridable copy/move, so elision could be treated as QoI issue.
More interestingly, now that C++ has guaranteed copy elision in some cases, in addition to allow returning non copyable objects, code that doesn't override constructors can rely on the address of an returned object not changing that open up some possibilities. I assume rust wants this.
My point is that these occasionally break out of their bubbles and become more "mainstream" than you might expect from the raw population-of-interest numbers. It's not all that uncommon (e.g. for a while there were more "how I cope with the difficulties that come from living off grid" stories out there than "how to live off grid" or even "why live off grid?") but I still find it noteworthy.