How can i reuse rust's type inference for numeric types given a string representing a number
As per https://doc.rust-lang.org/book/ch03-02-data-types.html#scalar-types a number without fractional component is inferred as integer, and the ones with fractional component is inferred as f64. I want to reuse the same rule for any input to my program.
enum NumType {
I32,
F64,
...
}
fn getType(s: &str) -> NumType {
// Reuse rust's rules here.
}