Sha256: 34ff93691d91d27110c35c2b330bf171fc5378efdcba0c954b8bdac369550eb9
Contents?: true
Size: 617 Bytes
Versions: 102
Compression:
Stored size: 617 Bytes
Contents
pub fn reply(message: &str) -> &str { if is_silence(message) { "Fine. Be that way!" } else if is_yelling(message) && is_question(message) { "Calm down, I know what I'm doing!" } else if is_yelling(message) { "Whoa, chill out!" } else if is_question(message) { "Sure." } else { "Whatever." } } fn is_silence(message: &str) -> bool { message.trim().is_empty() } fn is_yelling(message: &str) -> bool { let s = message.trim_matches(|c: char| !c.is_alphabetic()); !s.is_empty() && s.to_uppercase() == s } fn is_question(message: &str) -> bool { message.trim_right().ends_with("?") }
Version data entries
102 entries across 102 versions & 1 rubygems