| 1 | #![allow(clippy::module_name_repetitions)] |
| 2 | |
| 3 | use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::errorrust-analyzer cargo std https://github.com/rust-lang/rust/library/std error/::Errorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core error/Error# as StdErrorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core error/Error#; |
| 4 | use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::fmtrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc fmt/::{selfrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc fmt/, Displayrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Display#}; |
| 5 | use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::syncrust-analyzer cargo std https://github.com/rust-lang/rust/library/std sync/::atomicrust-analyzer cargo core https://github.com/rust-lang/rust/library/core sync/atomic/::{AtomicBoolrust-analyzer cargo core https://github.com/rust-lang/rust/library/core sync/atomic/AtomicBool#, Orderingrust-analyzer cargo core https://github.com/rust-lang/rust/library/core sync/atomic/Ordering#}; |
| 6 | use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::syncrust-analyzer cargo std https://github.com/rust-lang/rust/library/std sync/::Arcrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc sync/Arc#; |
| 7 | |
| 8 | #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:)] |
| 9 | pub struct Flagrust-analyzer cargo anyhow 1.0.103 drop/Flag# { |
| 10 | atomicrust-analyzer cargo anyhow 1.0.103 drop/Flag#atomic.: Arcrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc sync/Arc#<AtomicBoolrust-analyzer cargo core https://github.com/rust-lang/rust/library/core sync/atomic/AtomicBool#>, |
| 11 | } |
| 12 | |
| 13 | impl Flagrust-analyzer cargo anyhow 1.0.103 drop/Flag# { |
| 14 | pub fn newrust-analyzer cargo anyhow 1.0.103 drop/impl#[Flag]new().() -> Selfrust-analyzer cargo anyhow 1.0.103 drop/impl#[Flag] { |
| 15 | Flagrust-analyzer cargo anyhow 1.0.103 drop/Flag# { |
| 16 | atomicrust-analyzer cargo anyhow 1.0.103 drop/Flag#atomic.: Arcrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc sync/Arc#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc sync/impl#[`Arc<T>`]new().(AtomicBoolrust-analyzer cargo core https://github.com/rust-lang/rust/library/core sync/atomic/AtomicBool#::newrust-analyzer cargo core https://github.com/rust-lang/rust/library/core sync/atomic/impl#[AtomicBool]new().(false)), |
| 17 | } |
| 18 | } |
| 19 | |
| 20 | pub fn getrust-analyzer cargo anyhow 1.0.103 drop/impl#[Flag]get().(&self) -> bool { |
| 21 | self.atomicrust-analyzer cargo anyhow 1.0.103 drop/Flag#atomic..loadrust-analyzer cargo core https://github.com/rust-lang/rust/library/core sync/atomic/impl#[AtomicBool]load().(Orderingrust-analyzer cargo core https://github.com/rust-lang/rust/library/core sync/atomic/Ordering#::Relaxedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core sync/atomic/Ordering#Relaxed#) |
| 22 | } |
| 23 | } |
| 24 | |
| 25 | #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:)] |
| 26 | pub struct DetectDroprust-analyzer cargo anyhow 1.0.103 drop/DetectDrop# { |
| 27 | has_droppedrust-analyzer cargo anyhow 1.0.103 drop/DetectDrop#has_dropped.: Flagrust-analyzer cargo anyhow 1.0.103 drop/Flag#, |
| 28 | } |
| 29 | |
| 30 | impl DetectDroprust-analyzer cargo anyhow 1.0.103 drop/DetectDrop# { |
| 31 | pub fn newrust-analyzer cargo anyhow 1.0.103 drop/impl#[DetectDrop]new().(has_dropped: &Flagrust-analyzer cargo anyhow 1.0.103 drop/Flag#) -> Selfrust-analyzer cargo anyhow 1.0.103 drop/impl#[DetectDrop] { |
| 32 | DetectDroprust-analyzer cargo anyhow 1.0.103 drop/DetectDrop# { |
| 33 | has_droppedrust-analyzer cargo anyhow 1.0.103 drop/DetectDrop#has_dropped.: Flagrust-analyzer cargo anyhow 1.0.103 drop/Flag# { |
| 34 | atomicrust-analyzer cargo anyhow 1.0.103 drop/Flag#atomic.: Arcrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc sync/Arc#::clonerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc sync/impl#[`Arc<T, A>`][Clone]clone().(&has_dropped.atomicrust-analyzer cargo anyhow 1.0.103 drop/Flag#atomic.), |
| 35 | }, |
| 36 | } |
| 37 | } |
| 38 | } |
| 39 | |
| 40 | impl StdErrorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core error/Error# for DetectDroprust-analyzer cargo anyhow 1.0.103 drop/DetectDrop# {} |
| 41 | |
| 42 | impl Displayrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Display# for DetectDroprust-analyzer cargo anyhow 1.0.103 drop/DetectDrop# { |
| 43 | fn fmtrust-analyzer cargo anyhow 1.0.103 drop/impl#[DetectDrop][Display]fmt().(&self, f: &mut fmtrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc fmt/::Formatterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Formatter#) -> fmtrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc fmt/::Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Result# { |
| 44 | writerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/write!!(f, "oh no!") |
| 45 | } |
| 46 | } |
| 47 | |
| 48 | impl Droprust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/drop/Drop# for DetectDroprust-analyzer cargo anyhow 1.0.103 drop/DetectDrop# { |
| 49 | fn droprust-analyzer cargo anyhow 1.0.103 drop/impl#[DetectDrop][Drop]drop().(&mut self) { |
| 50 | let already_dropped = self.has_droppedrust-analyzer cargo anyhow 1.0.103 drop/DetectDrop#has_dropped..atomicrust-analyzer cargo anyhow 1.0.103 drop/Flag#atomic..swaprust-analyzer cargo core https://github.com/rust-lang/rust/library/core sync/atomic/impl#[AtomicBool]swap().(true, Orderingrust-analyzer cargo core https://github.com/rust-lang/rust/library/core sync/atomic/Ordering#::Relaxedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core sync/atomic/Ordering#Relaxed#); |
| 51 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(!rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().already_dropped); |
| 52 | } |
| 53 | } |