HN user

challengerapp

0 karma
Posts0
Comments1
View on HN
No posts found.

A challenge:

In the below code snippet, that it is assumed was gotten on GitHub or a documentation site or somewhere else, you are not allowed to figure out which edition the code is meant for. You must tell, without knowing the edition, whether the code has a deadlock or not. You may not assume a specific edition.

fn f(value: &RwLock<Option<bool>>) {

    if let Some(x) = *value.read().unwrap() {

        println!("value is {x}");

    } else {

        let mut v = value.write().unwrap();

        if v.is_none() {

            *v = Some(true);

        }

    }
}

If you are not able to, you must delete all your social media accounts and never comment on any topic related to programming languages or Rust ever again.