E4147

E4147#

Range pattern bounds must satisfy the ordering constraints:

Pattern

Constraint

a..=b

a <= b

a..<b

a < b

错误示例#

fn main {
  let value = 1
  match value {
    0..<-10 => println("0..<-10")
  //^~~~~~~
  // Error: Range pattern `a..<b` must satisfy `a < b`.
    _ => println("_")
  }
}

建议#

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("_")
  }
}