Skip to content

Instantly share code, notes, and snippets.

@interacsion
interacsion / lib.rs
Last active September 1, 2025 10:24
FallibleLazyLock
use std::cell::UnsafeCell;
use std::mem::ManuallyDrop;
use std::panic::{AssertUnwindSafe, catch_unwind, resume_unwind};
use std::sync::atomic::{AtomicU8, Ordering};
const INITIALIZED_BIT: u8 = 0b01;
const LOCKED_BIT: u8 = 0b10;
union Data<T, F> {
value: ManuallyDrop<T>,