We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 54344c2 commit 92e52bcCopy full SHA for 92e52bc
doc/tutorial.md
@@ -1226,6 +1226,18 @@ match crayons[0] {
1226
}
1227
~~~~
1228
1229
+A vector can be destructured using pattern matching:
1230
+
1231
+~~~~
1232
+let numbers: [int * 3] = [1, 2, 3];
1233
+let score = match numbers {
1234
+ [] => 0,
1235
+ [a] => a * 10,
1236
+ [a, b] => a * 6 + b * 4,
1237
+ [a, b, c, ..rest] => a * 5 + b * 3 + c * 2 + rest.len() as int
1238
+};
1239
1240
1241
The elements of a vector _inherit the mutability of the vector_,
1242
and as such, individual elements may not be reassigned when the
1243
vector lives in an immutable slot.
0 commit comments