I'm trying to match an input to possible types, which will then convert that string value to a number. I have something like this:
fn letter_to_num(nameNum: &str) -> Option<f32> {
match nameNum {
Some(num) => {
"One" => 1.0,
"Two" => 2.0,
"Three" => 3.0
},
None => println!("Invalid Number"),
}
}
If it can't match the input, it'll return an error. Otherwise, it will match with one of the items and return Some(num)
on success. I'm not entirely sure where to be putting the option statements and different combos seem to not want to compile either. The main error I'm getting is:
Expected one of '.', ',', ';', or an operator, found '=>'