classicube_helpers\traits/
cell.rs

1use std::{cell::Cell, thread::LocalKey};
2
3pub trait CellGetSet<T> {
4    fn get(&'static self) -> T;
5    fn set(&'static self, value: T);
6}
7
8impl<T> CellGetSet<T> for LocalKey<Cell<T>>
9where
10    T: Copy,
11{
12    fn get(&'static self) -> T {
13        self.with(Cell::get)
14    }
15
16    fn set(&'static self, value: T) {
17        self.with(|cell| cell.set(value));
18    }
19}