作为一名熟悉指针和取消引用的C程序员,我正在学习Rust教程,并且遇到了一些我不理解的事情.
fn main() {
let vector = vec![10, 20, 30, 40];
for entry in &vector {
if *entry == 30 { // I have to use a star (dereference) here...
println!("thirty");
} else {
println!("{}", entry);
}
match entry { // ...but why do I not need a star here?
30 => println!("thirty"),
_ => println!("{}", entry), // or here?
}
}
}