1 #![allow(unused)]
2 
3 #[derive(Copy, Clone)]
4 enum Nucleotide {
5     Adenine,
6     Thymine,
7     Cytosine,
8     Guanine
9 }
10 
11 #[derive(Clone)]
12 struct Autosome;
13 
14 #[derive(Clone)]
15 enum Allosome {
16     X(Vec<Nucleotide>),
17     Y(Vec<Nucleotide>)
18 }
19 
20 impl Allosome {
is_x(&self) -> bool21     fn is_x(&self) -> bool {
22         match *self {
23             Allosome::X(_) => true,
24             Allosome::Y(_) => false,
25         }
26     }
27 }
28 
29 #[derive(Clone)]
30 struct Genome {
31     autosomes: [Autosome; 22],
32     allosomes: (Allosome, Allosome)
33 }
34 
find_start_codon(strand: &[Nucleotide]) -> Option<usize>35 fn find_start_codon(strand: &[Nucleotide]) -> Option<usize> {
36     let mut reading_frame = strand.windows(3);
37     // (missing parentheses in `while let` tuple pattern)
38     while let b1, b2, b3 = reading_frame.next().expect("there should be a start codon") {
39         //~^ ERROR unexpected `,` in pattern
40         // ...
41     }
42     None
43 }
44 
find_thr(strand: &[Nucleotide]) -> Option<usize>45 fn find_thr(strand: &[Nucleotide]) -> Option<usize> {
46     let mut reading_frame = strand.windows(3);
47     let mut i = 0;
48     // (missing parentheses in `if let` tuple pattern)
49     if let b1, b2, b3 = reading_frame.next().unwrap() {
50         //~^ ERROR unexpected `,` in pattern
51         // ...
52     }
53     None
54 }
55 
is_thr(codon: (Nucleotide, Nucleotide, Nucleotide)) -> bool56 fn is_thr(codon: (Nucleotide, Nucleotide, Nucleotide)) -> bool {
57     match codon {
58         // (missing parentheses in match arm tuple pattern)
59         Nucleotide::Adenine, Nucleotide::Cytosine, _ => true
60         //~^ ERROR unexpected `,` in pattern
61         _ => false
62     }
63 }
64 
analyze_female_sex_chromosomes(women: &[Genome])65 fn analyze_female_sex_chromosomes(women: &[Genome]) {
66     // (missing parentheses in `for` tuple pattern)
67     for x, _barr_body in women.iter().map(|woman| woman.allosomes.clone()) {
68         //~^ ERROR unexpected `,` in pattern
69         // ...
70     }
71 }
72 
analyze_male_sex_chromosomes(men: &[Genome])73 fn analyze_male_sex_chromosomes(men: &[Genome]) {
74     // (missing parentheses in pattern with `@` binding)
75     for x, y @ Allosome::Y(_) in men.iter().map(|man| man.allosomes.clone()) {
76         //~^ ERROR unexpected `,` in pattern
77         // ...
78     }
79 }
80 
main()81 fn main() {
82     let genomes = Vec::new();
83     // (missing parentheses in `let` pattern)
84     let women, men: (Vec<Genome>, Vec<Genome>) = genomes.iter().cloned()
85     //~^ ERROR unexpected `,` in pattern
86         .partition(|g: &Genome| g.allosomes.0.is_x() && g.allosomes.1.is_x());
87 }
88