Skip to content

Small documentation update for enums #1658

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions doc/rust.md
Original file line number Diff line number Diff line change
Expand Up @@ -1058,7 +1058,9 @@ accessed through the components `x` and `y`, and laid out in memory with the
An _enumeration item_ simultaneously declares a new nominal
[enumerated type](#enumerated-types) as well as a set of *constructors* that
can be used to create or pattern-match values of the corresponding enumerated
type.
type. Note that `enum` previously was refered to as a `tag`, however this
definition has been deprecated. While `tag` is no longer used, the two are
synonymous.

The constructors of an `enum` type may be recursive: that is, each constructor
may take an argument that refers, directly or indirectly, to the enumerated
Expand Down Expand Up @@ -2007,7 +2009,7 @@ alt_pat : pat [ "to" pat ] ? [ "if" expr ] ;

An `alt` expression branches on a *pattern*. The exact form of matching that
occurs depends on the pattern. Patterns consist of some combination of
literals, destructured tag constructors, records and tuples, variable binding
literals, destructured enum constructors, records and tuples, variable binding
specifications and placeholders (`_`). An `alt` expression has a *head
expression*, which is the value to compare to the patterns. The type of the
patterns must equal the type of the head expression.
Expand All @@ -2022,7 +2024,7 @@ An example of an `alt` expression:


~~~~
tag list<X> { nil; cons(X, @list<X>); }
enum list<X> { nil; cons(X, @list<X>); }

let x: list<int> = cons(10, @cons(11, @nil));

Expand Down Expand Up @@ -3286,7 +3288,7 @@ such as vectors, strings, and the low level communication system (ports,
channels, tasks).

Support for other built-in types such as simple types, tuples, records, and
tags is open-coded by the Rust compiler.
enums is open-coded by the Rust compiler.



Expand Down
4 changes: 2 additions & 2 deletions doc/tutorial.md
Original file line number Diff line number Diff line change
Expand Up @@ -1346,7 +1346,7 @@ destructors. Resources might go away in the future.
Rust datatypes are not trivial to copy (the way, for example,
JavaScript values can be copied by simply taking one or two machine
words and plunking them somewhere else). Shared boxes require
reference count updates, big records, tags, or unique pointers require
reference count updates, big records, enums, or unique pointers require
an arbitrary amount of data to be copied (plus updating the reference
counts of shared boxes hanging off them).

Expand Down Expand Up @@ -1459,7 +1459,7 @@ alt my_rec {

The fact that arguments are conceptually passed by safe reference does
not mean all arguments are passed by pointer. Composite types like
records and tags *are* passed by pointer, but single-word values, like
records and enums *are* passed by pointer, but single-word values, like
integers and pointers, are simply passed by value. Most of the time,
the programmer does not have to worry about this, as the compiler will
simply pick the most efficient passing style. There is one exception,
Expand Down