How do I remove the unused_variables
warning from the following code?
pub enum Foo {
Bar {
a: i32,
b: i32,
c: i32,
},
Baz,
}
fn main() {
let myfoo = Foo::Bar { a: 1, b: 2, c: 3 };
let x: i32 = match myfoo {
Foo::Bar { a, b, c } => b * b,
Foo::Baz => -1,
};
assert_eq!(x, 4);
}
I know I can ignore struct members after a certain point with:
Foo::Bar { a, .. } => // do stuff with 'a'
But I can't find documentation anywhere that explains how to ignore individual struct members.
I know I can ignore struct members after a certain point with:
The ..
is not positional. It just means "all the other fields":
Foo::Bar { b, .. } => b * b,
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.