@@ -37,7 +37,22 @@ more fields or variants added in the future.
3737> #[non_exhaustive] Reaction (u32 ),
3838> #[non_exhaustive] Quit ,
3939> }
40+ > ```
41+
42+ r [attributes . type - system . non_exhaustive. allowed- positions ]
43+ It can be applied to [`struct `s ][struct ], [`enum `s ][enum ], and `enum ` variants .
44+
45+ r [attributes . type - system . non_exhaustive. syntax]
46+ The `non_exhaustive ` attribute uses the [MetaWord ] syntax and thus does not
47+ take any inputs .
48+
49+ r [attributes . type - system . non_exhaustive. same- crate ]
50+ Within the defining crate , `non_exhaustive ` has no effect .
51+
52+ > [! EXAMPLE ]
53+ > Using the definitions from [above ][attributes . type - system . non_exhaustive. intro], the following examples when used within the same crate are allowed without restrictions .
4054>
55+ > ```rust ,ignore
4156> // Non-exhaustive structs can be constructed as normal within the defining crate.
4257> let config = Config { window_width : 640 , window_height : 480 };
4358> let token = Token ;
@@ -65,15 +80,6 @@ more fields or variants added in the future.
6580> }
6681> ```
6782
68- r [attributes . type - system . non_exhaustive. allowed- positions ]
69- It can be applied to [`struct `s ][struct ], [`enum `s ][enum ], and `enum ` variants .
70-
71- r [attributes . type - system . non_exhaustive. syntax]
72- The `non_exhaustive ` attribute uses the [MetaWord ] syntax and thus does not
73- take any inputs .
74-
75- r [attributes . type - system . non_exhaustive. same- crate ]
76- Within the defining crate , `non_exhaustive ` has no effect .
7783
7884r [attributes . type - system . non_exhaustive. external- crate ]
7985Outside of the defining crate , types annotated with `non_exhaustive ` have limitations that
0 commit comments