fn capitalize(string: String) -> String {
    let string_chars = string.chars();

    let mut is_cap = false;
    let mut is_first_char = true;
    let mut chars = Vec::new();

    for character in string_chars {
        if character.is_whitespace() {
            is_cap = true;
            chars.push(character);
        } else {
            if is_cap == true || is_first_char == true {
                let char_upperred = character.to_uppercase();
                let char_stringified = char_upperred.to_string();
                let char_converted = char_stringified.chars();
                for cap in char_converted {
                    chars.push(cap);
                }
                is_cap = false;
                is_first_char = false;
            } else {
                chars.push(character);
            }
        }
    }

    let new_string = chars.into_iter().collect();

    return new_string;
}
/// Capitalize words in String variable.
/// Todo: Simplify code.
Capitalize words in String variable.
Todo: Simplify code.
Capitalize words in String variable . Todo : Simplify code .
fn capitalize(string: String) -> String {
    let string_chars = string.chars();
    let mut is_cap = false;
    let mut is_first_char = true;
    let mut chars = Vec::new();
    for character in string_chars {
        if character.is_whitespace() {
            is_cap = true;
            chars.push(character);
        } else {
            if is_cap == true || is_first_char == true {
                let char_upperred = character.to_uppercase();
                let char_stringified = char_upperred.to_string();
                let char_converted = char_stringified.chars();
                for cap in char_converted {
                    chars.push(cap);
                }
                is_cap = false;
                is_first_char = false;
            } else {
                chars.push(character);
            }
        }
    }
    let new_string = chars.into_iter().collect();
    return new_string;
}
fn capitalize ( string : String ) -> String { let string_chars = string . chars ( ) ; let mut is_cap = false ; let mut is_first_char = true ; let mut chars = Vec :: new ( ) ; for character in string_chars { if character . is_whitespace ( ) { is_cap = true ; chars . push ( character ) ; } else { if is_cap == true || is_first_char == true { let char_upperred = character . to_uppercase ( ) ; let char_stringified = char_upperred . to_string ( ) ; let char_converted = char_stringified . chars ( ) ; for cap in char_converted { chars . push ( cap ) ; } is_cap = false ; is_first_char = false ; } else { chars . push ( character ) ; } } } let new_string = chars . into_iter ( ) . collect ( ) ; return new_string ; }
Capitalize words in String variable.
Capitalize words in String variable .
string
String