about summary refs log tree commit diff
path: root/compiler/rustc_index
diff options
context:
space:
mode:
authorJason Newcomb <jsnewcomb@pm.me>2025-03-02 02:23:14 -0500
committerJason Newcomb <jsnewcomb@pm.me>2025-04-15 10:44:28 -0400
commit52694034ba0e3261fb53c97ca4da7743db4945e7 (patch)
tree3fe8102fa1ed52a52eb8d5cc9a30aaaba09949bf /compiler/rustc_index
parent40dacd50b7074783db748d73925ac5c3693a7ec1 (diff)
downloadrust-52694034ba0e3261fb53c97ca4da7743db4945e7.tar.gz
rust-52694034ba0e3261fb53c97ca4da7743db4945e7.zip
Add `copy_within` to `IndexSlice`
Diffstat (limited to 'compiler/rustc_index')
-rw-r--r--compiler/rustc_index/src/slice.rs13
1 files changed, 12 insertions, 1 deletions
diff --git a/compiler/rustc_index/src/slice.rs b/compiler/rustc_index/src/slice.rs
index 67ac805c2bf..d2702bdb057 100644
--- a/compiler/rustc_index/src/slice.rs
+++ b/compiler/rustc_index/src/slice.rs
@@ -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};
 
@@ -105,6 +105,17 @@ impl<I: Idx, T> IndexSlice<I, T> {
     }
 
     #[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,
         index: R,