aboutsummaryrefslogtreecommitdiff
path: root/crates/test_utils/src
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2021-06-18 20:37:03 +0100
committerAleksey Kladov <[email protected]>2021-06-18 20:37:34 +0100
commit991919e71f048f9321e702512248e11c6c5fef70 (patch)
treef7f01b88e18e7d10b79df4ca27090bd058e1a40e /crates/test_utils/src
parent73b3ee664ecc938b943b5a08a23ef29104fc390f (diff)
internal: add index to minicore
Diffstat (limited to 'crates/test_utils/src')
-rw-r--r--crates/test_utils/src/minicore.rs43
1 files changed, 43 insertions, 0 deletions
diff --git a/crates/test_utils/src/minicore.rs b/crates/test_utils/src/minicore.rs
index 769028580..71f07d38a 100644
--- a/crates/test_utils/src/minicore.rs
+++ b/crates/test_utils/src/minicore.rs
@@ -15,6 +15,7 @@
15//! range: 15//! range:
16//! deref: sized 16//! deref: sized
17//! deref_mut: deref 17//! deref_mut: deref
18//! index: sized
18//! fn: 19//! fn:
19//! pin: 20//! pin:
20//! future: pin 21//! future: pin
@@ -167,6 +168,48 @@ pub mod ops {
167 }; 168 };
168 // endregion:deref 169 // endregion:deref
169 170
171 // region:index
172 mod index {
173 #[lang = "index"]
174 pub trait Index<Idx: ?Sized> {
175 type Output: ?Sized;
176 fn index(&self, index: Idx) -> &Self::Output;
177 }
178 #[lang = "index_mut"]
179 pub trait IndexMut<Idx: ?Sized>: Index<Idx> {
180 fn index_mut(&mut self, index: Idx) -> &mut Self::Output;
181 }
182
183 // region:slice
184 impl<T, I> Index<I> for [T]
185 where
186 I: SliceIndex<[T]>,
187 {
188 type Output = I::Output;
189 fn index(&self, index: I) -> &I::Output {
190 loop {}
191 }
192 }
193 impl<T, I> IndexMut<I> for [T]
194 where
195 I: SliceIndex<[T]>,
196 {
197 fn index_mut(&mut self, index: I) -> &mut I::Output {
198 loop {}
199 }
200 }
201
202 pub unsafe trait SliceIndex<T: ?Sized> {
203 type Output: ?Sized;
204 }
205 unsafe impl<T> SliceIndex<[T]> for usize {
206 type Output = T;
207 }
208 // endregion:slice
209 }
210 pub use self::index::{Index, IndexMut};
211 // endregion:index
212
170 // region:range 213 // region:range
171 mod range { 214 mod range {
172 #[lang = "RangeFull"] 215 #[lang = "RangeFull"]