Initial commit

This commit is contained in:
2022-08-04 23:58:25 +02:00
commit ff1c36fc24
447 changed files with 9869 additions and 0 deletions

14
bob/src/lib.rs Normal file
View 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."
}
}