Struct Array

Source
pub struct Array<Wrapped> { /* private fields */ }
Expand description

A wrapper for array types that exposes checked APIs only

Implementations§

Source§

impl<Wrapped> Array<Wrapped>

Source

pub const fn new(array: Wrapped) -> Self

Wraps an array

Source

pub fn into_inner(self) -> Wrapped

Returns the wrapped array

Trait Implementations§

Source§

impl<T, Wrapped> ArrayAlloc<T> for Array<Wrapped>
where Wrapped: AsRef<[T]> + AsMut<[T]> + CanAlloc<T>,

Source§

type Error = <Wrapped as CanAlloc<T>>::Error

An alloc related error
Source§

fn alloc_new() -> Result<Self, Self::Error>

Creates a newly allocated instance of Self
Source§

fn alloc_clone<Source>(elements: &Source) -> Result<Self, Self::Error>
where Source: ArrayRef<T>, T: Clone,

Clones source into a newly allocated instance of Self
Source§

fn grow_with( &mut self, len: usize, init: impl FnMut() -> T, ) -> Result<(), Self::Error>

Grows self to the given capacity if the current length is smaller than len and inits new elements using init
Source§

fn grow(&mut self, len: usize) -> Result<(), Self::Error>
where T: Default,

Grows self to the given capacity if the current length is smaller than len and inits new elements using Default
Source§

fn shrink(&mut self, len: usize) -> Result<(), Self::Error>

Shrinks self to the given capacity if the current length is larger than len
Source§

fn push_front(&mut self, element: T) -> Result<(), Self::Error>

Pushes an element to the front of self
Source§

fn push_n_front<Source>(&mut self, elements: &Source) -> Result<(), Self::Error>
where Source: ArrayRef<T>, T: Clone,

Pushes some elements to the front of self
Source§

fn push_back(&mut self, element: T) -> Result<(), Self::Error>

Pushes an element to the front of self
Source§

fn push_n_back<Source>(&mut self, elements: &Source) -> Result<(), Self::Error>
where Source: ArrayRef<T>, T: Clone,

Pushes some elements to the front of self
Source§

fn pop_front(&mut self) -> Result<Option<T>, Self::Error>

Pops an element from the front of self
Source§

fn pop_n_front(&mut self, len: usize) -> Result<Option<Self>, Self::Error>

Pops multiple elements from the front of self
Source§

fn pop_back(&mut self) -> Result<Option<T>, Self::Error>

Pops an element from the back of self
Source§

fn pop_n_back(&mut self, len: usize) -> Result<Option<Self>, Self::Error>

Pops multiple elements from the back of self
Source§

impl<T, Wrapped> ArrayMut<T> for Array<Wrapped>
where Wrapped: AsRef<[T]> + AsMut<[T]>,

Source§

fn as_slice_mut(&mut self) -> &mut [T]

The underlying element as mutable slice
Source§

fn get_mut(&mut self, index: usize) -> Option<&mut T>

Gets a mutable reference to an element
Source§

fn get_n_mut<Range>(&mut self, range: Range) -> Option<Array<&mut [T]>>
where Range: RangeBounds<usize>,

Gets a mutable subrange
Source§

fn first_mut(&mut self) -> Option<&mut T>

Returns a mutable reference to the first element
Source§

fn last_mut(&mut self) -> Option<&mut T>

Returns a mutable reference to the last element
Source§

fn iter_mut(&mut self) -> SliceIterMut<'_, T>

Returns an iterator that mutably references the elements
Source§

fn rotate_left(&mut self, count: usize)

Rotates the elements left by count fields
Source§

fn rotate_right(&mut self, count: usize)

Rotates the elements right by count fields
Source§

fn reverse(&mut self)

Reverses the order of elements in the slice
Source§

impl<T, Wrapped> ArrayRef<T> for Array<Wrapped>
where Wrapped: AsRef<[T]>,

Source§

fn as_slice(&self) -> &[T]

The underlying elements as slice
Source§

fn len(&self) -> usize

The length of the wrapped elements
Source§

fn is_empty(&self) -> bool

Whether self is empty or not
Source§

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

Gets an element
Source§

fn get_n<Range>(&self, range: Range) -> Option<Array<&[T]>>
where Range: RangeBounds<usize>,

Gets a subrange
Source§

fn first(&self) -> Option<&T>

Returns a reference to the first element
Source§

fn last(&self) -> Option<&T>

Returns a reference to the last element
Source§

fn iter(&self) -> SliceIter<'_, T>

Returns an iterator that references the elements
Source§

fn clone_to<Source>(&self, dest: &mut Source) -> Result<(), BufferTooSmall>
where Source: ArrayMut<T>, T: Clone,

Clones self to target
Source§

impl<Wrapped> AsRef<Array<Wrapped>> for Array<Wrapped>

Source§

fn as_ref(&self) -> &Array<Wrapped>

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl<Wrapped> Clone for Array<Wrapped>
where Wrapped: Clone,

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl<Wrapped> Debug for Array<Wrapped>
where Wrapped: Debug,

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<Wrapped> Default for Array<Wrapped>
where Wrapped: Default,

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<Wrapped> Hash for Array<Wrapped>
where Wrapped: Hash,

Source§

fn hash<H: Hasher>(&self, state: &mut H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl<Wrapped> IntoIterator for Array<Wrapped>
where Wrapped: IntoIterator,

Source§

type Item = <Wrapped as IntoIterator>::Item

The type of the elements being iterated over.
Source§

type IntoIter = <Wrapped as IntoIterator>::IntoIter

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
Source§

impl<Wrapped> Ord for Array<Wrapped>
where Wrapped: Ord,

Source§

fn cmp(&self, other: &Self) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl<Wrapped> PartialEq for Array<Wrapped>
where Wrapped: PartialEq,

Source§

fn eq(&self, other: &Self) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<Wrapped> PartialOrd for Array<Wrapped>
where Wrapped: PartialOrd,

Source§

fn partial_cmp(&self, other: &Self) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl<Wrapped> Copy for Array<Wrapped>
where Wrapped: Copy,

Source§

impl<Wrapped> Eq for Array<Wrapped>
where Wrapped: Eq,

Auto Trait Implementations§

§

impl<Wrapped> Freeze for Array<Wrapped>
where Wrapped: Freeze,

§

impl<Wrapped> RefUnwindSafe for Array<Wrapped>
where Wrapped: RefUnwindSafe,

§

impl<Wrapped> Send for Array<Wrapped>
where Wrapped: Send,

§

impl<Wrapped> Sync for Array<Wrapped>
where Wrapped: Sync,

§

impl<Wrapped> Unpin for Array<Wrapped>
where Wrapped: Unpin,

§

impl<Wrapped> UnwindSafe for Array<Wrapped>
where Wrapped: UnwindSafe,

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, Array> ArrayAllocPanic<T> for Array
where Array: ArrayAlloc<T>,

Source§

fn alloc_new() -> Array

Creates a newly allocated instance of Self
Source§

fn alloc_clone<Source>(elements: &Source) -> Array
where Source: ArrayRef<T>, T: Clone,

Clones source into a newly allocated instance of Self
Source§

fn grow_with(&mut self, len: usize, init: impl FnMut() -> T)

Grows self to the given capacity if the current length is smaller than len and inits new elements using init
Source§

fn grow(&mut self, len: usize)
where T: Default,

Grows self to the given capacity if the current length is smaller than len and inits new elements using Default
Source§

fn shrink(&mut self, len: usize)

Shrinks self to the given capacity if the current length is larger than len
Source§

fn push_front(&mut self, element: T)

Pushes an element to the front of self
Source§

fn push_n_front<Source>(&mut self, elements: &Source)
where Source: ArrayRef<T>, T: Clone,

Pushes some elements to the front of self
Source§

fn push_back(&mut self, element: T)

Pushes an element to the front of self
Source§

fn push_n_back<Source>(&mut self, elements: &Source)
where Source: ArrayRef<T>, T: Clone,

Pushes some elements to the front of self
Source§

fn pop_front(&mut self) -> Option<T>

Pops an element from the front of self
Source§

fn pop_n_front(&mut self, len: usize) -> Option<Array>

Pops multiple elements from the front of self
Source§

fn pop_back(&mut self) -> Option<T>

Pops an element from the back of self
Source§

fn pop_n_back(&mut self, len: usize) -> Option<Array>

Pops multiple elements from the back of self
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> 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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.