October 2019
Intermediate to advanced
444 pages
10h 37m
English
Here are some steps for working with Result and Option:
/// /// Finds a needle in a haystack, returns -1 on error /// pub fn bad_practice_find(needle: &str, haystack: &str) -> i32 { haystack.find(needle).map(|p| p as i32).unwrap_or(-1)}
/// /// Finds a needle in a haystack, returns None on error /// pub fn better_find(needle: &str, haystack: &str) -> Option<usize> { haystack.find(needle) ...Read now
Unlock full access