How to copy the characters from a string into a vector and remove duplicates in Rust

1 Answer

0 votes
fn main() {
    let language: &'static str = "abbbccdddddeeeeeeeeefff";
   
    let mut chars: Vec<char> = language.chars().collect();
    chars.dedup();
    
    println!("{:?}", chars);
}




/*
run:

['a', 'b', 'c', 'd', 'e', 'f']

*/

 



answered Feb 5, 2023 by avibootz
...