作为熟悉指针和解引用的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?
}
}
}