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

#723 in Rust patterns

Download history 2966/week @ 2024-12-10 1897/week @ 2024-12-17 472/week @ 2024-12-24 1007/week @ 2024-12-31 2830/week @ 2025-01-07 2782/week @ 2025-01-14 3734/week @ 2025-01-21 4418/week @ 2025-01-28 6560/week @ 2025-02-04 5365/week @ 2025-02-11 4063/week @ 2025-02-18 7136/week @ 2025-02-25 5253/week @ 2025-03-04 5156/week @ 2025-03-11 5457/week @ 2025-03-18 4006/week @ 2025-03-25

21,034 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