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

#919 in Rust patterns

Download history 1208/week @ 2024-03-14 1063/week @ 2024-03-21 717/week @ 2024-03-28 876/week @ 2024-04-04 991/week @ 2024-04-11 1323/week @ 2024-04-18 1318/week @ 2024-04-25 1414/week @ 2024-05-02 869/week @ 2024-05-09 1206/week @ 2024-05-16 1314/week @ 2024-05-23 1661/week @ 2024-05-30 1572/week @ 2024-06-06 1554/week @ 2024-06-13 1688/week @ 2024-06-20 855/week @ 2024-06-27

6,081 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