Collective name for both structs and enums

I'm reviewing a PR for a derive macro which can handle both structs and enums.

The code uses the name "Container" to mean "either a struct or enum". To me that name feels a bit awry because I think of container to be synonymous with "collection" (e.g. Vec).

Maybe I'm just awkward here. Serde seems to use "Container" for this case: Container attributes · Serde

Does anyone have any other terms they like to use to refer to structs and enums?

This is somewhat difficult. Sometimes I use "object".

1 Like

It is hard as structs are described as heterogeneous product of other types and enums as heterogeneous disjoint union types. So essentially they are something different.

However, the reference groups structs, enums and unions into user-defined types.

5 Likes

This.
The only thing I have to add to that is that you can also sort-of create types with type MyResult<T> = std::result::Result<T, MyError> though technically that's defining a new alias for a pre-existing type.

2 Likes

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.