Closed
Description
Location
https://doc.rust-lang.org/std/sync/struct.LazyLock.html
https://doc.rust-lang.org/std/sync/struct.OnceLock.html
https://doc.rust-lang.org/std/cell/struct.OnceCell.html
https://doc.rust-lang.org/std/cell/struct.LazyCell.html
Summary
Today I realized these are separate types. I used the experimental LazyLock
before without realizing I can actually use stable OnceLock
. These types are so similar that I never realized there are two of them.
Still, I don't think I quite understand the difference and the tradeoff (e.g. is some of them faster or not?). It would be useful if the docs pages linked to each other and explained the difference.