- f32
Convert string to float
- Sometimes we are expecting floating point numbers.
examples/convert/string-to-float/src/main.rs
fn main() { let text = " 2.3 "; println!("'{}'", text); let number: f32 = text.trim().parse().expect("Could not convert to f32"); println!("'{}'", number); println!("'{}'", number + 1.0); }
' 2.3 ' '2.3' '3.3'