3 ms·
A Practical Analysis of Rust's Concurrency Story
- ordu 8y ago> 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 }) }