How to remove all spaces from a string in Rust

1 Answer

0 votes
fn main() {
    let s = String::from("rust   golang c#     java c c++   python");

    let result = s.replace(" ", "");
    
    println!("{}", result);
}

    
    
/*
run:

rustgolangc#javacc++python

*/

 



answered Oct 14, 2024 by avibootz
...