Span¶
No import is needed.
Read the usage guide for examples and common tasks. This reference lists the public declarations for this part of the library. See Reading API signatures for parameter and result notation.
Span¶
A writable, bounds-checked view of a contiguous range in an array. Changes affect the original array. Spans keep their source alive, cannot be stored in heap objects, and cannot cross an await.
constructor¶
A view of array[offset .. offset + length). Traps unless that range lies inside array; every later access relies on it.
of¶
A span over the whole of array.
length¶
Number of elements this span covers.
is_empty¶
True when this span covers no elements.
as_read_only¶
The same elements, viewed read-only.
this¶
The element at index (relative to this span, not the backing array). Traps if out of range.
this¶
Overwrites the element at index (relative to this span). Traps if out of range.
slice¶
Returns a view of elements from start (inclusive) to end (exclusive) that shares this span's storage. Panics unless 0 <= start <= end <= length.
slice¶
Returns a view from start to the end of this span. Panics unless 0 <= start <= length.
index_of¶
Index of the first element equal to value, or None.
contains¶
True when some element equals value.
sequence_equal¶
True when other has the same length and pairwise-equal elements.
sequence_equal¶
Returns whether both spans contain equal elements in the same order.
copy_from¶
Copies every element of src into the start of this span. The destination must be large enough. Overlapping ranges are supported.
copy_from¶
Copies every element of src into the start of this span. The destination must be large enough. Overlapping ranges are supported.
copy_to¶
Copies every element into the start of dst. Panics if the destination is shorter. Overlapping ranges are supported.
copy_to¶
Copies every element into the start of dst. Panics if the destination is shorter. Overlapping ranges are supported.
fill¶
Fills every element of this span with value.
to_array¶
Copies every element of this span into a fresh, independently-owned array.
to_array¶
Copies the elements into a new array.