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

#899 in Rust patterns

Download history 904/week @ 2023-11-20 1010/week @ 2023-11-27 704/week @ 2023-12-04 1096/week @ 2023-12-11 1142/week @ 2023-12-18 497/week @ 2023-12-25 617/week @ 2024-01-01 724/week @ 2024-01-08 850/week @ 2024-01-15 1163/week @ 2024-01-22 965/week @ 2024-01-29 822/week @ 2024-02-05 1268/week @ 2024-02-12 882/week @ 2024-02-19 848/week @ 2024-02-26 1141/week @ 2024-03-04

4,234 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