我正在关注rust-lang.org网站上的教程。我正在运行this code from Rust By Example:
enum Status {
Rich,
Poor,
}
fn main() {
// I am only allowing the use of Poor without manual scoping
use Status::Poor;
let status = Poor;
match status {
anyRandomValue => println!("The rich have lots of money!"), // <-- Why does match takes this path ???
Poor => println!("The poor have no money..."), // <-- Was expecting this ...
}
}
输出为:
富人有很多钱!
我期待“穷人没有钱……”。我想我缺少一些Rust的可塑性。
为什么match
这样行事?