pranaless

joined 1 year ago
[–] pranaless@beehaw.org 3 points 1 year ago (1 children)

OnceLock is the wrong primitive for this. Use a Mutex or an RwLock instead? You can initialize either of them with an empty array at declaration, so you don't need the set_log function. In push_log, do a .lock().unwrap() for a mutex or .write().unwrap() for an rwlock to get mutable access to the vector.