Slice<T>
Struct · built-in type
struct Slice<T>A view of a part of an array: a[i..j], a[..j], a[i..]. Nothing is copied, and writing slice[k] writes the
array.
A slice has Length, s[i] (also s[^i]), foreach and slicing again; Slice<T>.ToArray copies. Functions
that only read take a ReadOnlySlice, to which a Slice<T> and a T[] convert.
Fields
Section titled “Fields”| Name | Description |
|---|---|
Length |
The number of elements. |
Length
Section titled “Length”int LengthThe number of elements.
Methods
Section titled “Methods”| Name | Description |
|---|---|
ToArray |
A new array with the elements of the slice. |
Ptr |
A pointer to the first element (unsafe). |
ToArray
Section titled “ToArray”T[] ToArray()A new array with the elements of the slice.
T* Ptr()A pointer to the first element (unsafe).