pub type Array<T, const N: usize> = NonEmpty<[T; N]>;
Expand description
A non-empty array of known size.
Aliased Type§
struct Array<T, const N: usize> { /* private fields */ }
Implementations§
source§impl<const N: usize, T> Array<T, N>
impl<const N: usize, T> Array<T, N>
Array
methods
sourcepub const unsafe fn new_ref_unchecked(src: &[T; N]) -> &Self
pub const unsafe fn new_ref_unchecked(src: &[T; N]) -> &Self
sourcepub unsafe fn new_mut_unchecked(src: &mut [T; N]) -> &mut Self
pub unsafe fn new_mut_unchecked(src: &mut [T; N]) -> &mut Self
sourcepub const unsafe fn new_unchecked(src: [T; N]) -> Self
pub const unsafe fn new_unchecked(src: [T; N]) -> Self
sourcepub fn each_ref(&self) -> Array<&T, N>
pub fn each_ref(&self) -> Array<&T, N>
Borrows each element and returns a NonEmpty
array of references with the same size as self.
sourcepub fn each_mut(&mut self) -> Array<&mut T, N>
pub fn each_mut(&mut self) -> Array<&mut T, N>
Borrows each element mutably and returns a NonEmpty
array of mutable references with the same size as self.
sourcepub fn each_map<F, U>(self, f: F) -> Array<U, N>where
F: FnMut(T) -> U,
pub fn each_map<F, U>(self, f: F) -> Array<U, N>where
F: FnMut(T) -> U,
Returns a NonEmpty
array of the same size as self, with function f applied to each element in order.
sourcepub const fn as_slice_ne(&self) -> &Slice<T>
pub const fn as_slice_ne(&self) -> &Slice<T>
Returns a NonEmpty
slice.
sourcepub fn as_mut_slice_ne(&mut self) -> &mut Slice<T>
pub fn as_mut_slice_ne(&mut self) -> &mut Slice<T>
Returns a NonEmpty
slice.
sourcepub const fn as_array(&self) -> &[T; N]
pub const fn as_array(&self) -> &[T; N]
Returns a primitive array
.
sourcepub fn as_mut_array(&mut self) -> &mut [T; N]
pub fn as_mut_array(&mut self) -> &mut [T; N]
Returns a primitive array
.
sourcepub fn into_array(self) -> [T; N]
pub fn into_array(self) -> [T; N]
Returns a primitive array
.
source§impl<T, const N: usize> Array<T, N>
impl<T, const N: usize> Array<T, N>
Known non-empty iterator for Array
.
pub fn into_iter_ne(self) -> NonEmpty<IntoIter<T, N>>
Methods from Deref<Target = Slice<T>>§
sourcepub fn each_ref(&self) -> Array<&T, N>
pub fn each_ref(&self) -> Array<&T, N>
Borrows each element and returns a NonEmpty
array of references with the same size as self.
sourcepub fn each_mut(&mut self) -> Array<&mut T, N>
pub fn each_mut(&mut self) -> Array<&mut T, N>
Borrows each element mutably and returns a NonEmpty
array of mutable references with the same size as self.
sourcepub fn as_slice_ne(&self) -> &Slice<T>
pub fn as_slice_ne(&self) -> &Slice<T>
Returns a NonEmpty
slice.
sourcepub fn as_mut_slice_ne(&mut self) -> &mut Slice<T>
pub fn as_mut_slice_ne(&mut self) -> &mut Slice<T>
Returns a NonEmpty
slice.
sourcepub fn as_array(&self) -> &[T; N]
pub fn as_array(&self) -> &[T; N]
Returns a primitive array
.
sourcepub fn as_mut_array(&mut self) -> &mut [T; N]
pub fn as_mut_array(&mut self) -> &mut [T; N]
Returns a primitive array
.
sourcepub fn peek(&mut self) -> &I::Item
pub fn peek(&mut self) -> &I::Item
Peek this NonEmpty
iterator, without advancing it.
See Self::peekable
.
sourcepub fn peek_mut(&mut self) -> &mut I::Item
pub fn peek_mut(&mut self) -> &mut I::Item
Peek and modify this NonEmpty
iterator, without advancing it.
See Self::peekable
.
sourcepub fn as_slice(&self) -> &[T]
pub fn as_slice(&self) -> &[T]
Returns a primitive slice
.
sourcepub fn as_mut_slice(&mut self) -> &mut [T]
pub fn as_mut_slice(&mut self) -> &mut [T]
Returns a primitive slice
.
sourcepub fn len_ne(&self) -> NonZeroUsize
pub fn len_ne(&self) -> NonZeroUsize
Returns the known non-zero length.
sourcepub fn split_first(&self) -> (&T, &[T])
pub fn split_first(&self) -> (&T, &[T])
Returns the first element, guaranteed, and the rest of the elements.
sourcepub fn split_last(&self) -> (&T, &[T])
pub fn split_last(&self) -> (&T, &[T])
Returns the last element, guaranteed, and the rest of the elements.
sourcepub fn split_first_mut(&mut self) -> (&mut T, &mut [T])
pub fn split_first_mut(&mut self) -> (&mut T, &mut [T])
Returns the first element, guaranteed, and the rest of the elements.
sourcepub fn split_last_mut(&mut self) -> (&mut T, &mut [T])
pub fn split_last_mut(&mut self) -> (&mut T, &mut [T])
Returns the last element, guaranteed, and the rest of the elements.
pub fn iter_ne(&self) -> NonEmpty<Iter<'_, T>>
pub fn iter_mut_ne(&mut self) -> NonEmpty<IterMut<'_, T>>
sourcepub fn as_vec(&self) -> &Vec<T>
pub fn as_vec(&self) -> &Vec<T>
Returns a std::vec::Vec
.
sourcepub unsafe fn as_mut_vec(&mut self) -> &mut Vec<T>
pub unsafe fn as_mut_vec(&mut self) -> &mut Vec<T>
sourcepub fn as_slice_ne(&self) -> &Slice<T>
pub fn as_slice_ne(&self) -> &Slice<T>
Returns a NonEmpty
slice.
sourcepub fn as_mut_slice_ne(&mut self) -> &mut Slice<T>
pub fn as_mut_slice_ne(&mut self) -> &mut Slice<T>
Returns a NonEmpty
slice.
sourcepub fn capacity(&self) -> NonZeroUsize
pub fn capacity(&self) -> NonZeroUsize
Returns the known non-zero length.
sourcepub fn reserve_exact(&mut self, additional: usize)
pub fn reserve_exact(&mut self, additional: usize)
See reserve_exact
.
sourcepub fn try_reserve(&mut self, additional: usize) -> Result<(), TryReserveError>
pub fn try_reserve(&mut self, additional: usize) -> Result<(), TryReserveError>
See try_reserve
.
sourcepub fn try_reserve_exact(
&mut self,
additional: usize,
) -> Result<(), TryReserveError>
pub fn try_reserve_exact( &mut self, additional: usize, ) -> Result<(), TryReserveError>
See try_reserve_exact
.
sourcepub fn shrink_to_fit(&mut self)
pub fn shrink_to_fit(&mut self)
See shrink_to_fit
.
sourcepub fn truncate(&mut self, len: NonZeroUsize)
pub fn truncate(&mut self, len: NonZeroUsize)
Shortens the vector to a guaranteed-nonzero length
See truncate
.
sourcepub unsafe fn set_len(&mut self, new_len: NonZeroUsize)
pub unsafe fn set_len(&mut self, new_len: NonZeroUsize)
sourcepub fn dedup_by_key<F, K>(&mut self, key: F)
pub fn dedup_by_key<F, K>(&mut self, key: F)
See dedup_by_key
.
sourcepub fn resize_with<F>(&mut self, new_len: NonZeroUsize, f: F)where
F: FnMut() -> T,
pub fn resize_with<F>(&mut self, new_len: NonZeroUsize, f: F)where
F: FnMut() -> T,
See resize_with
.
sourcepub fn spare_capacity_mut(&mut self) -> &mut [MaybeUninit<T>]
pub fn spare_capacity_mut(&mut self) -> &mut [MaybeUninit<T>]
See spare_capacity_mut
.
Trait Implementations§
source§impl<T, const N: usize> BorrowMut<[T]> for Array<T, N>
impl<T, const N: usize> BorrowMut<[T]> for Array<T, N>
source§fn borrow_mut(&mut self) -> &mut [T]
fn borrow_mut(&mut self) -> &mut [T]
source§impl<T, const N: usize> BorrowMut<NonEmpty<[T]>> for Array<T, N>
impl<T, const N: usize> BorrowMut<NonEmpty<[T]>> for Array<T, N>
source§fn borrow_mut(&mut self) -> &mut Slice<T>
fn borrow_mut(&mut self) -> &mut Slice<T>
source§impl<'a, T, const N: usize> IntoIterator for &'a Array<T, N>
impl<'a, T, const N: usize> IntoIterator for &'a Array<T, N>
source§impl<'a, T, const N: usize> IntoIterator for &'a mut Array<T, N>
impl<'a, T, const N: usize> IntoIterator for &'a mut Array<T, N>
source§impl<const N: usize, T> IntoIterator for Array<T, N>
impl<const N: usize, T> IntoIterator for Array<T, N>
source§impl<T, const N: usize> JsonSchema for Array<T, N>where
T: JsonSchema,
impl<T, const N: usize> JsonSchema for Array<T, N>where
T: JsonSchema,
source§fn schema_name() -> String
fn schema_name() -> String
source§fn json_schema(gen: &mut SchemaGenerator) -> Schema
fn json_schema(gen: &mut SchemaGenerator) -> Schema
source§fn is_referenceable() -> bool
fn is_referenceable() -> bool
$ref
keyword. Read moresource§impl<const N: usize, T> Ord for Array<T, N>where
T: Ord,
impl<const N: usize, T> Ord for Array<T, N>where
T: Ord,
source§impl<A, B, const N: usize> PartialEq<&NonEmpty<[B]>> for Array<A, N>where
A: PartialEq<B>,
impl<A, B, const N: usize> PartialEq<&NonEmpty<[B]>> for Array<A, N>where
A: PartialEq<B>,
source§impl<A, B, const N: usize> PartialEq<&mut NonEmpty<[B]>> for Array<A, N>where
A: PartialEq<B>,
impl<A, B, const N: usize> PartialEq<&mut NonEmpty<[B]>> for Array<A, N>where
A: PartialEq<B>,
source§impl<T, U, const N: usize> PartialEq<[U; N]> for Array<T, N>where
T: PartialEq<U>,
impl<T, U, const N: usize> PartialEq<[U; N]> for Array<T, N>where
T: PartialEq<U>,
source§impl<A, B, const N: usize> PartialEq<NonEmpty<[B]>> for Array<A, N>where
A: PartialEq<B>,
impl<A, B, const N: usize> PartialEq<NonEmpty<[B]>> for Array<A, N>where
A: PartialEq<B>,
source§impl<A, B, const N: usize> PartialEq<NonEmpty<[B; N]>> for Array<A, N>where
A: PartialEq<B>,
impl<A, B, const N: usize> PartialEq<NonEmpty<[B; N]>> for Array<A, N>where
A: PartialEq<B>,
source§impl<T, U, const N: usize> PartialEq<Vec<U>> for Array<T, N>where
T: PartialEq<U>,
impl<T, U, const N: usize> PartialEq<Vec<U>> for Array<T, N>where
T: PartialEq<U>,
source§impl<T, const N: usize> PartialOrd<[T]> for Array<T, N>where
T: PartialOrd,
impl<T, const N: usize> PartialOrd<[T]> for Array<T, N>where
T: PartialOrd,
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read moresource§impl<T, const N: usize> PartialOrd<[T; N]> for Array<T, N>where
T: PartialOrd,
impl<T, const N: usize> PartialOrd<[T; N]> for Array<T, N>where
T: PartialOrd,
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read moresource§impl<T, const N: usize> PartialOrd<Vec<T>> for Array<T, N>where
T: PartialOrd,
impl<T, const N: usize> PartialOrd<Vec<T>> for Array<T, N>where
T: PartialOrd,
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read moresource§impl<const N: usize, T> PartialOrd for Array<T, N>where
T: PartialOrd,
impl<const N: usize, T> PartialOrd for Array<T, N>where
T: PartialOrd,
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read more