3 ms·
Cursed Rust
- dabacaba 2y agoIn 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.
- John23832 2y agoInteresting. Is there any documentation which explains this?
- eddyb 2y agoNot sure if there's a better section elsewhere, but at least this one touches on it: https://doc.rust-lang.org/reference/destructors.html#temporary-scopes https://doc.rust-lang.org/reference/destructors.html#tempora...
- justincredible 2y ago[dead]
- atoav 2y ago#00F on black is really not a color combination anybody should use in any case where accessability matters.
- davidatbu 2y agoI don't know if it's due to my familiarity with Rust, but I find none of the examples cursed or surprising, except the "&* is useful" one. Even for that one, I think the use case of "turning a raw pointer to a reference" actually requires unsafe, and so it's imo a bit misleading to omit that fact. All this is unlike a language i work with in my day job (and hence one would expect that I'd not find surprising), and yet I find so much behavior utterly baffling: https://dev.to/ben/what-is-the-oddest-javascript-behavior-4dh2 https://dev.to/ben/what-is-the-oddest-javascript-behavior-4d...
- desdenova 2y agoCursed article by someone who doesn't know Rust.
- deleted 2y ago[deleted]