menu
Slices and Fixed Arrays
Slices and Fixed Arrays
Slices and Fixed Arrays
fixed arrays
[T; N]slices are just fat pointers
&[T]is also a fat pointer,[T]is a managed slice,^[T]is an owned slice[T]is managed by default (just likeFunctionandDynamicare managed fat pointers by default)subslicing: a range subscript is a view, not a copy —
values[1..4]borrows a window of the backing storethe view carries the receiver's access: a managed receiver gives a managed
[T]view,&readonly/&exclusivegive same-access borrowed views.slice()keeps its TypeScript meaning and copies;.toOwned()copies a view into owned storagevalues[1..4] = othercopies in — lengths must match, elements must beCopysplitAtthrough&exclusiveyields two disjoint exclusive views, both mutablea view keeps its backing array alive; owned slices
^[T]move as a whole and never split