Remove reference to static mut

This is what UnsafeCell is for: Providing interior mutability.

The docs at https://doc.rust-lang.org/std/cell/struct.UnsafeCell.html
give an example just like this - `&mut *ptr.get()`

Without, rustc may complain - https://doc.rust-lang.org/nightly/edition-guide/rust-2024/static-mut-references.html
This commit is contained in:
Fabian Boehm 2024-11-28 19:35:36 +01:00
parent 281df5daad
commit 8b464d96af

View File

@ -212,10 +212,10 @@ fn reader_data_stack() -> &'static mut Vec<Pin<Box<ReaderData>>> {
// Safety: only used on main thread.
unsafe impl Sync for ReaderDataStack {}
static mut READER_DATA_STACK: ReaderDataStack = ReaderDataStack(UnsafeCell::new(vec![]));
static READER_DATA_STACK: ReaderDataStack = ReaderDataStack(UnsafeCell::new(vec![]));
assert_is_main_thread();
unsafe { READER_DATA_STACK.0.get_mut() }
unsafe { &mut *READER_DATA_STACK.0.get() }
}
/// Access the top level reader data.