once_cell
once_cell copied to clipboard
Rust library for single assignment cells and lazy statics without macros
`once_cell` is an extremely widely-used crate, so it would be very nice if it conformed to the stricted/simplest/checkable model we have for aliasing in Rust. To do this, we need...
The main disadvantage of the `Lazy` type over `lazy_static!` is that `Lazy` necessarily stores and calls `fn() -> T` rather than `impl FnOnce() -> T`. This means that any inlining...
adding multiple regexes in the macro will return a tuple with all the regexes, and also allow using an `expr` to compile into the regex. this leaves the original api...
1a) So I understand that I can do: ``` let lazy: Lazy = Lazy::new(|| String::from("hello")); ``` Because: - When you don't specify the 2nd generic it assumes `fn() -> String`...
I have a function for creating the instance and initialising the cell, but in some cases, for instance under testing , i need to reset the cell to a new...
I wanted to implement an evaluate-once cache on a trait, so I stored a OnceCell in an associated const: ```rust //! This module includes the [CryptoDigest] trait, //! which provides...
It seems like `OnceBox` should be able to support unsized types, as the `get_or_init` function expects the initializer to return a box, and stores the value behind a pointer. It...
I have some code where we'd like to use `Lazy` values as fields of structs, which means boxing closures: ```rust type AnyLazy>; ``` The problem is that this type alias...
Isn't it possible to get rid of `Option` in `get()` via typestate pattern (making the method available only for an initialized cell)?