News for hackers. Stuff that matters.
Re:Should Small Rust Structs be Passed by-copy or by-borrow? by cwzwarich on Saturday December 31, 2022 @02:51PM (#34200052)
It would be nice if Rust could do this, but it breaks backwards compatibility. Some existing code depends on pointer values of &T being equal or not equal.
Re:Should Small Rust Structs be Passed by-copy or by-borrow? by comex on Saturday December 31, 2022 @04:40PM (#34201050)
As an addendum, LLVM can automatically perform the “&T-as-T” optimization (without inlining) in some cases where the callee function is in the same compilation unit and known to not care about the pointer value. However, these types of optimizations tend to be fragile, easily disturbed when things get slightly complex.