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

#1451 in Rust patterns

Download history 1918/week @ 2025-09-01 2447/week @ 2025-09-08 2278/week @ 2025-09-15 2173/week @ 2025-09-22 2157/week @ 2025-09-29 1923/week @ 2025-10-06 2026/week @ 2025-10-13 2118/week @ 2025-10-20 2322/week @ 2025-10-27 1874/week @ 2025-11-03 1189/week @ 2025-11-10 1529/week @ 2025-11-17 1492/week @ 2025-11-24 1303/week @ 2025-12-01 1724/week @ 2025-12-08 220/week @ 2025-12-15

5,016 downloads per month
Used in 21 crates (9 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