1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
## std.arrays: The array[T, size] primitive and associated functions.
## A stub module for documentation. Mostly compiler magic.
## Primitive fixed-size arrays. Their size is statically known at compile-time.
@[magic]
pub type array[T, size: const uint]
## Array access. Returns None if i is out of range.
@[magic]
pub func get[T, size: const uint](self: lent array[T, size], i: uint): lent T?
## Array access. Returns None if i is out of range.
@[magic]
pub func get[T, size: const uint](self: mut array[T, size], i: uint): mut T?
## Array mutation.
# todo: how do we detect range errors?
@[magic]
pub func set[T, size: const uint](self: mut array[T, size], i: uint, val: T): Success[IndexOutOfBounds]
## A helper function to get the length of an array.
## Known to the compiler, and computed at compile-time.
@[inline]
pub func len[T, size: const uint](self: lent array[T, size]): uint = size
type ArrayIter[T, size: const uint] = struct
...
pub func iter[T, size: const uint](self: array[T, size]): ArrayIter[T, S] =
...
# todo: Eq, PartialEq, Ord, PartialOrd
|