@@ -105,37 +105,37 @@ then you can do so by use of an `#[enumcapsulate(exclude(…))]` attribute:
105
105
enum Enum { /* ... */ }
106
106
```
107
107
108
- ##### `#[enumcapsulate(discriminant(repr = …))]`
108
+ ##### `#[enumcapsulate(discriminant(name = …))]`
109
109
110
- Specify a memory representation for the generated discriminant type .
110
+ Specify a custom name for the generated discriminant type .
111
111
112
112
> [! IMPORTANT ]
113
113
> This attribute is only recognized by the `VariantDiscriminant ` derive macro .
114
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:
115
+ If you wish to specify a custom name for the discriminant type
116
+ generated by the `VariantDiscriminant ` derive macro , then you can do
117
+ so by use of an `#[enumcapsulate(discriminant(name = <typename>))]` attribute:
118
118
119
119
```rust
120
120
#[derive(VariantDiscriminant )]
121
- #[enumcapsulate(discriminant(repr = u8 ))]
121
+ #[enumcapsulate(discriminant(name = MyDiscriminant ))]
122
122
enum MyEnum { /* ... */ }
123
123
```
124
124
125
- ##### `#[enumcapsulate(discriminant(name = …))]`
125
+ ##### `#[enumcapsulate(discriminant(repr = …))]`
126
126
127
- Specify a custom name for the generated discriminant type .
127
+ Specify a memory representation for the generated discriminant type .
128
128
129
129
> [! IMPORTANT ]
130
130
> This attribute is only recognized by the `VariantDiscriminant ` derive macro .
131
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:
132
+ If you wish to specify a custom memory representation for the discriminant
133
+ type generated by the `VariantDiscriminant ` derive macro , then you can
134
+ do so by use of an `#[enumcapsulate(discriminant(repr = <typename>))]` attribute:
135
135
136
136
```rust
137
137
#[derive(VariantDiscriminant )]
138
- #[enumcapsulate(discriminant(name = MyDiscriminant ))]
138
+ #[enumcapsulate(discriminant(repr = u8 ))]
139
139
enum MyEnum { /* ... */ }
140
140
```
141
141
@@ -195,11 +195,11 @@ enum Enum {
195
195
196
196
Select a specific variant field as target for trait derivation.
197
197
198
- - `#[enumcapsulate(field(index = <index>) )]`
198
+ - `#[enumcapsulate(field = <index>)]`
199
199
200
200
Select field at index `<index>` to be used as target.
201
201
202
- - `#[enumcapsulate(field(name = " <name>") )]`
202
+ - `#[enumcapsulate(field = <name>)]`
203
203
204
204
Select field with name `<name>` to be used as target.
205
205
@@ -226,7 +226,7 @@ enum Enum {
226
226
VariantA (i32 , VariantA ),
227
227
228
228
// Select field `b`, i.e. `VariantB`:
229
- #[enumcapsulate(field(name = "b" ))]
229
+ #[enumcapsulate(field(name = b ))]
230
230
VariantB { b: VariantB , c: u32 },
231
231
}
232
232
```
@@ -237,27 +237,6 @@ enum Enum {
237
237
>
238
238
> Alternatively the variant can be excluded via `#[enumcapsulate(exclude)]`.
239
239
240
- ##### `#[enumcapsulate(discriminant(value = …))]`
241
-
242
- Specify a memory representation for the generated discriminant type .
243
-
244
- > [! IMPORTANT ]
245
- > This attribute is only recognized by the `VariantDiscriminant ` derive macro .
246
-
247
- If you wish to specify a custom memory representation for the discriminant
248
- type generated by the `VariantDiscriminant ` derive macro , then you can
249
- do so by use of an `#[enumcapsulate(discriminant(value = <expr>))]` attribute:
250
-
251
- ```rust
252
- #[derive(VariantDiscriminant )]
253
- enum Enum {
254
- #[enumcapsulate(discriminant(value = 42))]
255
- VariantA (i32 ),
256
-
257
- VariantB { b: u32 },
258
- }
259
- ```
260
-
261
240
##### `#[enumcapsulate(discriminant(name = …))]`
262
241
263
242
Specify a custom name for the generated discriminant type .
@@ -300,27 +279,6 @@ enum Enum {
300
279
}
301
280
```
302
281
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
-
324
282
## Generics
325
283
326
284
There is limited support for generic enums:
0 commit comments