File tree Expand file tree Collapse file tree 1 file changed +17
-1
lines changed Expand file tree Collapse file tree 1 file changed +17
-1
lines changed Original file line number Diff line number Diff line change @@ -6,6 +6,22 @@ import std.core;
6
6
/*!
7
7
The array library contains a helper type to make it easier to create multi-dimensional arrays
8
8
and pass arrays to functions as parameters.
9
+
10
+ ## Multi-dimensional arrays
11
+
12
+ The following example shows how to use multi-dimensional arrays with structs.
13
+
14
+ ```rust
15
+ import std.array;
16
+
17
+ struct File {
18
+ u8 width, height;
19
+ std::Array<std::Array<u8, parent.width>, height> cells;
20
+ };
21
+
22
+ File file @ 0x00;
23
+ ```
24
+
9
25
*/
10
26
11
27
namespace auto std {
@@ -27,7 +43,7 @@ namespace auto std {
27
43
struct ByteSizedArray<T, auto NumBytes> {
28
44
u64 startAddress = $;
29
45
T array[while($ - startAddress < NumBytes)] [[inline]];
30
-
46
+
31
47
std::assert($ - startAddress == NumBytes, "Not enough bytes available to fit a whole number of types");
32
48
} [[format("std::impl::format_array")]];
33
49
You can’t perform that action at this time.
0 commit comments