Skip to content

Commit

Permalink
Add ArrayVec::as_inner() (#197)
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?

This lives in its own `impl<A> ArrayVec<A>` block
because rust 1.47.0 is unhappy about having a
const function inside `impl<A: Array>
ArrayVec<A>`. We don't need the trait anyway.

Fixes #193.
  • Loading branch information
Fuuzetsu committed Jul 8, 2024
1 parent ed22e15 commit 1838a18
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/arrayvec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1183,6 +1183,18 @@ impl<A: Array> ArrayVec<A> {
}
}

impl<A> ArrayVec<A> {
/// 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
}
}

/// Splicing iterator for `ArrayVec`
/// See [`ArrayVec::splice`](ArrayVec::<A>::splice)
pub struct ArrayVecSplice<'p, A: Array, I: Iterator<Item = A::Item>> {
Expand Down

0 comments on commit 1838a18

Please sign in to comment.