Skip to content

Commit 5269403

Browse files
committed
Add copy_within to IndexSlice
1 parent 40dacd5 commit 5269403

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

compiler/rustc_index/src/slice.rs

+12-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use std::fmt;
22
use std::marker::PhantomData;
3-
use std::ops::{Index, IndexMut};
3+
use std::ops::{Index, IndexMut, RangeBounds};
44
use std::slice::GetDisjointMutError::*;
55
use std::slice::{self, SliceIndex};
66

@@ -104,6 +104,17 @@ impl<I: Idx, T> IndexSlice<I, T> {
104104
self.raw.swap(a.index(), b.index())
105105
}
106106

107+
#[inline]
108+
pub fn copy_within(
109+
&mut self,
110+
src: impl IntoSliceIdx<I, [T], Output: RangeBounds<usize>>,
111+
dest: I,
112+
) where
113+
T: Copy,
114+
{
115+
self.raw.copy_within(src.into_slice_idx(), dest.index());
116+
}
117+
107118
#[inline]
108119
pub fn get<R: IntoSliceIdx<I, [T]>>(
109120
&self,

0 commit comments

Comments
 (0)