Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

This is my first Rust project, so if you are an expert I would love a code review!

Seeing a few uses of `unsafe`, a few of `expect`. Wonder if you can mmap the binary model in without unsafe??



> Wonder if you can mmap the binary model in without unsafe??

Some operating systems do provide the proper guarantees to make mmap safe, but Rust decided it would be best to assume it's unsafe and maintain a uniform API. Which is probably a good call, it is notoriously difficult to get a readonly mmap to be entirely safe on Linux.

https://docs.rs/mmap-rs/latest/mmap_rs/struct.MmapOptions.ht...


It’s not safe under Rust’s definition of safe.

If you map the file into readonly memory and than get references to it, the underlying memory can mutate (eg: by modifying the file itself).




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: