How to trim a string in Rust

1 Answer

0 votes
fn main() {
    let mut s = String::from("           rust java c c++   ");
    
    s = s.trim().to_string();
    
    println!("{}", s);
}



/*
run:

rust java c c++

*/

 



answered Jul 6, 2024 by avibootz
...