How to convert a string to a vector of characters in Rust

1 Answer

0 votes
fn main() {
    let s = "rust c c++";
    let char_vec: Vec<char> = s.chars().collect();
    
    for ch in char_vec {
        print!("{} ", ch);
    }
}

  
    
/*
run:

r u s t   c   c + + 
  
*/

 



answered Oct 9, 2024 by avibootz

Related questions

...