From 87beb53ccd846bc725ffc54af7f60a3308894d80 Mon Sep 17 00:00:00 2001 From: Bradlee Speice Date: Sun, 20 Jan 2019 13:29:38 -0500 Subject: [PATCH] Minor note about protection level during release --- src/lib.rs | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 5e31d2f..cb15e1a 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -263,7 +263,9 @@ macro_rules! assert_no_alloc { static IS_ACTIVE: RwLock = RwLock::new(false); static INTERNAL_ALLOCATION: RwLock = RwLock::new(usize::max_value()); -/// Get the current "protection level" in QADAPT: calls to enter_protected() - exit_protected() +/// Get the current "protection level" in QADAPT: calls to `enter_protected() - exit_protected()`. +/// +/// **Note**: For release builds, `protection_level()` will always return 0. /// /// **Example**: /// @@ -290,11 +292,7 @@ static INTERNAL_ALLOCATION: RwLock = RwLock::new(usize::max_value()); /// // It's now safe to allocate/drop /// } pub fn protection_level() -> usize { - if cfg!(debug_assertions) { - PROTECTION_LEVEL.try_with(|v| *v.read()).unwrap_or(0) - } else { - 0 - } + PROTECTION_LEVEL.try_with(|v| *v.read()).unwrap_or(0) } /// Determine whether qadapt is running as the current global allocator. Useful for