std-method

Mutex::is_poisoned: advisory status

Inspect the current poison flag for diagnostics. In concurrent use another holder can panic after the check. Always inspect the acquisition result rather than relying on a prior flag read. Expected stdout (not executed): false true Common mistake: Using a prior false flag as permission to unwrap all future acquisitions.

Formal Syntax & Structure

rust syntaxrust
m.is_poisoned() -> bool

Working Example

Example Snippetrust
fn main() {    use std::sync::Mutex;    let m = Mutex::new(1);    println!("{} {}", m.is_poisoned(), m.lock().is_ok());}
Rust Reference