Skip to content

Commit 708f0f3

Browse files
committed
Add as_mut_inner method
1 parent 10f783e commit 708f0f3

2 files changed

Lines changed: 32 additions & 0 deletions

File tree

src/arrayvec.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1257,6 +1257,16 @@ impl<A> ArrayVec<A> {
12571257
pub const fn as_inner(&self) -> &A {
12581258
&self.data
12591259
}
1260+
1261+
/// Returns a mutable reference to the inner array of the `ArrayVec`.
1262+
///
1263+
/// This returns the full array, even if the `ArrayVec` length is currently
1264+
/// less than that.
1265+
#[inline(always)]
1266+
#[must_use]
1267+
pub fn as_mut_inner(&mut self) -> &mut A {
1268+
&mut self.data
1269+
}
12601270
}
12611271

12621272
/// Splicing iterator for `ArrayVec`

src/slicevec.rs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -634,6 +634,28 @@ impl<'s, T> SliceVec<'s, T> {
634634
}
635635
}
636636

637+
impl<'s, T> SliceVec<'s, T> {
638+
/// Returns the reference to the inner slice of the `SliceVec`.
639+
///
640+
/// This returns the full array, even if the `SliceVec` length is currently
641+
/// less than that.
642+
#[inline(always)]
643+
#[must_use]
644+
pub const fn as_inner(&self) -> &[T] {
645+
&*self.data
646+
}
647+
648+
/// Returns a mutable reference to the inner slice of the `SliceVec`.
649+
///
650+
/// This returns the full array, even if the `SliceVec` length is currently
651+
/// less than that.
652+
#[inline(always)]
653+
#[must_use]
654+
pub fn as_mut_inner(&mut self) -> &mut [T] {
655+
self.data
656+
}
657+
}
658+
637659
#[cfg(feature = "grab_spare_slice")]
638660
impl<'s, T> SliceVec<'s, T> {
639661
/// Obtain the shared slice of the array _after_ the active memory.

0 commit comments

Comments
 (0)