docs: document @field working on enums #30107

Open
opened 2025-12-04 22:33:00 +01:00 by eamonburns · 1 comment

Zig Version

0.15.2

Steps to Reproduce and Observed Behavior

Documentation for @field doesn't mention the fact that is works for enums:

Expected Behavior

Mention the functionality, and have a code example:

const Action = enum {
    left,
    right,
    shoot,
};

test "..." {
    try std.testing.expect(@field(Action, "shoot") == Action.shoot)
}

(Here is an example example 😄)

### Zig Version 0.15.2 ### Steps to Reproduce and Observed Behavior Documentation for [`@field`](https://ziglang.org/documentation/master/#field) doesn't mention the fact that is works for enums: ### Expected Behavior Mention the functionality, and have a code example: ```zig const Action = enum { left, right, shoot, }; test "..." { try std.testing.expect(@field(Action, "shoot") == Action.shoot) } ``` (Here is an example example 😄)
Author

Would also be nice if this documentation could be back-ported to the 0.15.2 documentation, since it works for that version as well.

Not sure if that is out-of-scope though 🤷‍♂️

Would also be nice if this documentation could be back-ported to the 0.15.2 documentation, since it works for that version as well. Not sure if that is out-of-scope though 🤷‍♂️
mlugg added this to the Upcoming milestone 2026-09-26 23:08:08 +02:00
Sign in to join this conversation.
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
ziglang/zig#30107
No description provided.