@@ -9,116 +9,124 @@ extern crate not_exhaustive_enough_helper;
99use not_exhaustive_enough_helper:: { AnotherCrateEnum , AnotherCrateStruct , TPrivateField } ;
1010
1111#[ non_exhaustive]
12- pub enum E {
12+ pub enum DefaultEnum {
1313 First ,
1414 Second ,
1515 Third ,
1616}
1717
1818#[ non_exhaustive]
19- pub enum K {
19+ pub enum DataEnum {
2020 First ( String ) ,
2121 Second ( u32 , u32 ) ,
22- Third ( String )
22+ Third ( String ) ,
2323}
2424
25- enum EF {
25+ pub enum StructVariantEnum1 {
2626 #[ non_exhaustive]
27- V { a : i32 , b : i32 }
27+ V { a : i32 , b : i32 } ,
2828}
2929
30- enum F {
30+ pub enum StructVariantEnum2 {
3131 #[ non_exhaustive]
32- V { a : i32 , b : i32 } ,
33- A { c : u32 }
32+ V {
33+ a : i32 ,
34+ b : i32 ,
35+ } ,
36+ A {
37+ c : u32 ,
38+ } ,
3439}
3540
3641#[ derive( Default ) ]
3742#[ non_exhaustive]
38- pub struct S {
43+ pub struct DefaultStruct {
3944 pub a : i32 ,
4045 pub b : i32 ,
4146 pub c : i32 ,
4247}
4348
4449#[ derive( Default ) ]
4550#[ non_exhaustive]
46- pub struct T ( pub i32 , pub i32 , pub i32 ) ;
47-
51+ pub struct DefaultTuple ( pub i32 , pub i32 , pub i32 ) ;
4852
4953fn main ( ) {
5054 //////// Enum
5155
52- let e = E :: First ;
56+ let default_enum = DefaultEnum :: First ;
5357
54- let ef = EF :: V { a : 1 , b : 2 } ;
58+ let struct_variant_enum_1 = StructVariantEnum1 :: V { a : 1 , b : 2 } ;
5559
56- let f = F :: V { a : 1 , b : 2 } ;
60+ let struct_variant_enum_2 = StructVariantEnum2 :: V { a : 1 , b : 2 } ;
5761
58- match e {
59- E :: First => { } ,
60- E :: Second => { } ,
62+ match default_enum {
63+ DefaultEnum :: First => { } ,
64+ DefaultEnum :: Second => { } ,
6165 _ => { } ,
6266 }
6367
64- match ef {
65- EF :: V { a : _, ..} => { }
68+ match struct_variant_enum_1 {
69+ StructVariantEnum1 :: V { a : _, .. } => { } ,
6670 }
6771
68- if let F :: V { a : _, ..} = f { }
72+ match struct_variant_enum_2 {
73+ StructVariantEnum2 :: V { a : _, .. } => { } ,
74+ _ => { } ,
75+ }
6976
7077 //
78+
7179 let example = "Example" . to_string ( ) ;
72- let k = K :: First ( example) ;
80+ let data_enum = DataEnum :: First ( example) ;
7381
74- match k {
75- K :: First ( ..) => { } ,
76- K :: Second ( ..) => { } ,
82+ match data_enum {
83+ DataEnum :: First ( ..) => { } ,
84+ DataEnum :: Second ( ..) => { } ,
7785 _ => { } ,
7886 }
7987
8088 //////// Struct
8189
82- let S { a : _, b : _, .. } = S :: default ( ) ;
90+ let DefaultStruct { a : _, b : _, .. } = DefaultStruct :: default ( ) ;
8391
84- match S :: default ( ) {
85- S { a : 42 , b : 21 , .. } => { } ,
86- S { a : _, b : _, .. } => { } ,
92+ match DefaultStruct :: default ( ) {
93+ DefaultStruct { a : 42 , b : 21 , .. } => { } ,
94+ DefaultStruct { a : _, b : _, .. } => { } ,
8795 }
8896
89- if let S { a : 42 , b : _, .. } = S :: default ( ) { }
97+ if let DefaultStruct { a : 42 , b : _, .. } = DefaultStruct :: default ( ) { }
9098
91- let v = vec ! [ S :: default ( ) ] ;
99+ let v = vec ! [ DefaultStruct :: default ( ) ] ;
92100
93- for S { a : _, b : _, .. } in v { }
101+ for DefaultStruct { a : _, b : _, .. } in v { }
94102
95- while let S { a : 42 , b : _, .. } = S :: default ( ) {
103+ while let DefaultStruct { a : 42 , b : _, .. } = DefaultStruct :: default ( ) {
96104 break ;
97105 }
98106
99- pub fn take_s ( S { a, b, .. } : S ) -> ( i32 , i32 ) {
107+ pub fn take_s ( DefaultStruct { a, b, .. } : DefaultStruct ) -> ( i32 , i32 ) {
100108 ( a, b)
101109 }
102110
103111 //////// Tuple Struct
104112
105- let T { 0 : _ , 1 : _ , .. } = T :: default ( ) ;
113+ let DefaultTuple { 0 : _ , 1 : _ , .. } = DefaultTuple :: default ( ) ;
106114
107- match T :: default ( ) {
108- T { 0 : 42 , 1 : 21 , .. } => { } ,
109- T { 0 : _, 1 : _, .. } => { } ,
115+ match DefaultTuple :: default ( ) {
116+ DefaultTuple { 0 : 42 , 1 : 21 , .. } => { } ,
117+ DefaultTuple { 0 : _, 1 : _, .. } => { } ,
110118 }
111119
112- if let T { 0 : 42 , 1 : _, .. } = T :: default ( ) { }
120+ if let DefaultTuple { 0 : 42 , 1 : _, .. } = DefaultTuple :: default ( ) { }
113121
114- let v = vec ! [ T :: default ( ) ] ;
115- for T { 0 : _, 1 : _, .. } in v { }
122+ let default_tuple = vec ! [ DefaultTuple :: default ( ) ] ;
123+ for DefaultTuple { 0 : _, 1 : _, .. } in default_tuple { }
116124
117- while let T { 0 : 42 , 1 : _, .. } = T :: default ( ) {
125+ while let DefaultTuple { 0 : 42 , 1 : _, .. } = DefaultTuple :: default ( ) {
118126 break ;
119127 }
120128
121- pub fn take_t ( T { 0 : _ , 1 : _ , .. } : T ) -> ( i32 , i32 ) {
129+ pub fn take_t ( DefaultTuple { 0 : _ , 1 : _ , .. } : DefaultTuple ) -> ( i32 , i32 ) {
122130 ( 0 , 1 )
123131 }
124132
@@ -132,8 +140,8 @@ fn main() {
132140 }
133141
134142 match TPrivateField :: default ( ) {
135- TPrivateField { 1 : 21 , .. } => { } ,
136- _ => { }
143+ TPrivateField { 1 : 21 , .. } => { } ,
144+ _ => { } ,
137145 }
138146
139147 if let TPrivateField { 0 : 42 , 1 : _, .. } = TPrivateField :: default ( ) { }
0 commit comments