fn format(txt: &str) -> String {
    let mut output = String::with_capacity(txt.len());
    let mut chars = txt.chars();

    if let Some(ch) = chars.next() {
        if ch.is_lowercase() {
            output.extend(ch.to_uppercase());
        } else {
            output.push(ch);
        }
    }

    output.extend(chars);

    if !txt.ends_with('.') {
        output.push('.');
    }

    output
}
// Makes sure errors message start with a capital letter and ends with '.'
Makes sure errors message start with a capital letter and ends with '.'
Makes sure errors message start with a capital letter and ends with ' . '
fn format(txt: &str) -> String {
    let mut output = String::with_capacity(txt.len());
    let mut chars = txt.chars();
    if let Some(ch) = chars.next() {
        if ch.is_lowercase() {
            output.extend(ch.to_uppercase());
        } else {
            output.push(ch);
        }
    }
    output.extend(chars);
    if !txt.ends_with('.') {
        output.push('.');
    }
    output
}
fn format ( txt : & str ) -> String { let mut output = String :: with_capacity ( txt . len ( ) ) ; let mut chars = txt . chars ( ) ; if let Some ( ch ) = chars . next ( ) { if ch . is_lowercase ( ) { output . extend ( ch . to_uppercase ( ) ) ; } else { output . push ( ch ) ; } } output . extend ( chars ) ; if ! txt . ends_with ( '.' ) { output . push ( '.' ) ; } output }
Makes sure errors message start with a capital letter and ends with '.'
Makes sure errors message start with a capital letter and ends with ' . '
txt
&str