You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The BrowserHistory initialization could be optimized / simplified a bit by using OnceCell instead of RefCell<Option<_>>. However, this would raise the MSRV to 1.70. Are you interested in a PR?
The text was updated successfully, but these errors were encountered:
Unlike a Send + Sync static, RefCell<Option<_>> does not have any racing conditions as it will not be able to execute any other code until the init sequence finished executing.
I think the better solution is to use std::cell::LazyCell in which a lazy initialisation is guaranteed to happen once.
Given I cannot see any downside and LazyCell seems to be a better candidate for this use case, I would prefer to wait until LazyCell is stabilised and switch to LazyCell directly.
I will keep this issue open so we can track the stabilisation process of LazyCell.
OnceCell also guarantees that it's only initialized once, LazyCell is simply a slightly less general but more convenient type on top of OnceCell. Also no race conditions are possible, we are talking about thread_local variables here.
The
BrowserHistory
initialization could be optimized / simplified a bit by usingOnceCell
instead ofRefCell<Option<_>>
. However, this would raise the MSRV to 1.70. Are you interested in a PR?The text was updated successfully, but these errors were encountered: