about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMatthias Krüger <476013+matthiaskrgr@users.noreply.github.com>2025-04-18 05:17:50 +0200
committerGitHub <noreply@github.com>2025-04-18 05:17:50 +0200
commit484abe9f77162deaea61b20c285320934af8799b (patch)
tree80168b4c8a6a4b1c729c277713eab0bf55d9d7ad
parent1f76d219c906f0112bb1872f33aa977164c53fa6 (diff)
parent52694034ba0e3261fb53c97ca4da7743db4945e7 (diff)
downloadrust-484abe9f77162deaea61b20c285320934af8799b.tar.gz
rust-484abe9f77162deaea61b20c285320934af8799b.zip
Rollup merge of #137881 - Jarcho:index_slice_ex, r=wesleywiser
Add `copy_within` to `IndexSlice`
-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,