Re:Cursed Rust
by dabacaba on Saturday October 05, 2024 @07:41PM
(#41753664)
In Rust, if expressions are not place expressions. In the example, arr_ref is a reference to a temporary, not to an array element. In Rust, it is possible to take an address of any expression, but taking an address of a value expression will produce an address of a temporary.
[ Parent
| on HN ]
Interesting. Is there any documentation which explains this?
Not sure if there's a better section elsewhere, but at least this one touches on it:
https://doc.rust-lang.org/reference/destructors.html#tempora...