Skip to content

Commit

Permalink
Add associated len method
Browse files Browse the repository at this point in the history
  • Loading branch information
novacrazy committed Sep 6, 2023
1 parent fb7f25c commit 37dc6ae
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -667,6 +667,15 @@ where
}

impl<T, N: ArrayLength> GenericArray<T, N> {
/// Returns the number of elements in the array.
///
/// Equivalent to [`<N as Unsigned>::USIZE`](typenum::Unsigned) where `N` is the array length.
///
/// Useful for when only a type alias is available.
pub const fn len() -> usize {
N::USIZE
}

/// Extracts a slice containing the entire array.
#[inline(always)]
pub const fn as_slice(&self) -> &[T] {
Expand Down

0 comments on commit 37dc6ae

Please sign in to comment.