Arrays & slices
Contiguous storage and borrowed views.
Fixed arrays
T[N] is inline contiguous storage for exactly N live elements. N is a compile-time usize. An array does not itself allocate on the heap.
Slices
T[] and readonly T[] provide read-only non-owning views. mut T[] grants writable element access. Slices carry data and length; they neither own the elements nor retain their backing owner.
Projections
Arrays and slices expose .Length and .Data. Obtaining the raw data pointer does not make its dereference safe or extend any lifetime.
Indexing
Base[Index] checks that the index is below the length in every profile and fatal-traps on failure. The index has the expected type usize. Writable access yields a writable element place; read-only access does not.
Invalidation
Returning a slice backed by a local array is invalid. Container growth, moves, or destruction may invalidate a view. The owner and operation contracts determine when a borrowed view remains usable.
Example: borrow a view of fixed storage
var Samples: i32[4] = [10, 20, 30, 40];
let View: readonly i32[] = Samples;
let First: i32 = View[0];Samples owns the four elements. View borrows them as a slice; it is not another four-element array. Keep the backing storage alive while the view is used. These are local declarations, using the fixed-array and readonly-slice forms.