Why “enum” is being discussed
The most recent Hacker News stories and comments contributing to this topic's mentions.
> What does it cost you to write that explicitly? Like, 10 extra characters? The given example is 26 additional characters, and that's without any type declarations. Also callin…
by moebrowne · Nov 19, 2026
Exactly this. Here we have a couple of people named "Fullname ." in Outlook because we can't just enter a single word name and are forced to use a dot to fill the second field.…
by nedt · Nov 17, 2026
To me, foo?.bar?.baz ?? 0 looks really hard to reason about, if I imagine it sits in the context of some wider processing code. Explicit options nudge you towards a data model t…
by hiimkeks · Nov 17, 2026
Yes, all correct. "()" the unit type, is a zero sized type (zst). And you don't have to have 1:1 type to enum discriminant: trait Payloads { type Read; type Write; } enum FileOp…
by bombela · Nov 17, 2026
You missed the point as well. You can't define a union type in Rust that is backed by a custom enum type. In rust it's a single conflated type. I can't make a Person enum that i…
by xeubie · Nov 17, 2026
This looks like it would handle synchronizing multiple variant records/enums, and if you just wanted the "plain" enum without any payload, you'd need to do: pub struct Bare…
by Jtsummers · Nov 17, 2026
Interest
Proportion of Hacker News items mentioning "enum" over time.
Mentions
Total number of Hacker News items mentioning "enum" over time.
In computer programming, an enumerated type is a data type consisting of a set of named values called elements, members, enumeral, or enumerators of the type. The enumerator names are usually identifiers that behave as constants in the language. An enumerated type can be seen as a degenerate tagged union of unit type. A variable that has been declared as having an enumerated type can be assigned any of the enumerators as a value. In other words, an enumerated type defines a set of discrete, mutually exclusive constants that are not generally written to a concrete representation in the computer's memory; compilers and interpreters can represent them arbitrarily without specification from the programmer. Read more on Wikipedia