From b10a37af673970217a784778d0599efb74a91733 Mon Sep 17 00:00:00 2001 From: C3pa <41503714+C3pa@users.noreply.github.com> Date: Wed, 18 Jun 2025 08:46:33 +0200 Subject: [PATCH] Docs: describe how to create multidimensional `std::Array` (#407) doc: descirbe how to create multidimensional std::Array Co-authored-by: paxcut <53811119+paxcut@users.noreply.github.com> --- includes/std/array.pat | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/includes/std/array.pat b/includes/std/array.pat index 444bdba..8a69b44 100644 --- a/includes/std/array.pat +++ b/includes/std/array.pat @@ -6,6 +6,22 @@ import std.core; /*! The array library contains a helper type to make it easier to create multi-dimensional arrays and pass arrays to functions as parameters. + + ## Multi-dimensional arrays + + The following example shows how to use multi-dimensional arrays with structs. + + ```rust + import std.array; + + struct File { + u8 width, height; + std::Array, height> cells; + }; + + File file @ 0x00; + ``` + */ namespace auto std { @@ -27,7 +43,7 @@ namespace auto std { struct ByteSizedArray { u64 startAddress = $; T array[while($ - startAddress < NumBytes)] [[inline]]; - + std::assert($ - startAddress == NumBytes, "Not enough bytes available to fit a whole number of types"); } [[format("std::impl::format_array")]];