@@ -809,7 +809,7 @@ expected to return.
809
809
~~~~
810
810
# fn can_go_left() -> bool { true }
811
811
# fn can_go_right() -> bool { true }
812
- # enum dir { left; right; }
812
+ # enum dir { left, right }
813
813
# fn dead_end() -> ! { fail; }
814
814
let dir = if can_go_left() { left }
815
815
else if can_go_right() { right }
@@ -989,8 +989,8 @@ types).
989
989
~~~~
990
990
type point = {x: float, y: float};
991
991
enum shape {
992
- circle(point, float);
993
- rectangle(point, point);
992
+ circle(point, float),
993
+ rectangle(point, point)
994
994
}
995
995
let my_shape = circle({x: 0.0, y: 0.0}, 10.0);
996
996
~~~~
@@ -1065,8 +1065,8 @@ example, the type shown earlier:
1065
1065
~~~~
1066
1066
# type point = {x: float, y: float};
1067
1067
enum shape {
1068
- circle(point, float);
1069
- rectangle(point, point);
1068
+ circle(point, float),
1069
+ rectangle(point, point)
1070
1070
}
1071
1071
~~~~
1072
1072
@@ -1087,10 +1087,10 @@ equivalent to a C enum:
1087
1087
1088
1088
~~~~
1089
1089
enum direction {
1090
- north;
1091
- east;
1092
- south;
1093
- west;
1090
+ north,
1091
+ east,
1092
+ south,
1093
+ west
1094
1094
}
1095
1095
~~~~
1096
1096
@@ -1103,9 +1103,9 @@ value:
1103
1103
1104
1104
~~~~
1105
1105
enum color {
1106
- red = 0xff0000;
1107
- green = 0x00ff00;
1108
- blue = 0x0000ff;
1106
+ red = 0xff0000,
1107
+ green = 0x00ff00,
1108
+ blue = 0x0000ff
1109
1109
}
1110
1110
~~~~
1111
1111
@@ -1130,7 +1130,7 @@ enum gizmo_id = int;
1130
1130
That is a shorthand for this:
1131
1131
1132
1132
~~~~
1133
- enum gizmo_id { gizmo_id(int); }
1133
+ enum gizmo_id { gizmo_id(int) }
1134
1134
~~~~
1135
1135
1136
1136
Enum types like this can have their content extracted with the
@@ -1150,7 +1150,7 @@ patterns, as in this definition of `area`:
1150
1150
1151
1151
~~~~
1152
1152
# type point = {x: float, y: float};
1153
- # enum shape { circle(point, float); rectangle(point, point); }
1153
+ # enum shape { circle(point, float), rectangle(point, point) }
1154
1154
fn area(sh: shape) -> float {
1155
1155
alt sh {
1156
1156
circle(_, size) { float::consts::pi * size * size }
@@ -1163,7 +1163,7 @@ Another example, matching nullary enum variants:
1163
1163
1164
1164
~~~~
1165
1165
# type point = {x: float, y: float};
1166
- # enum direction { north; east; south; west; }
1166
+ # enum direction { north, east, south, west }
1167
1167
fn point_from_direction(dir: direction) -> point {
1168
1168
alt dir {
1169
1169
north { {x: 0f, y: 1f} }
@@ -1545,7 +1545,7 @@ type circular_buf<T> = {start: uint,
1545
1545
end: uint,
1546
1546
buf: [mutable T]};
1547
1547
1548
- enum option<T> { some(T); none; }
1548
+ enum option<T> { some(T), none }
1549
1549
~~~~
1550
1550
1551
1551
You can then declare a function to take a ` circular_buf<u8> ` or return
0 commit comments