|
|
|
|
|
by comex
2590 days ago
|
|
This is incorrect. In general, a reference can point to either the stack or the heap, including when generics are used. It is possible in theory for the Rust compiler to implement an ABI optimization where function arguments that are references to small values would be passed by value instead, at least in some cases (see my other post). However, that optimization does not currently exist. Edit: But in this case the reference will be optimized away anyway, because the callee function will be inlined. Edit 2: Actually, the optimization does exist at the LLVM level, though it only applies in some cases. See my other comment: https://news.ycombinator.com/item?id=19997818 |
|