Mutex not dropped between function arguments?

Viewed 51

I understand that the following code hangs because the Mutex doesn't get dropped between the arguments (I switched to a RwLock to duck the problem), but ... why not? I presume this is specified somewhere but I don't seem to be able to hunt it down from the Rust docs.

Thanks.

use std::sync::{RwLock, Mutex};

pub struct Generic {
    ff: bool,
}

fn test_hang(ff0: bool, ff1: bool) {
    println!("Test: {} {}", ff0, ff1);
}

fn main() {
    let mm = Mutex::new(Generic {ff: true} );
    
    test_hang(mm.lock().unwrap().ff, mm.lock().unwrap().ff);
}

https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=5775de7bef67fe5ac448329e7c7af22e

0 Answers
Related