let current_column = 1;
let max_column = 7;
edge = match current_column {
0 => Edge::Left,
a if a == max_column => Edge::Right,
_ => Edge::NotAnEdge
};
上面的代码来自Why is this match pattern unreachable when using non-literal patterns?
这里为什么能将if 写入到 match 的 列举参数中
1
共 1 条评论, 1 页
评论区
写评论https://doc.rust-lang.org/book/ch18-03-pattern-syntax.html#extra-conditionals-with-match-guards