5 ms·
I thought that the point of Rust is to have safe {} blocks (implicit) as a default and unsafe {} when you need the absolute maximum performance available. You c
by datadeft 2y ago
I thought that the point of Rust is to have safe {} blocks (implicit) as a default and unsafe {} when you need the absolute maximum performance available. You can audit those few lines of unsafe code very easily. With C everything is unsafe and you can just forget to call free() or call it twice and you are done.
- steveklabnik 2y ago> unsafe {} when you need the absolute maximum performance available. Unsafe code is not inherently faster than safe code, though sometimes, it is. Unsafe is for when you want to do something that is legal, but the compiler cannot understand that it is legal.
- datadeft 2y agoTrue, however I only saw this happens to achieve max perf. I have very limited experience so this is confirmation bias from my end.
- steveklabnik 2y agoAn example of unsafe not for performance is when interacting with hardware directly.
- deleted 2y ago[deleted]
- ycombinatrix 2y agoor the operating system! opening stdout with file handle 0 is not guaranteed safe by the compiler. there's an "unsafe" somewhere in there.
- WD-42 2y agoIt’s not about performance, it’s about undefined behavior.