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 156 views
1 answer 113 views
1 answer 107 views
1 answer 179 views
1 answer 109 views
1 answer 92 views
...