Rollup merge of #137881 - Jarcho:index_slice_ex, r=wesleywiser

Add `copy_within` to `IndexSlice`
This commit is contained in:
Matthias Krüger 2025-04-18 05:17:50 +02:00 committed by GitHub
commit 484abe9f77
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1,6 +1,6 @@
use std::fmt;
use std::marker::PhantomData;
use std::ops::{Index, IndexMut};
use std::ops::{Index, IndexMut, RangeBounds};
use std::slice::GetDisjointMutError::*;
use std::slice::{self, SliceIndex};
@ -104,6 +104,17 @@ impl<I: Idx, T> IndexSlice<I, T> {
self.raw.swap(a.index(), b.index())
}
#[inline]
pub fn copy_within(
&mut self,
src: impl IntoSliceIdx<I, [T], Output: RangeBounds<usize>>,
dest: I,
) where
T: Copy,
{
self.raw.copy_within(src.into_slice_idx(), dest.index());
}
#[inline]
pub fn get<R: IntoSliceIdx<I, [T]>>(
&self,