matklad / once_cell

Rust library for single assignment cells and lazy statics without macros

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

`critical_section` based `OnceCell` doesn't need `T: Sync`

jedel1043 opened this issue · comments

Correct me if I'm wrong, but critical-section's Mutex allows Mutex<T> even if T: !Sync. However, OnceCell's implementation based on critical-section requires T: Send + Sync, and syncing is precisely the work of the Mutex used. Should this bound be removed?

I think it's important that the API is the same regardless of the synchronization primitive used internally.