want to do
I would like to use Rust's match statement to process variables differently when they are in an arbitrary range and in other cases. In that case, the code would look like this.
Applicable codes
// idx is usize variable
// num is usize variabel
let res: Option<f64> = match idx {
1..=num-5 => {
Some(func())
},
_ => None,
};
Error I received.
error: expected one of `::`, `=>`, `if`, or `|`, found `-`
--> src/features.rs:34:22
|
34 | 1..=num-5 => Some(func()),
| ^ expected one of `::`, `=>`, `if`, or `|`