Correct unused field warning on struct match container patterns

This commit is contained in:
varkor
2018-04-30 01:27:37 +01:00
parent 8e8fe9042c
commit 2eb8343af1
3 changed files with 77 additions and 13 deletions

View File

@@ -20,10 +20,13 @@ struct SoulHistory {
endless_and_singing: bool
}
#[derive(Clone, Copy)]
enum Large {
Suit { case: () }
}
struct Tuple(Large, ());
fn main() {
let i_think_continually = 2;
let who_from_the_womb_remembered = SoulHistory {
@@ -42,11 +45,33 @@ fn main() {
case: ()
};
// Plain struct
match bag {
Large::Suit { case } => {}
};
// Referenced struct
match &bag {
&Large::Suit { case } => {}
};
// Boxed struct
match box bag {
box Large::Suit { case } => {}
};
// Tuple with struct
match (bag,) {
(Large::Suit { case },) => {}
};
// Slice with struct
match [bag] {
[Large::Suit { case }] => {}
};
// Tuple struct with struct
match Tuple(bag, ()) {
Tuple(Large::Suit { case }, ()) => {}
};
}