OnceLock

A collection of 1 posts

A Java geek
  • Me
  • Books
  • Speaking
  • Mentions
  • Focus
Jun 1, 2025 Rust lazy_static LazyLock OnceLock

Runtime-initialized variables in Rust

Rust offers different ways to initialize compile time-initialized variables. Recently, I had to create a runtime-initialized variable: existing approaches don’t work in this case. I want to describe multiple ways to achieve it in this post. Constants The Rust language allows you to create constants. Two keywords are available: const and static. Sometimes a certain value is used many times throughout a program, and it can become inconvenient to copy it over and over. What’s more, it’

Nicolas Fränkel
A Java geek © 2008-2025
v. 8b2b5c3b1ea5f9020bfe3e1fa516f531fb5e8cc3/10254800311
Latest Posts