Hacker News new | ask | show | jobs
by iopq 1093 days ago
If you don't use `unsafe` then it guarantees it barring compiler mistakes. The compiler has had issues with memory safety before, they were found, and they were fixed. There might be some left lurking, but they are extremely unlikely since people are using it in production and haven't seen anything weird.

If you use `unsafe` you have to make sure of it yourself, but you can easily grep for this keyword and see where the monsters lurk.

2 comments

The issue is that any Rust code is going to be targeted at performance processing (since otherwise you would write it in a higher level language). And for performance processing, you need to use unsafe (because at some point, the most efficient thing is getting or setting data at a certain memory address without anything extra). Look at any big Rust project, like Amazon Firecracker, and its littered with unsafes.
You really don't, I worked on a Rust project:

https://github.com/ujh/iomrascalai

it doesn't need unsafe code despite being performance-optimized

If you use any language with garbage collection then you won't have memory safety problems (barring unusual corner cases). That is an actual guarantee of memory safety.