Created
October 23, 2017 17:51
-
-
Save lf94/1c8871c5efa739377d43f8db958037ce 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
pub fn reply(message: &str) -> &str { | |
let chrs = || message.trim().chars(); | |
let has_text = chrs().any(|c| c.is_alphanumeric()); | |
let has_letters = chrs().any(|c| c.is_alphabetic()); | |
let has_lowercase = chrs().any(|c| c.is_alphabetic() && !c.is_uppercase()); | |
if has_letters && has_text && !has_lowercase { "Whoa, chill out!" } | |
else if chrs().as_str().ends_with("?") { "Sure." } | |
else if !has_text { "Fine. Be that way!" } | |
else { "Whatever." } | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment