try_drop/handlers/primary/
mod.rs

1//! Manage the primary handler.
2
3use crate::handlers::common::handler::CommonHandler;
4use crate::handlers::common::proxy::TheGreatAbstracter;
5use crate::handlers::common::{Primary, Scope};
6use crate::handlers::on_uninit::ErrorOnUninit;
7use std::marker::PhantomData;
8
9#[macro_use]
10mod macros;
11
12#[cfg(feature = "global")]
13pub mod global;
14
15#[cfg(feature = "thread-local")]
16pub mod thread_local;
17
18#[cfg(all(feature = "global", feature = "thread-local"))]
19pub mod shim;
20
21/// The default thing to do when the primary handler is uninitialized, that is
22/// to panic.
23#[cfg(not(feature = "ds-write"))]
24pub type DefaultOnUninit = crate::handlers::on_uninit::PanicOnUninit;
25
26/// The default thing to do when the primary handler is uninitialized, that is
27/// to use the default strategy. Note that this mutates the primary handler.
28#[cfg(feature = "ds-write")]
29pub type DefaultOnUninit = crate::handlers::on_uninit::UseDefaultOnUninit;
30
31type Abstracter<S> = TheGreatAbstracter<Primary, S>;
32
33impl<S: Scope> CommonHandler<ErrorOnUninit, S, Primary> {
34    pub const ON_UNINIT_ERROR: Self = Self {
35        extra_data: (),
36        _scope: PhantomData,
37    };
38
39    pub fn error_on_uninit() -> Self {
40        Self::ON_UNINIT_ERROR
41    }
42}
43
44impl<S: Scope> CommonHandler<DefaultOnUninit, S, Primary> {
45    pub const DEFAULT: Self = Self {
46        extra_data: (),
47        _scope: PhantomData,
48    };
49}