6 ms·
What are some examples of things you "always" need that require unsafe Rust?
by duped 17d ago
What are some examples of things you "always" need that require unsafe Rust?
- yefol 17d ago[dead]
- afdbcreid 17d ago> for instance by causing a stack overflow That's not "for instance", that's literally the only place Rust has unfixable UB on embedded (code on OS has other such things, e.g. reading/writing to `/proc/self/mem`). > projects that need performance often use unsafe You'll be surprised to hear how often it's not needed at all. And when it is, you'll be surprised to hear how many times you can still avoid it with some tricks. Contrary to popular belief, performance isn't the most common reason for unsafe (FFI probably is).
- insanitybit 17d agoI haven't needed `unsafe` for performance since crates like zerocopy etc exist. It's been years, and I've worked hard to shave nanoseconds off of code, using valgrind to measure single digit changes to branch predictions.
- delamon 16d agoObjects belonging to multiple double-linked lists at the same time. Easily done with intrusive lists. Safe rust would require Rc/Arc: penalty both on memory usage and cpu time.