How to remove trailing zeros from a string in Rust

1 Answer

0 votes
fn main() {
    let mut str = String::from("457833.8591000");
    
    str = str.trim_end_matches('0').to_string();

    println!("{}", str);
}


 
 
 
/*
run:
 
3429865.9301
 
*/

 



answered Nov 15, 2024 by avibootz

Related questions

1 answer 142 views
1 answer 103 views
1 answer 164 views
1 answer 103 views
1 answer 83 views
...