3 ms·
I write Rust at $WORK. Using `unsafe` to meet a deadline makes 0 sense. It doesn't disable the borrow checker unless you're literally casting references through
by vgel 5y ago
I write Rust at $WORK. Using `unsafe` to meet a deadline makes 0 sense. It doesn't disable the borrow checker unless you're literally casting references through raw pointers to strip lifetimes, which is... insane and would never pass a code review.
99% of the time if you're fighting the borrow checker and just want a quick solution, that solution is `clone` or `Arc<Mutex<T>>`, not `unsafe`. Those solutions will sacrifice performance, but not safety.
- qualudeheart 5y agoMy girlfriend uses Rust for embedded systems at a large and important company. Everyone uses memory safety.
- nyanpasu64 5y ago> Using `unsafe` to meet a deadline makes 0 sense... would never pass a code review. I've seen unsound unchecked casts from &UnsafeCell or *mut to &mut in multiple codebases, including Firefox itself: https://github.com/emu-rs/snes-apu/blob/13c1752c0a9d43a32d0566563815eaa030fc7245/src/dsp/voice.rs#L117-L129 https://github.com/emu-rs/snes-apu/blob/13c1752c0a9d43a32d05..., https://searchfox.org/mozilla-central/rev/7142c947c285e4fe4fada728508b773528a225d8/gfx/wr/webrender/src/compositor/sw_compositor.rs#306 https://searchfox.org/mozilla-central/rev/7142c947c285e4fe4f....