Join Nostr
2025-03-27 21:37:48 UTC

gudenau on Nostr: How on earth am I supposed to have a static read only list of structures that ...

How on earth am I supposed to have a static read only list of structures that contains read only opaque C pointers?

I have something akin to
```Rust
#[repr(C)]
pub struct Handle {
_data: [u8; 0],
_marker: PhantomData<...>,
}

struct State {
handle: Handle,
}

static STATE : OnceLock<Vec<State>> = OnceLock::new();
```

and I can't figure out what combination of locks/traits I need to make this "thread safe" even though it's 99% read-only.