Commit c76182b
committed
Auto merge of rust-lang#114208 - GKFX:offset_of_enum, r=wesleywiser
Support enum variants in offset_of!
This MR implements support for navigating through enum variants in `offset_of!`, placing the enum variant name in the second argument to `offset_of!`. The RFC placed it in the first argument, but I think it interacts better with nested field access in the second, as you can then write things like
```rust
offset_of!(Type, field.Variant.field)
```
Alternatively, a syntactic distinction could be made between variants and fields (e.g. `field::Variant.field`) but I'm not convinced this would be helpful.
[RFC 3308 # Enum Support](https://rust-lang.github.io/rfcs/3308-offset_of.html#enum-support-offset_ofsomeenumstructvariant-field_on_variant)
Tracking Issue rust-lang#106655.1 file changed
+9
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1292 | 1292 | | |
1293 | 1293 | | |
1294 | 1294 | | |
1295 | | - | |
| 1295 | + | |
1296 | 1296 | | |
1297 | 1297 | | |
1298 | 1298 | | |
1299 | | - | |
| 1299 | + | |
| 1300 | + | |
| 1301 | + | |
| 1302 | + | |
| 1303 | + | |
1300 | 1304 | | |
1301 | 1305 | | |
1302 | 1306 | | |
| |||
1324 | 1328 | | |
1325 | 1329 | | |
1326 | 1330 | | |
| 1331 | + | |
| 1332 | + | |
| 1333 | + | |
1327 | 1334 | | |
1328 | 1335 | | |
1329 | 1336 | | |
| |||
0 commit comments