Function checkers::is_muted

source ·
pub fn is_muted() -> bool
Expand description

Test if the crate is currently muted. The allocator is muted by default.

We mute the allocator for allocations we don’t want to be tracked. This is useful to avoid tracing internal allocations.

Examples

assert!(checkers::is_muted());

{
    let _g = checkers::mute_guard(false);
    assert!(!checkers::is_muted());
}

assert!(checkers::is_muted());

checkers::with_unmuted(|| {
    assert!(!checkers::is_muted());
});

assert!(checkers::is_muted());

let result = std::panic::catch_unwind(|| {
    let _g = checkers::mute_guard(false);
    assert!(!checkers::is_muted());
    panic!("uh oh");
});
assert!(result.is_err());
assert!(checkers::is_muted());