Inverse of format!; &str -> Option<bool>, Option<i32>, Option<f32>

  1. What is the inverse of format! ?

  2. I have a &str, and I want to see if it get be parsed as a Bool, as a i32, or an f32. I.e. I am looking for functions of type signature:

&str -> Option<bool>
&str -> Option<i32>
&str -> Option<f32>

It’s not hard to write these on my own, but I suspect there is a standard way to do these in rust.

#2 - it returns a Result but you can turn that into Option if you don’t care about inspecting the error.


Got it working. Thanks!