Hashmap section on const/static construction should mention LazyLock
as a way to resolve problems mentioned.
#137566
Labels
A-collections
Area: `std::collections`
A-docs
Area: Documentation for any part of the project, including the compiler, standard library, and tools
needs-triage
This issue may need triage. Remove it if it has been sufficiently triaged.
T-libs
Relevant to the library team, which will review and decide on the PR/issue.
Location
https://doc.rust-lang.org/stable/std/collections/struct.HashMap.html#usage-in-const-and-static
Summary
In the documentation for HashMap, the section on using it in a
static
/const
context mentions that a const seed should be used. However, using aLazyLock<>
to wrap theHashMap
allows it to be constructed with a random seed, which resolves the main problem highlighted at the end of the paragraph.LazyLock
has been stabilized as of rust 1.80The text was updated successfully, but these errors were encountered: