/
asmody
/
exercism
Обзор
Документация
Войти
/
asmody
/
exercism
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
rust/bob/src/lib.rs
22 строки
566 B
Viktor Asmody Sakhnov
init
20 дек 2024, 16:33
20 дек 2024, 16:33
5163c44
Код
Авторство
О чём код?
fn is_yelling(message: &str) -> bool { message.chars().any(char::is_alphabetic) && message.to_uppercase() == message } fn is_question(message: &str) -> bool { message.trim().ends_with('?') } pub fn reply(message: &str) -> &str { if message.trim().is_empty() { "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." } }