orx_concurrent_option/
drop.rs

1use crate::{
2    concurrent_option::ConcurrentOption,
3    states::{RESERVED, SOME},
4};
5use core::sync::atomic::Ordering;
6
7impl<T> Drop for ConcurrentOption<T> {
8    #[allow(clippy::panic)]
9    fn drop(&mut self) {
10        match self.state.load(Ordering::Relaxed) {
11            SOME => {
12                let x = unsafe { &mut *self.value.get() };
13                unsafe { x.assume_init_drop() };
14            }
15            RESERVED => {
16                panic!("ConcurrentOption is dropped while its value is being written.")
17            }
18            _ => {}
19        }
20    }
21}