7 releases (4 breaking)

Uses old Rust 2015

0.5.1 Aug 1, 2022
0.5.0 Jan 18, 2021
0.4.0 Aug 22, 2020
0.3.0 Jan 18, 2018
0.1.1 Jan 28, 2017

#800 in Rust patterns

Download history 5007/week @ 2024-11-08 4731/week @ 2024-11-15 2951/week @ 2024-11-22 2682/week @ 2024-11-29 2596/week @ 2024-12-06 2657/week @ 2024-12-13 872/week @ 2024-12-20 559/week @ 2024-12-27 2082/week @ 2025-01-03 3160/week @ 2025-01-10 3043/week @ 2025-01-17 4139/week @ 2025-01-24 5940/week @ 2025-01-31 5714/week @ 2025-02-07 2294/week @ 2025-02-14

14,909 downloads per month
Used in 18 crates (8 directly)

Apache-2.0/MIT

14KB
227 lines

A crate for things that are

  1. Lazily initialized
  2. Expensive to create
  3. Immutable after creation
  4. Used on multiple threads

Lazy<T> is better than Mutex<Option<T>> because after creation accessing T does not require any locking, just a single boolean load with Ordering::Acquire (which on x86 is just a compiler barrier, not an actual memory barrier).

No runtime deps