mirror of
https://github.com/ArthurDanjou/exercism-rust.git
synced 2026-01-24 08:50:28 +01:00
Initial commit
This commit is contained in:
14
bob/src/lib.rs
Normal file
14
bob/src/lib.rs
Normal file
@@ -0,0 +1,14 @@
|
||||
fn is_yelling(message: &str) -> bool {
|
||||
let have_letters: bool = message.chars().filter(|c| c.is_alphabetic()).count() > 0;
|
||||
message.to_uppercase() == message && have_letters
|
||||
}
|
||||
|
||||
pub fn reply(message: &str) -> &str {
|
||||
match message.trim() {
|
||||
m if m.trim().len() == 0 => "Fine. Be that way!",
|
||||
m if m.ends_with("?") && is_yelling(m) => "Calm down, I know what I'm doing!",
|
||||
m if m.ends_with("?") => "Sure.",
|
||||
m if is_yelling(m) => "Whoa, chill out!",
|
||||
_ => "Whatever."
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user