sandbox

14 commits
Updated 2026-04-25 12:39:37
src
src/plop2.rs

pub struct PhantomUndrop<const ALIVE: bool>;

impl PhantomUndrop<true> {
    pub const fn forget(self) -> PhantomUndrop<false> {
        unsafe { core::mem::transmute(self) }
    }
}

impl<const ALIVE: bool> Drop for PhantomUndrop<ALIVE> {
    fn drop(&mut self) {
        const { assert!(!ALIVE) }
    }
}

fn main() {
    let u = PhantomUndrop::<true>;
    u.forget();
}