1 2 3 4 5 6 7 8 9 10 11
fn main() { let s = "Perl Weekly Challenge"; let cnt = s.chars().filter(|&c| c == 'e').count(); println!("Input: {s}"); print!("Output: "); for c in s.chars() { if c == 'e' { print!("E"); } else { print!("{c}"); } } println!("\ne occurs {cnt} times in the input sentence."); }