(word: String)
| 1 | pub fn detect_capital_use(word: String) -> bool { |
| 2 | let word_len = word.len(); |
| 3 | let mut count = vec![0, 0]; |
| 4 | let chars = word.chars().collect::<Vec<char>>(); |
| 5 | let first_char = chars[0]; |
| 6 | for c in chars { |
| 7 | if c.is_uppercase() { |
| 8 | count[0] += 1 |
| 9 | } else { |
| 10 | count[1] += 1 |
| 11 | } |
| 12 | } |
| 13 | if count[0] == 0 { |
| 14 | true |
| 15 | } else { |
| 16 | if count[1] == 0 { |
| 17 | true |
| 18 | } else { |
| 19 | count[1] == word_len - 1 && first_char.is_uppercase() |
| 20 | } |
| 21 | } |
| 22 | } |
| 23 | |
| 24 | fn main() { |
| 25 | println!("{:?}", detect_capital_use("USA".to_string())); |
nothing calls this directly
no outgoing calls
no test coverage detected