cloudflare/pingora

Replace once_cell dependency with std LazyLock and OnceLock

Open

#721 geöffnet am 2. Nov. 2025

Auf GitHub ansehen
 (0 Kommentare) (0 Reaktionen) (0 zugewiesene Personen)Rust (1.642 Forks)batch import
help wanted

Repository-Metriken

Stars
 (26.634 Stars)
PR-Merge-Metriken
 (Durchschn. Merge 1T 15h) (3 gemergte PRs in 30 T)

Beschreibung

What is the problem your feature solves, or the need it fulfills?

once_cell provides lazy initialization primitives (Lazy, OnceCell). It's now in the standard library as LazyLock and OnceLock. Continuing to use once_cell adds an unnecessary external dependency when the same functionality is now available natively in Rust's standard library.

Describe the solution you'd like

replace all it's usages with the standard library equivalents as it will be a 1 to 1 replacement:

  • once_cell::sync::Lazy -> std::sync::LazyLock
  • once_cell::sync::OnceCell -> std::sync::OnceLock

except for try_insert(), found in pingora-runtime/src/lib.rs, as it is not stable yet issue, it's alternative would be doing set() then get().unwrap() till it gets stabilized.

Describe alternatives you've considered

Keep using once_cell

Contributor Guide