Modulo operator in a match expression
I need to partition a given vec of numbers into odds and evens. To do that I’m using itertools
crate to perform the partition like below. Since modulo(%)
operator by 2
can possibly return -1, 0, 1
, rust compiler still throws an error to include patterns of i32::MIN..=-2_i32
and 2_i32..=i32::MAX
, which is kind of not good looking. I can overcoome this issue by including the _
pattern, but would like to know a better way to handle this kind of scenario.