ArraySlice
struct · ferroui-base · v0.5.0
struct ArraySlice<T>
A view over length elements of a shared array starting at start.
Members
empty
fn empty() -> Self
An empty slice (C# ArraySlice<T>.Empty).
new
fn new(data: Vec<T>) -> Self
A slice over a whole new array.
from_shared
fn from_shared(data: Rc<RefCell<Vec<T>>>, start: usize, length: usize) -> Self
A slice over part of a shared array.
Panics when the range is outside the array.
data
fn data(self: &Self) -> &Rc<RefCell<Vec<T>>>
The shared array this slice views.
is_empty
fn is_empty(self: &Self) -> bool
Whether the slice has no elements.
start
fn start(self: &Self) -> usize
The offset of the slice inside the shared array.
length
fn length(self: &Self) -> usize
The number of elements.
span
fn span(self: &Self) -> Ref<'_, [T]>
Borrows the elements (C# Span).
Panics when the array is mutably borrowed.
span_mut
fn span_mut(self: &Self) -> RefMut<'_, [T]>
Mutably borrows the elements (C# Span).
Panics when the array is borrowed.
set
fn set(self: &Self, index: usize, value: T)
Writes one element.
slice
fn slice(self: &Self, start: usize, length: usize) -> Self
A slice of the same array. As upstream, start is relative to the
underlying array, not to this slice.
take
fn take(self: &Self, length: usize) -> Self
The first length elements.
Panics when length is larger than the slice.
skip
fn skip(self: &Self, length: usize) -> Self
Everything after the first length elements.
Panics when length is larger than the slice.
get
fn get(self: &Self, index: usize) -> T
Reads one element.
fill
fn fill(self: &Self, value: T)
Sets every element to value.
Trait implementations
SendSyncFreezeUnsafeUnpinUnpinUnwindSafeRefUnwindSafeClassDefaultsBorrow<T>BorrowMut<T>CloneToUninitInto<U>From<T>TryInto<U>TryFrom<U>AnyToOwnedErasedDestructorIntoEitherCloneFrom<Vec<T>>
Availability
Extracted for aarch64-apple-darwin. Cargo features are listed in the crate index.