【发布时间】:2014-11-12 18:45:13
【问题描述】:
我想知道是否可以将范围匹配器与枚举一起使用。玩具示例:
enum Things {
One,
Two,
Three
}
pub fn main() {
match One {
One...Two => println!("one to two"),
Three => println!("three")
}
}
错误:
<anon>:9:9: 9:12 error: only char and numeric types are allowed in range [E0029]
<anon>:9 One...Two => println!("one to two"),
^~~
error: aborting due to previous error
playpen: application terminated with error code 101
那么,有没有可能做这样的事情?
【问题讨论】:
-
不是你要的,但你可以在同一个分支中匹配两个枚举:
One | Two => ...