fn is_title_case(s: &str) -> bool {
for word in s.split_whitespace() {
let mut chars = word.chars();
match chars.next() {
Some(first) if first.is_uppercase() => (),
_ => return false,
}
if chars.any(|c| !c.is_lowercase()) {
return false;
}
}
true
}
fn main() {
println!("{}", is_title_case("Hello World")); // true
println!("{}", is_title_case("Hello world")); // false
}
/*
run:
true
false
*/