@@ -105,6 +105,40 @@ then you can do so by use of an `#[enumcapsulate(exclude(…))]` attribute:
105
105
enum Enum { /* ... */ }
106
106
```
107
107
108
+ ##### `#[enumcapsulate(discriminant(repr = …))]`
109
+
110
+ Specify a memory representation for the generated discriminant type .
111
+
112
+ > [! IMPORTANT ]
113
+ > This attribute is only recognized by the `VariantDiscriminant ` derive macro .
114
+
115
+ If you wish to specify a custom memory representation for the discriminant
116
+ type generated by the `VariantDiscriminant ` derive macro , then you can
117
+ do so by use of an `#[enumcapsulate(discriminant(repr = <typename>))]` attribute:
118
+
119
+ ```rust
120
+ #[derive(VariantDiscriminant )]
121
+ #[enumcapsulate(discriminant(repr = u8 ))]
122
+ enum MyEnum { /* ... */ }
123
+ ```
124
+
125
+ ##### `#[enumcapsulate(discriminant(name = …))]`
126
+
127
+ Specify a custom name for the generated discriminant type .
128
+
129
+ > [! IMPORTANT ]
130
+ > This attribute is only recognized by the `VariantDiscriminant ` derive macro .
131
+
132
+ If you wish to specify a custom name for the discriminant type
133
+ generated by the `VariantDiscriminant ` derive macro , then you can do
134
+ so by use of an `#[enumcapsulate(discriminant(name = <typename>))]` attribute:
135
+
136
+ ```rust
137
+ #[derive(VariantDiscriminant )]
138
+ #[enumcapsulate(discriminant(name = MyDiscriminant ))]
139
+ enum MyEnum { /* ... */ }
140
+ ```
141
+
108
142
### Variant attributes
109
143
110
144
> [! NOTE ]
@@ -245,6 +279,48 @@ enum Enum {
245
279
}
246
280
```
247
281
282
+ ##### `#[enumcapsulate(discriminant(value = …))]`
283
+
284
+ Specify a memory representation for the generated discriminant type .
285
+
286
+ > [! IMPORTANT ]
287
+ > This attribute is only recognized by the `VariantDiscriminant ` derive macro .
288
+
289
+ If you wish to specify a custom memory representation for the discriminant
290
+ type generated by the `VariantDiscriminant ` derive macro , then you can
291
+ do so by use of an `#[enumcapsulate(discriminant(value = <expr>))]` attribute:
292
+
293
+ ```rust
294
+ #[derive(VariantDiscriminant )]
295
+ enum Enum {
296
+ #[enumcapsulate(discriminant(value = 42))]
297
+ VariantA (i32 ),
298
+
299
+ VariantB { b: u32 },
300
+ }
301
+ ```
302
+
303
+ ##### `#[enumcapsulate(discriminant(name = …))]`
304
+
305
+ Specify a custom name for the generated discriminant type .
306
+
307
+ > [! IMPORTANT ]
308
+ > This attribute is only recognized by the `VariantDiscriminant ` derive macro .
309
+
310
+ If you wish to specify a custom name for the discriminant type
311
+ generated by the `VariantDiscriminant ` derive macro , then you can do
312
+ so by use of an `#[enumcapsulate(discriminant(name = …))]` attribute:
313
+
314
+ ```rust
315
+ #[derive(VariantDiscriminant )]
316
+ enum Enum {
317
+ #[enumcapsulate(discriminant(name = CustomDiscriminant ))]
318
+ VariantA (i32 ),
319
+
320
+ VariantB { b: u32 },
321
+ }
322
+ ```
323
+
248
324
## Generics
249
325
250
326
There is limited support for generic enums:
0 commit comments