October 2019
Intermediate to advanced
444 pages
10h 37m
English
Since we are exploring a built-in library feature, we'll create several tests that cover everything:
#[test] #[should_panic] fn option_unwrap() { // Options to unwrap Options assert_eq!(Some(10).unwrap(), 10); assert_eq!(None.unwrap_or(10), 10); assert_eq!(None.unwrap_or_else(|| 5 * 2), 10); Option::<i32>::None.unwrap(); Option::<i32>::None.expect("Better say something when panicking"); }
Read now
Unlock full access