Type Alias nunny::Array

source ·
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>

Array methods

source

pub const fn new_ref(src: &[T; N]) -> Option<&Self>

Returns a NonEmpty array.

Returns None if src is empty.

source

pub fn new_mut(src: &mut [T; N]) -> Option<&mut Self>

Returns a NonEmpty array.

Returns None if src is empty.

source

pub fn new(src: [T; N]) -> Option<Self>

Returns a NonEmpty array.

Returns None if src is empty.

source

pub const unsafe fn new_ref_unchecked(src: &[T; N]) -> &Self

Create a NonEmpty array.

§Safety
  • src must not be empty
source

pub unsafe fn new_mut_unchecked(src: &mut [T; N]) -> &mut Self

Create a NonEmpty array.

§Safety
  • src must not be empty
source

pub const unsafe fn new_unchecked(src: [T; N]) -> Self

Create a NonEmpty array.

§Safety
  • src must not be empty
source

pub fn each_ref(&self) -> Array<&T, N>

Borrows each element and returns a NonEmpty array of references with the same size as self.

source

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.

source

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.

source

pub const fn as_slice_ne(&self) -> &Slice<T>

Returns a NonEmpty slice.

source

pub fn as_mut_slice_ne(&mut self) -> &mut Slice<T>

Returns a NonEmpty slice.

source

pub const fn as_array(&self) -> &[T; N]

Returns a primitive array.

source

pub fn as_mut_array(&mut self) -> &mut [T; N]

Returns a primitive array.

source

pub fn into_array(self) -> [T; N]

Returns a primitive array.

source§

impl<T, const N: usize> Array<T, N>

Known non-empty iterator for Array.

source

pub fn into_iter_ne(self) -> NonEmpty<IntoIter<T, N>>

source§

impl<T> Array<T, 1>

Special case for Arrays of length one

source

pub const fn of(item: T) -> Self

Create a NonEmpty array of a single element

source

pub fn of_mut(item: &mut T) -> &mut Self

Create a NonEmpty array of a single mutable reference

source

pub const fn of_ref(item: &T) -> &Self

Create a NonEmpty array of a single reference

Methods from Deref<Target = Slice<T>>§

source

pub fn each_ref(&self) -> Array<&T, N>

Borrows each element and returns a NonEmpty array of references with the same size as self.

source

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.

source

pub fn as_slice_ne(&self) -> &Slice<T>

Returns a NonEmpty slice.

source

pub fn as_mut_slice_ne(&mut self) -> &mut Slice<T>

Returns a NonEmpty slice.

source

pub fn as_array(&self) -> &[T; N]

Returns a primitive array.

source

pub fn as_mut_array(&mut self) -> &mut [T; N]

Returns a primitive array.

source

pub fn peek(&mut self) -> &I::Item

Peek this NonEmpty iterator, without advancing it.

See Self::peekable.

source

pub fn peek_mut(&mut self) -> &mut I::Item

Peek and modify this NonEmpty iterator, without advancing it.

See Self::peekable.

source

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

Returns a primitive slice.

source

pub fn as_mut_slice(&mut self) -> &mut [T]

Returns a primitive slice.

source

pub fn len_ne(&self) -> NonZeroUsize

Returns the known non-zero length.

source

pub fn first(&self) -> &T

Returns the first element, guaranteed.

source

pub fn split_first(&self) -> (&T, &[T])

Returns the first element, guaranteed, and the rest of the elements.

source

pub fn split_last(&self) -> (&T, &[T])

Returns the last element, guaranteed, and the rest of the elements.

source

pub fn last(&self) -> &T

Returns the last element, guaranteed.

source

pub fn first_mut(&mut self) -> &mut T

Returns the first element, guaranteed.

source

pub fn split_first_mut(&mut self) -> (&mut T, &mut [T])

Returns the first element, guaranteed, and the rest of the elements.

source

pub fn split_last_mut(&mut self) -> (&mut T, &mut [T])

Returns the last element, guaranteed, and the rest of the elements.

source

pub fn last_mut(&mut self) -> &mut T

Returns the last element, guaranteed.

source

pub fn iter_ne(&self) -> NonEmpty<Iter<'_, T>>

source

pub fn iter_mut_ne(&mut self) -> NonEmpty<IterMut<'_, T>>

source

pub fn as_vec(&self) -> &Vec<T>

Returns a std::vec::Vec.

source

pub unsafe fn as_mut_vec(&mut self) -> &mut Vec<T>

Returns a std::vec::Vec.

§Safety
  • returned vec must not be emptied through this reference
source

pub fn as_slice_ne(&self) -> &Slice<T>

Returns a NonEmpty slice.

source

pub fn as_mut_slice_ne(&mut self) -> &mut Slice<T>

Returns a NonEmpty slice.

source

pub fn capacity(&self) -> NonZeroUsize

Returns the known non-zero length.

source

pub fn reserve(&mut self, additional: usize)

See reserve.

source

pub fn reserve_exact(&mut self, additional: usize)

source

pub fn try_reserve(&mut self, additional: usize) -> Result<(), TryReserveError>

source

pub fn try_reserve_exact( &mut self, additional: usize, ) -> Result<(), TryReserveError>

source

pub fn shrink_to_fit(&mut self)

source

pub fn shrink_to(&mut self, min_capacity: usize)

See shrink_to.

source

pub fn truncate(&mut self, len: NonZeroUsize)

Shortens the vector to a guaranteed-nonzero length

See truncate.

source

pub unsafe fn set_len(&mut self, new_len: NonZeroUsize)

§Safety
source

pub fn insert(&mut self, index: usize, element: T)

See insert.

source

pub fn dedup_by_key<F, K>(&mut self, key: F)
where F: FnMut(&mut T) -> K, K: PartialEq,

source

pub fn dedup_by<F>(&mut self, same_bucket: F)
where F: FnMut(&mut T, &mut T) -> bool,

See dedup_by.

source

pub fn push(&mut self, value: T)

See push.

source

pub fn append(&mut self, other: &mut Vec<T>)

See append.

source

pub fn resize_with<F>(&mut self, new_len: NonZeroUsize, f: F)
where F: FnMut() -> T,

source

pub fn spare_capacity_mut(&mut self) -> &mut [MaybeUninit<T>]

Trait Implementations§

source§

impl<T, const N: usize> AsMut<[T]> for Array<T, N>

source§

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

Converts this type into a mutable reference of the (usually inferred) input type.
source§

impl<T, const N: usize> AsMut<NonEmpty<[T]>> for Array<T, N>

source§

fn as_mut(&mut self) -> &mut Slice<T>

Converts this type into a mutable reference of the (usually inferred) input type.
source§

impl<T, const N: usize> AsMut<NonEmpty<[T; N]>> for Array<T, N>

source§

fn as_mut(&mut self) -> &mut Self

Converts this type into a mutable reference of the (usually inferred) input type.
source§

impl<T, const N: usize> AsRef<[T]> for Array<T, N>

source§

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

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

impl<T, const N: usize> AsRef<NonEmpty<[T]>> for Array<T, N>

source§

fn as_ref(&self) -> &Slice<T>

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

impl<T, const N: usize> AsRef<NonEmpty<[T; N]>> for Array<T, N>

source§

fn as_ref(&self) -> &Self

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

impl<T, const N: usize> Borrow<[T]> for Array<T, N>

source§

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

Immutably borrows from an owned value. Read more
source§

impl<T, const N: usize> Borrow<NonEmpty<[T]>> for Array<T, N>

source§

fn borrow(&self) -> &Slice<T>

Immutably borrows from an owned value. Read more
source§

impl<T, const N: usize> BorrowMut<[T]> for Array<T, N>

source§

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

Mutably borrows from an owned value. Read more
source§

impl<T, const N: usize> BorrowMut<NonEmpty<[T]>> for Array<T, N>

source§

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

Mutably borrows from an owned value. Read more
source§

impl<const N: usize, T> Deref for Array<T, N>

§

type Target = NonEmpty<[T]>

The resulting type after dereferencing.
source§

fn deref(&self) -> &Self::Target

Dereferences the value.
source§

impl<const N: usize, T> DerefMut for Array<T, N>

source§

fn deref_mut(&mut self) -> &mut Self::Target

Mutably dereferences the value.
source§

impl<'a, T, const N: usize> IntoIterator for &'a Array<T, N>

§

type Item = &'a T

The type of the elements being iterated over.
§

type IntoIter = Iter<'a, T>

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<'a, T, const N: usize> IntoIterator for &'a mut Array<T, N>

§

type Item = &'a mut T

The type of the elements being iterated over.
§

type IntoIter = IterMut<'a, T>

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<const N: usize, T> IntoIterator for Array<T, N>

§

type Item = T

The type of the elements being iterated over.
§

type IntoIter = IntoIter<T, N>

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<T, const N: usize> JsonSchema for Array<T, N>
where T: JsonSchema,

source§

fn schema_name() -> String

The name of the generated JSON Schema. Read more
source§

fn json_schema(gen: &mut SchemaGenerator) -> Schema

Generates a JSON Schema for this type. Read more
source§

fn is_referenceable() -> bool

Whether JSON Schemas generated for this type should be re-used where possible using the $ref keyword. Read more
source§

fn schema_id() -> Cow<'static, str>

Returns a string that uniquely identifies the schema produced by this type. Read more
source§

impl<const N: usize, T> Ord for Array<T, N>
where T: 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 + PartialOrd,

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

impl<A, B, const N: usize> PartialEq<&NonEmpty<[B]>> for Array<A, N>
where A: PartialEq<B>,

source§

fn eq(&self, other: &&Slice<B>) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<A, B, const N: usize> PartialEq<&mut NonEmpty<[B]>> for Array<A, N>
where A: PartialEq<B>,

source§

fn eq(&self, other: &&mut Slice<B>) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<T, U, const N: usize> PartialEq<[U]> for Array<T, N>
where T: PartialEq<U>,

source§

fn eq(&self, other: &[U]) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<T, U, const N: usize> PartialEq<[U; N]> for Array<T, N>
where T: PartialEq<U>,

source§

fn eq(&self, other: &[U; N]) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<A, B, const N: usize> PartialEq<NonEmpty<[B]>> for Array<A, N>
where A: PartialEq<B>,

source§

fn eq(&self, other: &Slice<B>) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<A, B, const N: usize> PartialEq<NonEmpty<[B; N]>> for Array<A, N>
where A: PartialEq<B>,

source§

fn eq(&self, other: &Array<B, N>) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<T, U, const N: usize> PartialEq<Vec<U>> for Array<T, N>
where T: PartialEq<U>,

source§

fn eq(&self, other: &Vec<U>) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<T, const N: usize> PartialOrd<[T]> for Array<T, N>
where T: PartialOrd,

source§

fn partial_cmp(&self, other: &[T]) -> 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

This method 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

This method 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

This method 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

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
source§

impl<T, const N: usize> PartialOrd<[T; N]> for Array<T, N>
where T: PartialOrd,

source§

fn partial_cmp(&self, other: &[T; N]) -> 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

This method 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

This method 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

This method 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

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
source§

impl<T, const N: usize> PartialOrd<Vec<T>> for Array<T, N>
where T: PartialOrd,

source§

fn partial_cmp(&self, other: &Vec<T>) -> 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

This method 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

This method 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

This method 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

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
source§

impl<const N: usize, T> PartialOrd for Array<T, N>
where T: 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

This method 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

This method 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

This method 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

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
source§

impl<'a, T, const N: usize> TryFrom<&'a [T; N]> for &'a Array<T, N>

§

type Error = Error

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

fn try_from(value: &'a [T; N]) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl<'a, T, const N: usize> TryFrom<&'a NonEmpty<[T]>> for &'a Array<T, N>

§

type Error = TryFromSliceError

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

fn try_from(value: &'a Slice<T>) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl<T, const N: usize> TryFrom<&NonEmpty<[T]>> for Array<T, N>
where T: Copy,

§

type Error = TryFromSliceError

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

fn try_from(value: &Slice<T>) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl<'a, T, const N: usize> TryFrom<&'a mut [T; N]> for &'a mut Array<T, N>

§

type Error = Error

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

fn try_from(value: &'a mut [T; N]) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl<'a, T, const N: usize> TryFrom<&'a mut NonEmpty<[T]>> for &'a mut Array<T, N>

§

type Error = TryFromSliceError

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

fn try_from(value: &'a mut Slice<T>) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl<T, const N: usize> TryFrom<&mut NonEmpty<[T]>> for Array<T, N>
where T: Copy,

§

type Error = TryFromSliceError

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

fn try_from(value: &mut Slice<T>) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl<T, const N: usize> TryFrom<[T; N]> for Array<T, N>

§

type Error = Error

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

fn try_from(value: [T; N]) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl<T, const N: usize> TryFrom<Box<NonEmpty<[T]>>> for Box<Array<T, N>>

§

type Error = Box<NonEmpty<[T]>>

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

fn try_from(value: Box<Slice<T>>) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl<T, const N: usize> TryFrom<NonEmpty<Vec<T>>> for Box<Array<T, N>>

§

type Error = NonEmpty<Vec<T>>

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

fn try_from(value: Vec<T>) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl<T, const N: usize> TryFrom<NonEmpty<Vec<T>>> for Array<T, N>

§

type Error = NonEmpty<Vec<T>>

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

fn try_from(value: Vec<T>) -> Result<Self, Self::Error>

Performs the conversion.