You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: _2047_number_of_valid_words_in_a_sentence.rs
    path of file: ./repos/rustgym/leetcode/src/d20
    
    the code of the file until where you have to start completion: struct Solution;

impl Solution {
    fn count_valid_words(sentence: String) -> i32 {
        let mut res = 0;
        for word in sentence.split_whitespace() {
            if Solution::is_valid(word) {
                res += 1;
            }
        }
        res
    }

    fn is_valid(s: &str) -> bool {
        let n = s.len();
        let mut h_co
    
    fn is_valid(s: &str) -> bool {
        let n = s.len();
        let mut h_count = 0;
        let s: Vec<char> = s.chars().collect();
        for i in 0..n {
            let c = s[i];
            match c {
                'a'..='z' => {}
                ',' | '!' | '.' => {
                    if i != n - 1 {
                        return false;
                    }
                }
                '-' => {
                    h_count += 1;
                    if i == 0 || i == n - 1 {
                        return false;
                    }
                    if !(('a'..='z').contains(&s[i - 1]) && ('a'..='z').contains(&s[i + 1])) {
                        return false;
                    }
                }
                _ => {
                    return false;
                }
            };
        }
        if h_count > 1 {
            return false;
        }
        true
    }