7
submitted 1 year ago by danyel@lemmyrs.org to c/support@lemmyrs.org

I've been using lazy_static until now but was trying to migrate to OnceCell. It seems I can't have a OnceCell even though I'm never calling mutable methods on the regex. I'm not even using multiple threads.

The error I'm getting is:

Any way to solve this or do I have to use OnceLock / continue using lazy_static? I don't want to add the overhead of using OnceLock if not necessary.

you are viewing a single comment's thread
view the rest of the comments
[-] Aloso@lemmyrs.org 5 points 1 year ago

Yeah, it doesn't help that in the once_cell crate, the thread-safe version was also called OnceCell; you had to choose between once_cell::sync::OnceCell and once_cell::unsync::OnceCell. But when it was added to the standard library, once_cell::sync::OnceCell was renamed to OnceLock to make them easier distinguishable. So

this post was submitted on 14 Jun 2023
7 points (100.0% liked)

Rust: Support

3 readers
1 users here now

Rules

founded 1 year ago
MODERATORS