3 ms·
The obvious use-case for unsafe is to implement alternative memory regimes that don’t exist in rust already, so you can write safe abstractions over them. Rust
by scratcheee 11mo ago
The obvious use-case for unsafe is to implement alternative memory regimes that don’t exist in rust already, so you can write safe abstractions over them.
Rust doesn’t have the kind of high performance garbage collection you’d want for this, so starting with unsafe makes perfect sense to me. Hopefully they keep the unsafe layer small to minimise mistakes, but it seems reasonable to me.
- amelius 11mo agoI'm curious if it can be done in Rust entirely though. Maybe some assembly instructions are required e.g. for trapping or setting memory fences.
- nicoburns 11mo agoIf it comes to it then Rust has excellent support for inline assembly
- amelius 11mo agoBut how well does it play with memory fences?
- steveklabnik 11mo agoYou don’t even need inline assembly for those https://doc.rust-lang.org/stable/std/sync/atomic/fn.fence.html https://doc.rust-lang.org/stable/std/sync/atomic/fn.fence.ht...