Hacker News new | ask | show | jobs
by nemothekid 4064 days ago
Well you are right, the name does make sense, but I would have thought "union" would have made more sense than "enum" for those of us from the C-family.

OTOH I haven't written a line of Rust of yet, so enum might be more familiar in use.

1 comments

> Well you are right, the name does make sense, but I would have thought "union" would have made more sense than "enum" for those of us from the C-family.

The issue with `union` is it might hint at things which are not available (e.g. the union of an int and a float where you can access to the raw data as either).

A Rust enum is really an encoding of the `struct { enum, union }` pattern, but it degenerates to an enum if there's no union part (no data payload), not to a union. So calling it an enum makes more sense.