Skip to content

Commit fdc8638

Browse files
committed
Add copy_within to IndexSlice
1 parent 1c3b035 commit fdc8638

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::{self, SliceIndex};
55

66
use crate::{Idx, IndexVec, IntoSliceIdx};
@@ -97,6 +97,17 @@ impl<I: Idx, T> IndexSlice<I, T> {
9797
self.raw.swap(a.index(), b.index())
9898
}
9999

100+
#[inline]
101+
pub fn copy_within(
102+
&mut self,
103+
src: impl IntoSliceIdx<I, [T], Output: RangeBounds<usize>>,
104+
dest: I,
105+
) where
106+
T: Copy,
107+
{
108+
self.raw.copy_within(src.into_slice_idx(), dest.index());
109+
}
110+
100111
#[inline]
101112
pub fn get<R: IntoSliceIdx<I, [T]>>(
102113
&self,

0 commit comments

Comments
 (0)