matklad / once_cell

Rust library for single assignment cells and lazy statics without macros
Apache License 2.0
1.87k stars 109 forks source link

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

Closed jedel1043 closed 1 year ago

jedel1043 commented 1 year ago

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?

matklad commented 1 year ago

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