Skip to content

Commit 3401c50

Browse files
committed
doc: Use commas to separate enums in tutorial
1 parent 992d743 commit 3401c50

File tree

1 file changed

+16
-16
lines changed

1 file changed

+16
-16
lines changed

doc/tutorial.md

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -809,7 +809,7 @@ expected to return.
809809
~~~~
810810
# fn can_go_left() -> bool { true }
811811
# fn can_go_right() -> bool { true }
812-
# enum dir { left; right; }
812+
# enum dir { left, right }
813813
# fn dead_end() -> ! { fail; }
814814
let dir = if can_go_left() { left }
815815
else if can_go_right() { right }
@@ -989,8 +989,8 @@ types).
989989
~~~~
990990
type point = {x: float, y: float};
991991
enum shape {
992-
circle(point, float);
993-
rectangle(point, point);
992+
circle(point, float),
993+
rectangle(point, point)
994994
}
995995
let my_shape = circle({x: 0.0, y: 0.0}, 10.0);
996996
~~~~
@@ -1065,8 +1065,8 @@ example, the type shown earlier:
10651065
~~~~
10661066
# type point = {x: float, y: float};
10671067
enum shape {
1068-
circle(point, float);
1069-
rectangle(point, point);
1068+
circle(point, float),
1069+
rectangle(point, point)
10701070
}
10711071
~~~~
10721072

@@ -1087,10 +1087,10 @@ equivalent to a C enum:
10871087

10881088
~~~~
10891089
enum direction {
1090-
north;
1091-
east;
1092-
south;
1093-
west;
1090+
north,
1091+
east,
1092+
south,
1093+
west
10941094
}
10951095
~~~~
10961096

@@ -1103,9 +1103,9 @@ value:
11031103

11041104
~~~~
11051105
enum color {
1106-
red = 0xff0000;
1107-
green = 0x00ff00;
1108-
blue = 0x0000ff;
1106+
red = 0xff0000,
1107+
green = 0x00ff00,
1108+
blue = 0x0000ff
11091109
}
11101110
~~~~
11111111

@@ -1130,7 +1130,7 @@ enum gizmo_id = int;
11301130
That is a shorthand for this:
11311131

11321132
~~~~
1133-
enum gizmo_id { gizmo_id(int); }
1133+
enum gizmo_id { gizmo_id(int) }
11341134
~~~~
11351135

11361136
Enum types like this can have their content extracted with the
@@ -1150,7 +1150,7 @@ patterns, as in this definition of `area`:
11501150

11511151
~~~~
11521152
# type point = {x: float, y: float};
1153-
# enum shape { circle(point, float); rectangle(point, point); }
1153+
# enum shape { circle(point, float), rectangle(point, point) }
11541154
fn area(sh: shape) -> float {
11551155
alt sh {
11561156
circle(_, size) { float::consts::pi * size * size }
@@ -1163,7 +1163,7 @@ Another example, matching nullary enum variants:
11631163

11641164
~~~~
11651165
# type point = {x: float, y: float};
1166-
# enum direction { north; east; south; west; }
1166+
# enum direction { north, east, south, west }
11671167
fn point_from_direction(dir: direction) -> point {
11681168
alt dir {
11691169
north { {x: 0f, y: 1f} }
@@ -1545,7 +1545,7 @@ type circular_buf<T> = {start: uint,
15451545
end: uint,
15461546
buf: [mutable T]};
15471547
1548-
enum option<T> { some(T); none; }
1548+
enum option<T> { some(T), none }
15491549
~~~~
15501550

15511551
You can then declare a function to take a `circular_buf<u8>` or return

0 commit comments

Comments
 (0)