# [−][src]Struct generic_array::GenericArray

    pub struct GenericArray<T, U: ArrayLength<T>> { /* fields omitted */ }

Struct representing a generic array - `GenericArray<T, N>` works like [T; N]

## Methods

### `impl<T, N> GenericArray<T, N> where
N: ArrayLength<T>,` [src]

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

Extracts a slice containing the entire array.

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

Extracts a mutable slice containing the entire array.

#### `pub fn from_slice(slice: &[T]) -> &GenericArray<T, N>`[src]

Converts slice to a generic array reference with inferred length;

Length of the slice must be equal to the length of the array.

#### `pub fn from_mut_slice(slice: &mut [T]) -> &mut GenericArray<T, N>`[src]

Converts mutable slice to a mutable generic array reference

Length of the slice must be equal to the length of the array.

### `impl<T: Clone, N> GenericArray<T, N> where
N: ArrayLength<T>,` [src]

#### `pub fn clone_from_slice(list: &[T]) -> GenericArray<T, N>`[src]

Construct a `GenericArray` from a slice by cloning its content

Length of the slice must be equal to the length of the array

### `impl<T, N> GenericArray<T, N> where
N: ArrayLength<T>,` [src]

#### `pub fn from_exact_iter<I>(iter: I) -> Option<Self> where
I: IntoIterator<Item = T>,
<I as IntoIterator>::IntoIter: ExactSizeIterator,` [src]

Creates a new `GenericArray` instance from an iterator with a known exact size.

Returns `None` if the size is not equal to the number of elements in the `GenericArray`.

## Trait Implementations

### `impl<T, U, N> MappedGenericSequence<T, U> for GenericArray<T, N> where
N: ArrayLength<T> + ArrayLength<U>,
GenericArray<U, N>: GenericSequence<U, Length = N>,` [src]

#### `type Mapped = GenericArray<U, N>`

Mapped sequence type

### `impl<T, N> FunctionalSequence<T> for GenericArray<T, N> where
N: ArrayLength<T>,
Self: GenericSequence<T, Item = T, Length = N>,` [src]

#### `fn map<U, F>(self, f: F) -> MappedSequence<Self, T, U> where
Self::Length: ArrayLength<U>,
Self: MappedGenericSequence<T, U>,
F: FnMut(T) -> U,` [src]

Maps a `GenericSequence` to another `GenericSequence`. Read more

#### `fn zip<B, Rhs, U, F>(self, rhs: Rhs, f: F) -> MappedSequence<Self, T, U> where
Self: MappedGenericSequence<T, U>,
Rhs: MappedGenericSequence<B, U, Mapped = MappedSequence<Self, T, U>>,
Self::Length: ArrayLength<B> + ArrayLength<U>,
Rhs: GenericSequence<B, Length = Self::Length>,
F: FnMut(T, Rhs::Item) -> U,` [src]

Combines two `GenericSequence` instances and iterates through both of them, initializing a new `GenericSequence` with the result of the zipped mapping function. Read more

#### `fn fold<U, F>(self, init: U, f: F) -> U where
F: FnMut(U, T) -> U,` [src]

Folds (or reduces) a sequence of data into a single value. Read more

### `impl<T, N> GenericSequence<T> for GenericArray<T, N> where
N: ArrayLength<T>,
Self: IntoIterator<Item = T>,` [src]

#### `type Length = N`

`GenericArray` associated length

#### `type Sequence = Self`

Concrete sequence type used in conjuction with reference implementations of `GenericSequence`

#### `fn generate<F>(f: F) -> GenericArray<T, N> where
F: FnMut(usize) -> T,` [src]

Initializes a new sequence instance using the given function. Read more

### `impl<T, N: ArrayLength<T>> Lengthen<T> for GenericArray<T, N> where
N: Add<B1>,
Add1<N>: ArrayLength<T>,
Add1<N>: Sub<B1, Output = N>,
Sub1<Add1<N>>: ArrayLength<T>,` [src]

#### `type Longer = GenericArray<T, Add1<N>>`

`GenericSequence` that has one more element than `Self`

#### `fn append(self, last: T) -> Self::Longer`[src]

Returns a new array with the given element appended to the end of it. Read more

#### `fn prepend(self, first: T) -> Self::Longer`[src]

Returns a new array with the given element prepended to the front of it. Read more

### `impl<T, N: ArrayLength<T>> Shorten<T> for GenericArray<T, N> where
N: Sub<B1>,
Sub1<N>: ArrayLength<T>,
Sub1<N>: Add<B1, Output = N>,
Add1<Sub1<N>>: ArrayLength<T>,` [src]

#### `type Shorter = GenericArray<T, Sub1<N>>`

`GenericSequence` that has one less element than `Self`

#### `fn pop_back(self) -> (Self::Shorter, T)`[src]

Returns a new array without the last element, and the last element. Read more

#### `fn pop_front(self) -> (T, Self::Shorter)`[src]

Returns a new array without the first element, and the first element. Example: Read more

### `impl<T, N, K> Split<T, K> for GenericArray<T, N> where
N: ArrayLength<T>,
K: ArrayLength<T>,
N: Sub<K>,
Diff<N, K>: ArrayLength<T>,` [src]

#### `type First = GenericArray<T, K>`

First part of the resulting split array

#### `type Second = GenericArray<T, Diff<N, K>>`

Second part of the resulting split array

#### `fn split(self) -> (Self::First, Self::Second)`[src]

Splits an array at the given index, returning the separate parts of the array.

### `impl<T, N, M> Concat<T, M> for GenericArray<T, N> where
N: ArrayLength<T> + Add<M>,
M: ArrayLength<T>,
Sum<N, M>: ArrayLength<T>,` [src]

#### `type Rest = GenericArray<T, M>`

Sequence to be concatenated with `self`

#### `type Output = GenericArray<T, Sum<N, M>>`

Resulting sequence formed by the concatenation.

#### `fn concat(self, rest: Self::Rest) -> Self::Output`[src]

Concatenate, or join, two sequences.

### `impl<T, N> Deref for GenericArray<T, N> where
N: ArrayLength<T>,` [src]

#### `type Target = [T]`

The resulting type after dereferencing.

#### `fn deref(&self) -> &[T]`[src]

Dereferences the value.

### `impl<T: Copy, N> Copy for GenericArray<T, N> where
N: ArrayLength<T>,
N::ArrayType: Copy,` [src]

### `impl<T: Debug, N> Debug for GenericArray<T, N> where
N: ArrayLength<T>,` [src]

#### `fn fmt(&self, fmt: &mut Formatter) -> Result`[src]

Formats the value using the given formatter. Read more

### `impl<T: PartialEq, N> PartialEq<GenericArray<T, N>> for GenericArray<T, N> where
N: ArrayLength<T>,` [src]

#### `fn eq(&self, other: &Self) -> bool`[src]

This method tests for `self` and `other` values to be equal, and is used by `==`. Read more

#### `
#[must_use]
fn ne(&self, other: &Rhs) -> bool` 1.0.0[src]

This method tests for `!=`.

### `impl<T: Eq, N> Eq for GenericArray<T, N> where
N: ArrayLength<T>,` [src]

### `impl<T: Ord, N> Ord for GenericArray<T, N> where
N: ArrayLength<T>,` [src]

#### `fn cmp(&self, other: &GenericArray<T, N>) -> Ordering`[src]

This method returns an `Ordering` between `self` and `other`. Read more

#### `fn max(self, other: Self) -> Self` 1.21.0[src]

Compares and returns the maximum of two values. Read more

#### `fn min(self, other: Self) -> Self` 1.21.0[src]

Compares and returns the minimum of two values. Read more

#### `fn clamp(self, min: Self, max: Self) -> Self`[src]

🔬 This is a nightly-only experimental API. (`clamp`)

Restrict a value to a certain interval. Read more

### `impl<T: PartialOrd, N> PartialOrd<GenericArray<T, N>> for GenericArray<T, N> where
N: ArrayLength<T>,` [src]

#### `fn partial_cmp(&self, other: &GenericArray<T, N>) -> Option<Ordering>`[src]

This method returns an ordering between `self` and `other` values if one exists. Read more

#### `
#[must_use]
fn lt(&self, other: &Rhs) -> bool` 1.0.0[src]

This method tests less than (for `self` and `other`) and is used by the `<` operator. Read more

#### `
#[must_use]
fn le(&self, other: &Rhs) -> bool` 1.0.0[src]

This method tests less than or equal to (for `self` and `other`) and is used by the `<=` operator. Read more

#### `
#[must_use]
fn gt(&self, other: &Rhs) -> bool` 1.0.0[src]

This method tests greater than (for `self` and `other`) and is used by the `>` operator. Read more

#### `
#[must_use]
fn ge(&self, other: &Rhs) -> bool` 1.0.0[src]

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

### `impl<T> From<[T; 1]> for GenericArray<T, U1>`[src]

#### `fn from(arr: [T; 1]) -> Self`[src]

Performs the conversion.

### `impl<T> From<[T; 2]> for GenericArray<T, U2>`[src]

#### `fn from(arr: [T; 2]) -> Self`[src]

Performs the conversion.

### `impl<T> From<[T; 3]> for GenericArray<T, U3>`[src]

#### `fn from(arr: [T; 3]) -> Self`[src]

Performs the conversion.

### `impl<T> From<[T; 4]> for GenericArray<T, U4>`[src]

#### `fn from(arr: [T; 4]) -> Self`[src]

Performs the conversion.

### `impl<T> From<[T; 5]> for GenericArray<T, U5>`[src]

#### `fn from(arr: [T; 5]) -> Self`[src]

Performs the conversion.

### `impl<T> From<[T; 6]> for GenericArray<T, U6>`[src]

#### `fn from(arr: [T; 6]) -> Self`[src]

Performs the conversion.

### `impl<T> From<[T; 7]> for GenericArray<T, U7>`[src]

#### `fn from(arr: [T; 7]) -> Self`[src]

Performs the conversion.

### `impl<T> From<[T; 8]> for GenericArray<T, U8>`[src]

#### `fn from(arr: [T; 8]) -> Self`[src]

Performs the conversion.

### `impl<T> From<[T; 9]> for GenericArray<T, U9>`[src]

#### `fn from(arr: [T; 9]) -> Self`[src]

Performs the conversion.

### `impl<T> From<[T; 10]> for GenericArray<T, U10>`[src]

#### `fn from(arr: [T; 10]) -> Self`[src]

Performs the conversion.

### `impl<T> From<[T; 11]> for GenericArray<T, U11>`[src]

#### `fn from(arr: [T; 11]) -> Self`[src]

Performs the conversion.

### `impl<T> From<[T; 12]> for GenericArray<T, U12>`[src]

#### `fn from(arr: [T; 12]) -> Self`[src]

Performs the conversion.

### `impl<T> From<[T; 13]> for GenericArray<T, U13>`[src]

#### `fn from(arr: [T; 13]) -> Self`[src]

Performs the conversion.

### `impl<T> From<[T; 14]> for GenericArray<T, U14>`[src]

#### `fn from(arr: [T; 14]) -> Self`[src]

Performs the conversion.

### `impl<T> From<[T; 15]> for GenericArray<T, U15>`[src]

#### `fn from(arr: [T; 15]) -> Self`[src]

Performs the conversion.

### `impl<T> From<[T; 16]> for GenericArray<T, U16>`[src]

#### `fn from(arr: [T; 16]) -> Self`[src]

Performs the conversion.

### `impl<T> From<[T; 17]> for GenericArray<T, U17>`[src]

#### `fn from(arr: [T; 17]) -> Self`[src]

Performs the conversion.

### `impl<T> From<[T; 18]> for GenericArray<T, U18>`[src]

#### `fn from(arr: [T; 18]) -> Self`[src]

Performs the conversion.

### `impl<T> From<[T; 19]> for GenericArray<T, U19>`[src]

#### `fn from(arr: [T; 19]) -> Self`[src]

Performs the conversion.

### `impl<T> From<[T; 20]> for GenericArray<T, U20>`[src]

#### `fn from(arr: [T; 20]) -> Self`[src]

Performs the conversion.

### `impl<T> From<[T; 21]> for GenericArray<T, U21>`[src]

#### `fn from(arr: [T; 21]) -> Self`[src]

Performs the conversion.

### `impl<T> From<[T; 22]> for GenericArray<T, U22>`[src]

#### `fn from(arr: [T; 22]) -> Self`[src]

Performs the conversion.

### `impl<T> From<[T; 23]> for GenericArray<T, U23>`[src]

#### `fn from(arr: [T; 23]) -> Self`[src]

Performs the conversion.

### `impl<T> From<[T; 24]> for GenericArray<T, U24>`[src]

#### `fn from(arr: [T; 24]) -> Self`[src]

Performs the conversion.

### `impl<T> From<[T; 25]> for GenericArray<T, U25>`[src]

#### `fn from(arr: [T; 25]) -> Self`[src]

Performs the conversion.

### `impl<T> From<[T; 26]> for GenericArray<T, U26>`[src]

#### `fn from(arr: [T; 26]) -> Self`[src]

Performs the conversion.

### `impl<T> From<[T; 27]> for GenericArray<T, U27>`[src]

#### `fn from(arr: [T; 27]) -> Self`[src]

Performs the conversion.

### `impl<T> From<[T; 28]> for GenericArray<T, U28>`[src]

#### `fn from(arr: [T; 28]) -> Self`[src]

Performs the conversion.

### `impl<T> From<[T; 29]> for GenericArray<T, U29>`[src]

#### `fn from(arr: [T; 29]) -> Self`[src]

Performs the conversion.

### `impl<T> From<[T; 30]> for GenericArray<T, U30>`[src]

#### `fn from(arr: [T; 30]) -> Self`[src]

Performs the conversion.

### `impl<T> From<[T; 31]> for GenericArray<T, U31>`[src]

#### `fn from(arr: [T; 31]) -> Self`[src]

Performs the conversion.

### `impl<T> From<[T; 32]> for GenericArray<T, U32>`[src]

#### `fn from(arr: [T; 32]) -> Self`[src]

Performs the conversion.

### `impl<'a, T, N: ArrayLength<T>> From<&'a [T]> for &'a GenericArray<T, N>`[src]

#### `fn from(slice: &[T]) -> &GenericArray<T, N>`[src]

Converts slice to a generic array reference with inferred length;

Length of the slice must be equal to the length of the array.

### `impl<'a, T, N: ArrayLength<T>> From<&'a mut [T]> for &'a mut GenericArray<T, N>`[src]

#### `fn from(slice: &mut [T]) -> &mut GenericArray<T, N>`[src]

Converts mutable slice to a mutable generic array reference

Length of the slice must be equal to the length of the array.

### `impl<T: Hash, N> Hash for GenericArray<T, N> where
N: ArrayLength<T>,` [src]

#### `fn hash<H>(&self, state: &mut H) where
H: Hasher,` [src]

Feeds this value into the given [`Hasher`]. Read more

#### `fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,` 1.3.0[src]

Feeds a slice of this type into the given [`Hasher`]. Read more

### `impl<T: Send, N: ArrayLength<T>> Send for GenericArray<T, N>`[src]

### `impl<T: Sync, N: ArrayLength<T>> Sync for GenericArray<T, N>`[src]

### `impl<T, N> DerefMut for GenericArray<T, N> where
N: ArrayLength<T>,` [src]

#### `fn deref_mut(&mut self) -> &mut [T]`[src]

Mutably dereferences the value.

### `impl<T, N> FromIterator<T> for GenericArray<T, N> where
N: ArrayLength<T>,` [src]

#### `fn from_iter<I>(iter: I) -> GenericArray<T, N> where
I: IntoIterator<Item = T>,` [src]

Creates a value from an iterator. Read more

### `impl<T, N> IntoIterator for GenericArray<T, N> where
N: ArrayLength<T>,` [src]

#### `type Item = T`

The type of the elements being iterated over.

#### `type IntoIter = GenericArrayIter<T, N>`

Which kind of iterator are we turning this into?

#### `fn into_iter(self) -> Self::IntoIter`[src]

Creates an iterator from a value. Read more

### `impl<'a, T: 'a, N> IntoIterator for &'a GenericArray<T, N> where
N: ArrayLength<T>,` [src]

#### `type IntoIter = Iter<'a, T>`

Which kind of iterator are we turning this into?

#### `type Item = &'a T`

The type of the elements being iterated over.

#### `fn into_iter(self: &'a GenericArray<T, N>) -> Self::IntoIter`[src]

Creates an iterator from a value. Read more

### `impl<'a, T: 'a, N> IntoIterator for &'a mut GenericArray<T, N> where
N: ArrayLength<T>,` [src]

#### `type IntoIter = IterMut<'a, T>`

Which kind of iterator are we turning this into?

#### `type Item = &'a mut T`

The type of the elements being iterated over.

#### `fn into_iter(self: &'a mut GenericArray<T, N>) -> Self::IntoIter`[src]

Creates an iterator from a value. Read more

### `impl<T, N> AsRef<[T]> for GenericArray<T, N> where
N: ArrayLength<T>,` [src]

#### `fn as_ref(&self) -> &[T]`[src]

Performs the conversion.

### `impl<T, N> AsMut<[T]> for GenericArray<T, N> where
N: ArrayLength<T>,` [src]

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

Performs the conversion.

### `impl<T: ArrayLength<u8>> LowerHex for GenericArray<u8, T> where
T: Add<T>,
<T as Add<T>>::Output: ArrayLength<u8>,` [src]

#### `fn fmt(&self, f: &mut Formatter) -> Result`[src]

Formats the value using the given formatter.

### `impl<T: ArrayLength<u8>> UpperHex for GenericArray<u8, T> where
T: Add<T>,
<T as Add<T>>::Output: ArrayLength<u8>,` [src]

#### `fn fmt(&self, f: &mut Formatter) -> Result`[src]

Formats the value using the given formatter.

### `impl<T: Clone, N> Clone for GenericArray<T, N> where
N: ArrayLength<T>,` [src]

#### `fn clone(&self) -> GenericArray<T, N>`[src]

Returns a copy of the value. Read more

#### `fn clone_from(&mut self, source: &Self)`1.0.0[src]

Performs copy-assignment from `source`. Read more

### `impl<T: Default, N> Default for GenericArray<T, N> where
N: ArrayLength<T>,` [src]

#### `fn default() -> Self`[src]

Returns the "default value" for a type. Read more

### `impl<T, N> Borrow<[T]> for GenericArray<T, N> where
N: ArrayLength<T>,` [src]

#### `fn borrow(&self) -> &[T]`[src]

Immutably borrows from an owned value. Read more

### `impl<T, N> BorrowMut<[T]> for GenericArray<T, N> where
N: ArrayLength<T>,` [src]

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

Mutably borrows from an owned value. Read more

## Blanket Implementations

### `impl<T, U> TryFrom<U> for T where
U: Into<T>,` [src]

#### `type Error = Infallible`

The type returned in the event of a conversion error.

#### `fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>`[src]

Performs the conversion.

### `impl<T> From<T> for T`[src]

#### `fn from(t: T) -> T`[src]

Performs the conversion.

### `impl<I> IntoIterator for I where
I: Iterator,` [src]

#### `type Item = <I as Iterator>::Item`

The type of the elements being iterated over.

#### `type IntoIter = I`

Which kind of iterator are we turning this into?

#### `fn into_iter(self) -> I`[src]

Creates an iterator from a value. Read more

### `impl<T, U> Into<U> for T where
U: From<T>,` [src]

#### `fn into(self) -> U`[src]

Performs the conversion.

### `impl<T, U> TryInto<U> for T where
U: TryFrom<T>,` [src]

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

The type returned in the event of a conversion error.

#### `fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>`[src]

Performs the conversion.

### `impl<T> Borrow<T> for T where
T: ?Sized,` [src]

#### `fn borrow(&self) -> &T`[src]

Immutably borrows from an owned value. Read more

### `impl<T> BorrowMut<T> for T where
T: ?Sized,` [src]

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

Mutably borrows from an owned value. Read more

### `impl<T> Any for T where
T: 'static + ?Sized,` [src]

#### `fn type_id(&self) -> TypeId`[src]

Gets the `TypeId` of `self`. Read more

### `impl<T> Same<T> for T`[src]

#### `type Output = T`

Should always be `Self`

# Help

## Keyboard Shortcuts

`?`
  Show this help dialog
`S`
  Focus the search field
`↑`
  Move up in search results
`↓`
  Move down in search results
`↹`
  Switch tab
`⏎`
  Go to active search result
`+`
  Expand all sections
`-`
  Collapse all sections

## Search Tricks

Prefix searches with a type followed by a colon (e.g., `fn:`) to restrict the search to a given type.

Accepted types are: `fn`, `mod`, `struct`, `enum`, `trait`, `type`, `macro`, and `const`.

Search functions by type signature (e.g., `vec -> usize` or `* -> vec`)

Search multiple things at once by splitting your query with comma (e.g., `str,u8` or `String,struct:Vec,test`)