Hacker News new | past | comments | ask | show | jobs | submit login
A Practical Analysis of Rust's Concurrency Story (arxiv.org)
16 points by furcyd 21 days ago | hide | past | web | favorite | 1 comment



> we found that it took some effort to remove these unwraps and replace them with match statements or the equivalent.

You may choose to not use match expression. It can be as simple as:

    fn get_val() -> i64 {
        function_returning_result().unwrap_or(-1)
    }
Or if println! there is really needed, then instead of unwrap_or is possible to use unwrap_or_else with a lambda:

    fn get_val() -> i64 {
        function_returning_result()
        .unwrap_or_else(|e| {
            println!("Error occured! {:?}", e);
            -1
        })
    }




Guidelines | FAQ | Support | API | Security | Lists | Bookmarklet | Legal | Apply to YC | Contact

Search: