Skip to main content

no_drop/
lib.rs

1#![no_std]
2#![doc = include_str!("../README.md")]
3#![warn(clippy::pedantic, clippy::cargo, clippy::nursery)]
4#![warn(missing_docs, missing_debug_implementations)]
5#![allow(clippy::match_bool, clippy::single_match_else)]
6
7#[cfg(feature = "alloc")]
8extern crate alloc;
9
10/// Internal default panic message used by Empty variant types.
11pub(crate) const DEFAULT_DROP_PANIC_MSG: &str = "Value was dropped without being unwrapped";
12
13#[doc(hidden)]
14pub mod guards;
15
16#[doc(hidden)]
17pub mod markers;
18
19#[doc(hidden)]
20pub mod wrap;
21
22/// Module containing [`NoDrop`](wrap::NoDropEmpty) and [`NoDropMsg`](wrap::NoDropMsg)
23/// with debug-only panic behavior.
24pub mod dbg {
25    pub use crate::guards::GuardNotArmed;
26
27    #[cfg(debug_assertions)]
28    pub use crate::wrap::NoDrop;
29
30    #[cfg(not(debug_assertions))]
31    pub use crate::wrap::NoDropNoOpEmpty as NoDropEmpty;
32
33    #[cfg(feature = "alloc")]
34    #[cfg(debug_assertions)]
35    pub use crate::wrap::NoDropMsg;
36
37    #[cfg(feature = "alloc")]
38    #[cfg(not(debug_assertions))]
39    pub use crate::wrap::NoDropNoOpMsg as NoDropMsg;
40
41    #[cfg(debug_assertions)]
42    pub use crate::guards::DropGuardEmpty;
43
44    #[cfg(not(debug_assertions))]
45    pub use crate::guards::DropGuardNoOpEmpty as DropGuardEmpty;
46
47    #[cfg(feature = "alloc")]
48    #[cfg(debug_assertions)]
49    pub use crate::guards::DropGuard;
50
51    #[cfg(feature = "alloc")]
52    #[cfg(not(debug_assertions))]
53    pub use crate::guards::DropGuardNoOpMsg as DropGuard;
54}
55
56/// Module containing [`NoDrop`](wrap::NoDropEmpty) and [`NoDropMsg`](wrap::NoDropMsg) with always-[`panic!`]ing behavior.
57pub mod rls {
58    pub use crate::guards::GuardNotArmed;
59
60    pub use crate::wrap::NoDrop;
61
62    #[cfg(feature = "alloc")]
63    pub use crate::wrap::NoDropMsg;
64
65    pub use crate::guards::DropGuardEmpty;
66
67    #[cfg(feature = "alloc")]
68    pub use crate::guards::DropGuard;
69}