Originally posted by cb88
View Post
The only affect of the compile-time checks in Rust are the compile-time behavior, and therefore the way that you write software to adhere to the borrowing and ownership model. It either compiles or fails to compile, and that's the extent of the safety checks.
Unsafe methods don't use less memory than safe ones. Unsafe operations are simply actions like making direct system calls, dereferencing a raw pointer, or accessing data from an array without validating that the data is in bounds.
These aren't typically being used for the purpose of using less memory. It's to get access to special features like SIMD, low level file operations with the kernel such as io_uring, use of inline assembly, or the implementation of some novel technique in a research paper to create a safe interface for it. That last one is typically verified with Miri to ensure soundness.
I think you're confusing the bad practice of beginner's cloning memory that doesn't need to be cloned with memory consumption. You don't need to reach for unsafe methods to manage memory efficiently. You just have to understand the aliasing XOR mutability model and design software with that in mind from the start.
Comment