Skip to content

Commit

Permalink
Add ArrayVec::as_inner()
Browse files Browse the repository at this point in the history
Originally I was going to call this `as_array()`
but `as_inner()` is more consistent with the
existing `into_inner()` method. I don't
_ultimately_ care what it ends up being called.

I wonder if we should have a `impl
From<ArrayVec<T>> for A` implementation or is that
a bit too foot-gun-y?

Fixes #193.
  • Loading branch information
Fuuzetsu committed Jun 26, 2024
1 parent 612c87d commit 53a088e
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/arrayvec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,16 @@ impl<A: Array> ArrayVec<A> {
self.deref()
}

/// Returns the reference to the inner array of the `ArrayVec`.
///
/// This returns the full array, even if the `ArrayVec` length is currently
/// less than that.
#[inline(always)]
#[must_use]
pub const fn as_inner(&self) -> &A {
&self.data
}

/// The capacity of the `ArrayVec`.
///
/// This is fixed based on the array type, but can't yet be made a `const fn`
Expand Down

0 comments on commit 53a088e

Please sign in to comment.