Mojo module
inline_array
Provides a fixed-size array implementation with compile-time size checking.
The InlineArray
type represents a fixed-size sequence of homogeneous elements where the size
is determined at compile time. It provides efficient memory layout and bounds checking while
maintaining type safety. The InlineArray
type is part of the prelude
module and therefore
does not need to be imported in order to use it.
Example:
# Create an array of 3 integers
var arr = InlineArray[Int, 3](1, 2, 3)
# Access elements
print(arr[0]) # Prints 1
# Fill with a value
var filled = InlineArray[Int, 5](fill=42)
# Create an array of 3 integers
var arr = InlineArray[Int, 3](1, 2, 3)
# Access elements
print(arr[0]) # Prints 1
# Fill with a value
var filled = InlineArray[Int, 5](fill=42)
Note:
- For historical reasons, destructors are not run by default on the elements of an
InlineArray
. This can be controlled with therun_destructors
parameter. In the future, this will default toTrue
and therun_destructors
parameter will be removed.
Structs
-
InlineArray
: A fixed-size sequence of homogeneous elements where size is a constant expression.
Was this page helpful?
Thank you! We'll create more content like this.
Thank you for helping us improve!