Skip to main content

ArraySlice

Struct ArraySlice 

Source
pub struct ArraySlice<T> { /* private fields */ }
Expand description

A view over length elements of a shared array starting at start.

Implementations§

Source§

impl<T> ArraySlice<T>

Source

pub fn empty() -> Self

An empty slice (C# ArraySlice<T>.Empty).

Source

pub fn new(data: Vec<T>) -> Self

A slice over a whole new array.

Source

pub 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.

Source

pub fn data(&self) -> &Rc<RefCell<Vec<T>>>

The shared array this slice views.

Source

pub fn is_empty(&self) -> bool

Whether the slice has no elements.

Source

pub fn start(&self) -> usize

The offset of the slice inside the shared array.

Source

pub fn length(&self) -> usize

The number of elements.

Source

pub fn span(&self) -> Ref<'_, [T]>

Borrows the elements (C# Span).

Panics when the array is mutably borrowed.

Source

pub fn span_mut(&self) -> RefMut<'_, [T]>

Mutably borrows the elements (C# Span).

Panics when the array is borrowed.

Source

pub fn set(&self, index: usize, value: T)

Writes one element.

Source

pub fn slice(&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.

Source

pub fn take(&self, length: usize) -> Self

The first length elements.

Panics when length is larger than the slice.

Source

pub fn skip(&self, length: usize) -> Self

Everything after the first length elements.

Panics when length is larger than the slice.

Source§

impl<T: Copy> ArraySlice<T>

Source

pub fn get(&self, index: usize) -> T

Reads one element.

Source

pub fn fill(&self, value: T)

Sets every element to value.

Trait Implementations§

Source§

impl<T> Clone for ArraySlice<T>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<T> From<Vec<T>> for ArraySlice<T>

Source§

fn from(data: Vec<T>) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

§

impl<T> !RefUnwindSafe for ArraySlice<T>

§

impl<T> !Send for ArraySlice<T>

§

impl<T> !Sync for ArraySlice<T>

§

impl<T> !UnwindSafe for ArraySlice<T>

§

impl<T> Freeze for ArraySlice<T>
where Rc<RefCell<Vec<T>>>: Freeze,

§

impl<T> Unpin for ArraySlice<T>
where Rc<RefCell<Vec<T>>>: Unpin,

§

impl<T> UnsafeUnpin for ArraySlice<T>
where Rc<RefCell<Vec<T>>>: UnsafeUnpin,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> ClassDefaults for T
where T: ?Sized,

Source§

fn static_constructor()

The static constructor of a type: work done once per thread, after the properties of the type are registered and before its first instance exists (class handlers, affects_render, metadata overrides). Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.