Closed danielhenrymantilla closed 1 year ago
Self::force() has to synchronize the access to the raw value and/or its needed initialization, given its &-based API, but force_mut() does not, thanks to the guarantees of &mut access (e.g., https://doc.rust-lang.org/stable/std/cell/struct.UnsafeCell.html#method.get_mut).
Self::force()
&
force_mut()
&mut
But the current implementation of force_mut() just defers to force():
force()
https://github.com/matklad/once_cell/blob/35148638c54c6233545c65d1a5e09d5ba0661806/src/lib.rs#L767-L770
Yup, this indeed should be improved!
Self::force()
has to synchronize the access to the raw value and/or its needed initialization, given its&
-based API, butforce_mut()
does not, thanks to the guarantees of&mut
access (e.g., https://doc.rust-lang.org/stable/std/cell/struct.UnsafeCell.html#method.get_mut).But the current implementation of
force_mut()
just defers toforce()
:https://github.com/matklad/once_cell/blob/35148638c54c6233545c65d1a5e09d5ba0661806/src/lib.rs#L767-L770