4 ms·
I am fairly sure such constructs require unsafe? https://doc.rust-lang.org/std/mem/union.MaybeUninit.html https://doc.rust-lang.org/std/mem/union.MaybeUninit.ht
by saagarjha 7y ago
I am fairly sure such constructs require unsafe? https://doc.rust-lang.org/std/mem/union.MaybeUninit.html https://doc.rust-lang.org/std/mem/union.MaybeUninit.html
- robalni 7y agoNo, I'm just saying that what memory is allocated (as in the language) is not necessarily the same as the memory that is allocated as in your intentions. It's possible to allocate (as in language) an array that is longer than what you really need, and when you are done using some of the memory in that array you might not want to call any free/realloc functions in order to make the program faster. So instead you might want to just remember that the memory is unallocated (as in intentions) even if it's still allocated (as in language). And now there is a disagreement between you and the language on what memory is allocated. No "memory-safe" language can make sure you don't accidently use memory unintentionally. With that said, languages like Rust really give you helpful tools to minimize the unintentional memory accesses.
- saagarjha 7y agoOh, I guess that is fair.