• 2 Posts
  • 13 Comments
Joined 1 year ago
cake
Cake day: July 5th, 2023

help-circle





  • Ah I didn’t realize most people have moved onto OnceCell. The issue with both lazy static and oncecell is that they can only be assigned to once. You need a global mutable state, so neither OnceCell or lazy_static are the right choice.

    You’re going to be fighting the borrow checker if you try to have global mutable state. It will bite you eventually. You can potentially use an interior mutablity pattern along with a mutex. Have you looked into interior mutability?