Created
September 24, 2018 08:25
-
-
Save shakyShane/ed7d6e69e3283ce98f5563502109c8d4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// | |
/// A simple way to apply both a predicate | |
/// and default value when dealing with an option. | |
/// | |
fn is_legal(age: Option<usize>) -> bool { | |
age.map(|x| x >= 18).unwrap_or(false) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment