E4147#
Range pattern bounds must satisfy the ordering constraints:
Pattern |
Constraint |
---|---|
|
|
|
|
Erroneous example#
fn main {
let value = 1
match value {
0..<-10 => println("0..<-10")
//^~~~~~~
// Error: Range pattern `a..<b` must satisfy `a < b`.
_ => println("_")
}
}
Suggestion#
Make sure the range pattern bounds satisfy the ordering constraints. This can be usually achieved by swapping the bounds.
fn main {
let value = 1
match value {
-10..<0 => println("0..=10")
_ => println("_")
}
}