parking_lot icon indicating copy to clipboard operation
parking_lot copied to clipboard

[Feature Request] Create `OnceLock` and `OnceCell` using this library's Once

Open BLucky-gh opened this issue 10 months ago • 3 comments

Since unlike Mutex, you can't specify which underlying Once to use with std::sync::OnceLock and std::cell::OnceCell, I would either have to roll my own, which seems wasteful and will not update when the std versions get changed, or manage the value and the Once separately like in the Once example, which is error-prone and puts the burden of upholding invariants on the developer

BLucky-gh avatar Apr 26 '24 18:04 BLucky-gh

I would be happy to accept a PR for it, but it is not something I have time to work on myself.

Amanieu avatar Apr 26 '24 19:04 Amanieu

I could try making a PR for it, but it will probably be almost entirely just a copy paste of the std implementation and just changing the import from std::sync::Once to parking_lot::Once, would that be any good?

BLucky-gh avatar Apr 27 '24 12:04 BLucky-gh

That's fine.

Amanieu avatar Apr 27 '24 14:04 Amanieu