jorendorff / atomicbox

Safe atomic Box types for Rust
Other
22 stars 11 forks source link

Add const fn to generate null AtomicOptionBox? #6

Closed nyanpasu64 closed 2 years ago

nyanpasu64 commented 4 years ago

I was thinking of using AtomicOptionBox in a static variable, which can only be initialized using a const fn. Is the following worth adding to the library?

impl<T> AtomicOptionBox<T> {
    ...
    pub const fn new_none() -> AtomicOptionBox<T> {
        AtomicOptionBox {
            ptr: AtomicPtr::new(null_mut()),
        }
    }
jorendorff commented 2 years ago

Good call. This is in version 0.4.0, thanks to #3 by @kennytm.