# matklad/once_cell

Rust library for single assignment cells and lazy statics without macros

Repository: https://github.com/matklad/once_cell
Canonical: https://ross.abutalabs.com/products/once_cell
Language: Rust
License: Apache-2.0
License Family: permissive
Topics: rust, lazy-evaluation
Last push: 2026-03-12T10:59:54+00:00

## Health v2 (maintenance only)
Score: 64/100 (v2, computed 2026-09-03T02:20:16.233290+00:00)
- activity 71, release rhythm 35, longevity 100
- inputs: {"age_days": 2954, "days_push": 174, "days_rel": null, "gap_med": null, "n_releases_24m": 0}
- flags: no_releases
- formula: round(0.45*activity + 0.35*rhythm + 0.20*longevity); archived -> min(score, 10)

## Adoption (not part of the score)
Stars 2089, forks 124 (observed 2026-08-28T04:06:12.201821+00:00)

## What it is
A Rust library providing single assignment cells (OnceCell) and lazy initialization types (Lazy) without macros. It offers a macro-free alternative to lazy_static! with sync and unsync variants.

## Use cases
- initialize global static data lazily in Rust
- replace lazy_static! macro with plain code
- store a value that is assigned at most once
- share lazily-built HashMap or Mutex across threads
- defer expensive computation until first access

## When to choose
- you need lazy statics or single-assignment cells in Rust without macros
- you want a minimal, widely-adopted dependency for lazy initialization
- you need both thread-safe and single-threaded lazy cell variants

## When to avoid
- you are on Rust 1.70+ and std's OnceCell/LazyLock suffice
- you need reassignment or interior mutability beyond single assignment
- you need async-aware lazy initialization (consider async_once_cell)

## Facets
- artifact type: library
- maturity: stable
- function: concurrency, developer-tools
- domain: developer-tools, programming-languages
- platform: rust, cross-platform
- tags: lazy-static, single-assignment, no-macros, initialization

## Member repositories
- matklad/once_cell (main) score 64

## Provenance
- Observed fields: from GitHub, fetched 2026-08-28T04:06:12.201821+00:00.
- Health v2: computed from the inputs above; adoption is never an input.
- Inferred fields (summary, facets, guidance): AI-extracted, prompt v1, taxonomy v1, on 2026-08-30T02:55:39.145396+00:00, confidence not recorded.
  - readme: https://github.com/matklad/once_cell (fetched 2026-08-28T04:06:12.201821+00:00, sha 2331182c8b5a)
  - registry_crates: https://crates.io/api/v1/crates/once_cell (fetched 2026-08-29T10:35:24.190732+00:00, sha 80c08459fb86)
- Data as of 2026-08-30T08:39:29.467469+00:00.
