Re: [PATCH v4 1/3] rust: Add `OnceLite` for executing code once
From: jens . korinth
Date: Thu Dec 05 2024 - 01:50:01 EST
I'm afraid you lost me. You wrote:
> Using a Once type for this seems like a good idea to me.
and
> One advantage of using a Once type is that we can use core::sync::atomic
> until we have working LKMM atomics and then we just swap out the Once
> type without having to modify the warn_once abstractions.
That made sense to me, so I started in this direction. `std::sync::Once`
has `is_completed` [1], which made particular sense to implement in my
mind to increase the utility of `OnceLite`.
[1]: https://doc.rust-lang.org/std/sync/struct.Once.html#method.is_completed
> The purpose is to use this for printing once, and printing doesn't need
> `is_completed`. We can have another helper for other purposes.
Why have `OnceLite` then at all, instead of the hidden Rust macro that was
proposed initially?
Jens