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 242 views
1 answer 212 views
1 answer 181 views
1 answer 247 views
1 answer 185 views
1 answer 183 views
...