summary refs log tree commit diff
path: root/library/std/src/sync/lazy_lock.rs
AgeCommit message (Collapse)AuthorLines
2024-06-10replace version placeholderPietro Albini-11/+11
2024-06-02Move first OnceLock example to LazyLockJubilee Young-22/+14
This example is spiritually an example of LazyLock, as it computes a variable at runtime but accepts no inputs into that process. It is also slightly simpler and thus easier to understand. Change it to an even-more concise version and move it to LazyLock. The example now editorializes slightly more. This may be unnecessary, but it can be educational for the reader.
2024-05-28update tracking issue for lazy_cell_consumeTrevor Spiteri-1/+1
2024-02-20Stabilize `LazyCell` and `LazyLock` (`lazy_cell`)Peter Jaszkowiak-18/+23
2024-01-14std: Doc blocking behavior of LazyLock methodsBehnam Esfahbod-6/+15
2023-07-31Rollup merge of #109318 - joboet:better_fmt_placeholder, r=dtolnayMatthias Krüger-3/+5
Make `Debug` representations of `[Lazy, Once]*[Cell, Lock]` consistent with `Mutex` and `RwLock` `Mutex` prints `<locked>` as a field value when its inner value cannot be accessed, but the lazy types print a fixed string like "`OnceCell(Uninit)`". This could cause confusion if the inner type is a unit type named `Uninit` and does not respect the pretty-printing flag. With this change, the format message is now "`OnceCell(<uninit>)`", consistent with `Mutex`.
2023-07-30Rollup merge of #109075 - joboet:lazylock_backtrace, r=workingjubileeJubilee-0/+9
Use `LazyLock` to lazily resolve backtraces By using TAIT to name the initializing closure, `LazyLock` can be used to replace the current `LazilyResolvedCapture`.
2023-07-25docs(LazyLock): add example pass local LazyLock variable to structDragonBillow-0/+20
Signed-off-by: DragonBillow <DragonBillow@outlook.com>
2023-04-27std: use `LazyLock` to lazily resolve backtracesjoboet-0/+9
2023-04-19std: make `Debug` representations of `[Lazy, Once]*[Cell, Lock]` consistent ↵joboet-3/+5
with `Mutex` and `RwLock` `Mutex` prints `<locked>` as a field value when its inner value cannot be accessed, but the lazy types print a fixed string like "`OnceCell(Uninit)`". This could cause confusion if the inner type is a unit type named `Uninit` and does not respect the pretty-printing flag. With this change, the format message is now "`OnceCell(<uninit>)`", consistent with `Mutex`.
2023-04-14Add Lazy{Cell,Lock}::into_innerAlex Saveau-1/+37
Signed-off-by: Alex Saveau <saveau.alexandre@gmail.com>
2023-03-29Stabilize a portion of 'once_cell'Trevor Gross-12/+12
Move items not part of this stabilization to 'lazy_cell' or 'once_cell_try'
2023-01-27std: add safety comment in `LazyLock::get`joboet-1/+8
2023-01-27std: fix `Debug` implementation on `LazyLock`joboet-8/+5
2023-01-26std: optimize `LazyLock` sizejoboet-16/+66
2022-12-30Auto merge of #105651 - tgross35:once-cell-inline, r=m-ou-sebors-0/+5
Add #[inline] markers to once_cell methods Added inline markers to all simple methods under the `once_cell` feature. Relates to #74465 and #105587 This should not block #105587
2022-12-27Rollup merge of #103718 - matklad:infer-lazy, r=dtolnayMichael Goulet-4/+1
More inference-friendly API for lazy The signature for new was ``` fn new<F>(f: F) -> Lazy<T, F> ``` Notably, with `F` unconstrained, `T` can be literally anything, and just `let _ = Lazy::new(|| 92)` would not typecheck. This historiacally was a necessity -- `new` is a `const` function, it couldn't have any bounds. Today though, we can move `new` under the `F: FnOnce() -> T` bound, which gives the compiler enough data to infer the type of T from closure.
2022-12-13Add #[inline] marker to OnceCell/LazyCell/OnceLock/LazyLockTrevor Gross-0/+5
2022-11-17Properly link `{Once,Lazy}{Cell,Lock}` in docsMaybe Waffle-1/+3
2022-10-29More inference-friendly API for lazyAleksey Kladov-4/+1
The signature for new was ``` fn new<F>(f: F) -> Lazy<T, F> ``` Notably, with `F` unconstrained, `T` can be literally anything, and just `let _ = Lazy::new(|| 92)` would not typecheck. This historiacally was a necessity -- `new` is a `const` function, it couldn't have any bounds. Today though, we can move `new` under the `F: FnOnce() -> T` bound, which gives the compiler enough data to infer the type of T from closure.
2022-06-16Move/rename `lazy::Sync{OnceCell,Lazy}` to `sync::{Once,Lazy}Lock`Maybe Waffle-0/+121