Broption - for when you need more bro's in your ption's

how is this for most egregious use of unsafe in 2023? broption - Rust

Panic in drop is generally regarded as a very bad idea. See https://github.com/rust-lang/lang-team/issues/97 and Don't allow unwinding from Drop impls by Amanieu · Pull Request #3288 · rust-lang/rfcs · GitHub

Not particularly relevant here since the type is never meaningfully exposed to the user in any way that matters. (It's only ever exposed as a &mut, but there's no way to take it out. take_mut doesn't count because that aborts on unwind or if the &mut is empty or whatnot.)

Unlike catch_unwind this avoids us from needing to handle panic-on-drop ourselves. Instead, the runtime does it for us. But yes, arguably there's a better way of doing it that still maintains the semantics necessary for soundness.

We suppose panic-on-drop is more strict than what we need for soundness, since the only way to get at the 'static is to have it returned.

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.