Skip to content

Glossary: Software Design Patterns in Rust

OnceLock

Also written: OnceLock<T>, get_or_init

A standard-library slot that is filled once by the first `get_or_init` call and then hands out the same shared reference. It is Rust's safe way to build a read-only singleton.

Where the book teaches it

Related terms

Singletonstatic