Debian Codegraph @

src/set/slice.rs

raw symbols ◀ ▶ SCIP
1 Debian patch touch this file
1 use superrust-analyzer cargo ordermap 1.2.0 set/::OrderSetrust-analyzer cargo ordermap 1.2.0 set/OrderSet#;
2 use corerust-analyzer cargo core https://github.com/rust-lang/rust/library/core crate/::opsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/::{selfrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/, Boundrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Bound#, Indexrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#};
3 use indexmaprust-analyzer cargo indexmap 2.14.0 crate/::setrust-analyzer cargo indexmap 2.14.0 set/::Slicerust-analyzer cargo indexmap 2.14.0 set/slice/Slice#;
4
5 // We can't have `impl<I: RangeBounds<usize>> Index<I>` because that conflicts with `Index<usize>`.
6 // Instead, we repeat the implementations for all the core range types.
7 macro_rules! impl_indexrust-analyzer cargo ordermap 1.2.0 set/slice/impl_index! {
8 ($($range:ty),*) => {$(
9 impl<T, S> Index<$range> for OrderSet<T, S> {
10 type Output = Slice<T>;
11
12 fn index(&self, range: $range) -> &Self::Output {
13 &self.inner[range]
14 }
15 }
16 )*}
17 }
18 impl_indexrust-analyzer cargo ordermap 1.2.0 set/slice/impl_index!!(
19 opsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/::Rangerust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#<usize>,
20 opsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/::RangeFromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeFrom#<usize>,
21 opsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/::RangeFullrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeFull#,
22 opsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/::RangeInclusiverust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeInclusive#<usize>,
23 opsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/::RangeTorust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeTo#<usize>,
24 opsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/::RangeToInclusiverust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeToInclusive#<usize>,
25 (Boundrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Bound#<usize>, Boundrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Bound#<usize>)
26 );
27
•28 #[cfg(all(test, feature = "std"))]
29 mod testsrust-analyzer cargo ordermap 1.2.0 set/slice/tests/ {
30 use superrust-analyzer cargo ordermap 1.2.0 set/slice/::*;
31 use allocrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc crate/::vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/::Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#;
32
33 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
34 fn slice_indexrust-analyzer cargo ordermap 1.2.0 set/slice/tests/slice_index().() {
35 fn checkrust-analyzer cargo ordermap 1.2.0 set/slice/tests/check().(vec_slice: &[i32], set_slice: &Slicerust-analyzer cargo indexmap 2.14.0 set/slice/Slice#<i32>, sub_slice: &Slicerust-analyzer cargo indexmap 2.14.0 set/slice/Slice#<i32>) {
36 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(set_slice as *const _, sub_slice as *const _);
37 itertoolsrust-analyzer cargo itertools 0.14.0 crate/::assert_equalrust-analyzer cargo itertools 0.14.0 assert_equal().(vec_slice, set_slice);
38 }
39
40 let vec: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<i32> = (0..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#10).maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#map().(|i| i rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Mul<Self>`]mul().i).collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().();
41 let set: OrderSetrust-analyzer cargo ordermap 1.2.0 set/OrderSet#<i32> = vec.iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().().clonedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#cloned().().collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().();
42 let slice = set.as_slicerust-analyzer cargo ordermap 1.2.0 set/impl#[`OrderSet<T, S>`]as_slice().();
43
44 // RangeFull
45 checkrust-analyzer cargo ordermap 1.2.0 set/slice/tests/check().(&vec[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index()...rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeFull#]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index()., &set[rust-analyzer cargo ordermap 1.2.0 set/slice/impl#[`OrderSet<T, S>`][`Index<ops::RangeFull>`]index()...rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeFull#]rust-analyzer cargo ordermap 1.2.0 set/slice/impl#[`OrderSet<T, S>`][`Index<ops::RangeFull>`]index()., &slice[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()...rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeFull#]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().);
46
47 for i in 0usize..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#10 {
48 // Index
49 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(vec[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().i]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index()., set[rust-analyzer cargo ordermap 1.2.0 set/impl#[`OrderSet<T, S>`][`Index<usize>`]index().i]rust-analyzer cargo ordermap 1.2.0 set/impl#[`OrderSet<T, S>`][`Index<usize>`]index().);
50 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(vec[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().i]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index()., slice[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().i]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().);
51
52 // RangeFrom
53 checkrust-analyzer cargo ordermap 1.2.0 set/slice/tests/check().(&vec[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().i..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeFrom#]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index()., &set[rust-analyzer cargo ordermap 1.2.0 set/slice/impl#[`OrderSet<T, S>`][`Index<ops::RangeFrom<usize>>`]index().i..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeFrom#]rust-analyzer cargo ordermap 1.2.0 set/slice/impl#[`OrderSet<T, S>`][`Index<ops::RangeFrom<usize>>`]index()., &slice[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().i..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeFrom#]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().);
54
55 // RangeTo
56 checkrust-analyzer cargo ordermap 1.2.0 set/slice/tests/check().(&vec[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index()...rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeTo#i]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index()., &set[rust-analyzer cargo ordermap 1.2.0 set/slice/impl#[`OrderSet<T, S>`][`Index<ops::RangeTo<usize>>`]index()...rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeTo#i]rust-analyzer cargo ordermap 1.2.0 set/slice/impl#[`OrderSet<T, S>`][`Index<ops::RangeTo<usize>>`]index()., &slice[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()...rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeTo#i]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().);
57
58 // RangeToInclusive
59 checkrust-analyzer cargo ordermap 1.2.0 set/slice/tests/check().(&vec[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index()...=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeToInclusive#i]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index()., &set[rust-analyzer cargo ordermap 1.2.0 set/slice/impl#[`OrderSet<T, S>`][`Index<ops::RangeToInclusive<usize>>`]index()...=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeToInclusive#i]rust-analyzer cargo ordermap 1.2.0 set/slice/impl#[`OrderSet<T, S>`][`Index<ops::RangeToInclusive<usize>>`]index()., &slice[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()...=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeToInclusive#i]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().);
60
61 // (Bound<usize>, Bound<usize>)
62 let bounds = (Boundrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Bound#::Excludedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Bound#Excluded#(i), Boundrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Bound#::Unboundedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Bound#Unbounded#);
63 checkrust-analyzer cargo ordermap 1.2.0 set/slice/tests/check().(&vec[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().i rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().1..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeFrom#]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index()., &set[rust-analyzer cargo ordermap 1.2.0 set/slice/impl#[`OrderSet<T, S>`][`Index<(Bound<usize>, Bound<usize>)>`]index().bounds]rust-analyzer cargo ordermap 1.2.0 set/slice/impl#[`OrderSet<T, S>`][`Index<(Bound<usize>, Bound<usize>)>`]index()., &slice[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().bounds]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().);
64
65 for j in i..=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeInclusive#10 {
66 // Range
67 checkrust-analyzer cargo ordermap 1.2.0 set/slice/tests/check().(&vec[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().i..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#j]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index()., &set[rust-analyzer cargo ordermap 1.2.0 set/slice/impl#[`OrderSet<T, S>`][`Index<ops::Range<usize>>`]index().i..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#j]rust-analyzer cargo ordermap 1.2.0 set/slice/impl#[`OrderSet<T, S>`][`Index<ops::Range<usize>>`]index()., &slice[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().i..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#j]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().);
68 }
69
70 for j in i..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#10 {
71 // RangeInclusive
72 checkrust-analyzer cargo ordermap 1.2.0 set/slice/tests/check().(&vec[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().i..=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeInclusive#j]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index()., &set[rust-analyzer cargo ordermap 1.2.0 set/slice/impl#[`OrderSet<T, S>`][`Index<ops::RangeInclusive<usize>>`]index().i..=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeInclusive#j]rust-analyzer cargo ordermap 1.2.0 set/slice/impl#[`OrderSet<T, S>`][`Index<ops::RangeInclusive<usize>>`]index()., &slice[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().i..=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeInclusive#j]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().);
73 }
74 }
75 }
76 }