summaryrefslogtreecommitdiffstats
path: root/tests/ui/rfcs/rfc-2008-non-exhaustive/auxiliary/enums.rs
blob: cb2b585ab96a8cd7680b5b006228e1cee1936a09 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#![crate_type = "rlib"]

#[non_exhaustive]
pub enum NonExhaustiveEnum {
    Unit,
    Tuple(u32),
    Struct { field: u32 },
}

#[non_exhaustive]
pub enum NestedNonExhaustive {
    A(NonExhaustiveEnum),
    B,
    C,
}

#[non_exhaustive]
pub enum EmptyNonExhaustiveEnum {}

pub enum VariantNonExhaustive {
    #[non_exhaustive]
    Bar {
        x: u32,
        y: u64,
    },
    Baz(u32, u16),
}

#[non_exhaustive]
pub enum NonExhaustiveSingleVariant {
    A(bool),
}

#[repr(u8)]
pub enum FieldLessWithNonExhaustiveVariant {
    A,
    B,
    #[non_exhaustive]
    C,
}

impl Default for FieldLessWithNonExhaustiveVariant {
    fn default() -> Self { Self::A }
}