From b237d1299e6588ec7e785377f8cfe470bf68a072 Mon Sep 17 00:00:00 2001 From: Michael Howell Date: Wed, 22 Nov 2017 10:43:30 -0700 Subject: [PATCH 1/2] Rename C-like enum to Field-less enum There is no need to reference the C programming language to explain this concept. --- src/items/enumerations.md | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/items/enumerations.md b/src/items/enumerations.md index 81b92ec96..b7ebb9cb2 100644 --- a/src/items/enumerations.md +++ b/src/items/enumerations.md @@ -36,12 +36,14 @@ In this example, `Cat` is a _struct-like enum variant_, whereas `Dog` is simply called an enum variant. Each enum instance has a _discriminant_ which is an integer associated to it that is used to determine which variant it holds. -## C-like Enumerations +## Custom Discriminant Values for Field-Less Enumerations -If there is no data attached to *any* of the variants of an enumeration it is -called a *c-like enumeration*. If a discriminant isn't specified, they start at -zero, and add one for each variant, in order. Each enum value is just its -discriminant which you can specify explicitly: +If there is no data attached to *any* of the variants of an enumeration, +then the discriminant can directly chosen and accessed. + +If a discriminant isn't specified, they start at zero, and add one for each +variant, in order. Each enum value is just its discriminant which you can +specify explicitly: ```rust enum Foo { @@ -58,7 +60,7 @@ hand side and specify the memory layout. [`repr` attribute]: attributes.html#ffi-attributes -You can also cast a c-like enum to get its discriminant: +You can also cast a field-less enum to get its discriminant: ```rust # enum Foo { Baz = 123 } From 0828379ad2ba3241414e6292a4144e55006df389 Mon Sep 17 00:00:00 2001 From: Michael Howell Date: Tue, 28 Nov 2017 14:48:04 -0700 Subject: [PATCH 2/2] Update enumerations.md --- src/items/enumerations.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/items/enumerations.md b/src/items/enumerations.md index b7ebb9cb2..b2f6c100e 100644 --- a/src/items/enumerations.md +++ b/src/items/enumerations.md @@ -39,7 +39,7 @@ integer associated to it that is used to determine which variant it holds. ## Custom Discriminant Values for Field-Less Enumerations If there is no data attached to *any* of the variants of an enumeration, -then the discriminant can directly chosen and accessed. +then the discriminant can be directly chosen and accessed. If a discriminant isn't specified, they start at zero, and add one for each variant, in order. Each enum value is just its discriminant which you can