Skip to content

Hashmap section on const/static construction should mention LazyLock as a way to resolve problems mentioned. #137566

Closed
@burtonageo

Description

@burtonageo

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 a LazyLock<> to wrap the HashMap 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.80

Metadata

Metadata

Assignees

Labels

A-collectionsArea: `std::collections`A-docsArea: Documentation for any part of the project, including the compiler, standard library, and toolsE-easyCall for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.T-libsRelevant to the library team, which will review and decide on the PR/issue.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions