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

#784 in Rust patterns

Download history 1924/week @ 2023-10-20 1695/week @ 2023-10-27 1432/week @ 2023-11-03 1416/week @ 2023-11-10 1091/week @ 2023-11-17 1047/week @ 2023-11-24 949/week @ 2023-12-01 1062/week @ 2023-12-08 1357/week @ 2023-12-15 719/week @ 2023-12-22 651/week @ 2023-12-29 905/week @ 2024-01-05 950/week @ 2024-01-12 1255/week @ 2024-01-19 1022/week @ 2024-01-26 785/week @ 2024-02-02

4,186 downloads per month
Used in 16 crates (7 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