5 ms·
You can't do that using anything here? https://doc.rust-lang.org/std/mem/index.html https://doc.rust-lang.org/std/mem/index.html Genuine question, I don't mes
by ipodopt 5y ago
You can't do that using anything here?
https://doc.rust-lang.org/std/mem/index.html https://doc.rust-lang.org/std/mem/index.html
Genuine question, I don't mess around with memory typically.
- eximius 5y agoforget takes owned values. So you wouldn't have a handle to them to use after.
- pornel 5y agomem::forget() is not crashy like free(). It merely prevents destructors from being run (e.g. you could do the same by storing the value in a global variable). It's a safe method, subject to usual safety checks. You can use an `unsafe {}` block to call literally libc::free(), or dereference a random raw C pointer, or do something else crashy. However, when talking about Rust's safety rules it's usually assumed we're not talking about code bypassing these rules on purpose.