Hacker News new | ask | show | jobs
by steveklabnik 456 days 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.

1 comments

True, however I only saw this happens to achieve max perf. I have very limited experience so this is confirmation bias from my end.
An example of unsafe not for performance is when interacting with hardware directly.
or the operating system!

opening stdout with file handle 0 is not guaranteed safe by the compiler. there's an "unsafe" somewhere in there.