Lines Matching refs:index
2686 // no-op on the last index
3831 assert_eq!(&s[$range], expected, "(in assertion for: index)");
3883 // Generates test cases for bad index operations.
4151 "byte index 4 is not a char boundary; it is inside 'α' (bytes 3..5) of";
4158 "byte index 6 is not a char boundary; it is inside 'β' (bytes 5..7) of";
4165 "byte index 4 is not a char boundary; it is inside 'α' (bytes 3..5) of";
4172 "byte index 6 is not a char boundary; it is inside 'β' (bytes 5..7) of";
4179 "byte index 4 is not a char boundary; it is inside 'α' (bytes 3..5) of";
4186 "byte index 6 is not a char boundary; it is inside 'β' (bytes 5..7) of";
4193 "byte index 6 is not a char boundary; it is inside 'β' (bytes 5..7) of";
4208 #[should_panic(expected = "byte index 1024 is out of bounds of `Lorem ipsum dolor sit amet")]
4502 for (index, _) in s.char_indices() {
4503 let (a, b) = s.split_at(index);
7846 index: usize,
7852 self.drop_counts.lock().unwrap()[self.index] += 1;
7853 println!("drop: {}", self.index);
7860 .map(|index| Check { index, drop_counts: Rc::clone(&drop_counts) })
7865 if c.index == 2 {
7866 panic!("panic at index: {}", c.index);
7871 if c.index == 4 {
7872 panic!("panic at index: {}", c.index);
7874 c.index < 6
7885 for (index, count) in drop_counts.iter().cloned().enumerate() {
7886 assert_eq!(1, count, "unexpected drop count at index: {} (count: {})", index, count);
7898 index: usize,
7904 self.drop_counts.lock().unwrap()[self.index] += 1;
7905 println!("drop: {}", self.index);
7912 .map(|index| Check { index, drop_counts: Rc::clone(&drop_counts) })
7917 if c.index == 2 {
7918 panic!("panic at index: {}", c.index);
7923 if c.index == 4 {
7924 panic!("panic at index: {}", c.index);
7926 c.index < 6
7936 for (index, count) in drop_counts.iter().cloned().enumerate() {
7937 assert_eq!(1, count, "unexpected drop count at index: {} (count: {})", index, count);
8758 index: usize,
8776 Panic { drop_counter: &DROP_COUNTER, value: false, index: 0 },
8777 Panic { drop_counter: &DROP_COUNTER, value: false, index: 5 },
8778 Panic { drop_counter: &DROP_COUNTER, value: true, index: 6 },
8779 Panic { drop_counter: &DROP_COUNTER, value: true, index: 7 },
8782 Panic { drop_counter: &DROP_COUNTER, value: false, index: 0 },
8784 Panic { drop_counter: &DROP_COUNTER, value: false, index: 1 },
8785 Panic { drop_counter: &DROP_COUNTER, value: false, index: 2 },
8786 Panic { drop_counter: &DROP_COUNTER, value: false, index: 3 },
8787 Panic { drop_counter: &DROP_COUNTER, value: false, index: 4 },
8789 Panic { drop_counter: &DROP_COUNTER, value: false, index: 5 },
8790 Panic { drop_counter: &DROP_COUNTER, value: true, index: 6 },
8791 Panic { drop_counter: &DROP_COUNTER, value: true, index: 7 },
8798 let ok = vec.iter().zip(expected.iter()).all(|(x, y)| x.index == y.index);
13963 /// [`std::fmt`]: ../std/fmt/index.html
16281 /// you cannot index into a `String`:
16293 /// thing the index should return: a byte, a codepoint, or a grapheme cluster.
17448 /// The exact order may be useful for tracking external state, like an index.
17653 /// Splits the string into two at the given byte index.
18276 fn index(&self, index: ops::Range<usize>) -> &str {
18277 &self[..][index]
18285 fn index(&self, index: ops::RangeTo<usize>) -> &str {
18286 &self[..][index]
18294 fn index(&self, index: ops::RangeFrom<usize>) -> &str {
18295 &self[..][index]
18303 fn index(&self, _index: ops::RangeFull) -> &str {
18312 fn index(&self, index: ops::RangeInclusive<usize>) -> &str {
18313 Index::index(&**self, index)
18321 fn index(&self, index: ops::RangeToInclusive<usize>) -> &str {
18322 Index::index(&**self, index)
18329 fn index_mut(&mut self, index: ops::Range<usize>) -> &mut str {
18330 &mut self[..][index]
18336 fn index_mut(&mut self, index: ops::RangeTo<usize>) -> &mut str {
18337 &mut self[..][index]
18343 fn index_mut(&mut self, index: ops::RangeFrom<usize>) -> &mut str {
18344 &mut self[..][index]
18357 fn index_mut(&mut self, index: ops::RangeInclusive<usize>) -> &mut str {
18358 IndexMut::index_mut(&mut **self, index)
18364 fn index_mut(&mut self, index: ops::RangeToInclusive<usize>) -> &mut str {
18365 IndexMut::index_mut(&mut **self, index)
19306 //! since its contents are re-exported in the [`std` crate](../std/index.html).
19345 //! [standard collections library](../std/collections/index.html).
19349 //! The [`alloc`](alloc/index.html) module defines the low-level interface to the
19784 /// See the [module-level documentation](./index.html) for more details.
22377 let mut index = indices[i].1;
22378 while (index as usize) < i {
22379 index = indices[index as usize].1;
22381 indices[i].1 = index;
22382 $slice.swap(i, index as usize);
23101 // run starts at index 0, it will always demand a merge operation until the stack is fully
23441 /// [`std::sync`]: ../../std/sync/index.html
27470 Cursor { index: 0, current: self.head, list: self }
27479 CursorMut { index: 0, current: self.head, list: self }
27488 Cursor { index: self.len.checked_sub(1).unwrap_or(0), current: self.tail, list: self }
27497 CursorMut { index: self.len.checked_sub(1).unwrap_or(0), current: self.tail, list: self }
27777 /// Splits the list into two at the given index. Returns everything after the given index,
27778 /// including the index.
27805 assert!(at <= len, "Cannot split off at a nonexistent index");
27834 /// Removes the element at the given index and returns it.
27860 assert!(at < len, "Cannot remove at an index outside of the list bounds");
27862 // Below, we iterate towards the node at the given index, either from
28052 /// Cursors always rest between two elements in the list, and index in a logically circular way.
28059 index: usize,
28067 let Cursor { index, current, list } = *self;
28068 Cursor { index, current, list }
28075 f.debug_tuple("Cursor").field(&self.list).field(&self.index()).finish()
28086 /// Cursors always rest between two elements in the list, and index in a logically circular way.
28091 index: usize,
28099 f.debug_tuple("CursorMut").field(&self.list).field(&self.index()).finish()
28104 /// Returns the cursor position index within the `LinkedList`.
28109 pub fn index(&self) -> Option<usize> {
28111 Some(self.index)
28126 self.index = 0;
28131 self.index += 1;
28147 self.index = self.list.len().checked_sub(1).unwrap_or(0);
28152 self.index = self.index.checked_sub(1).unwrap_or_else(|| self.list.len());
28201 /// Returns the cursor position index within the `LinkedList`.
28206 pub fn index(&self) -> Option<usize> {
28208 Some(self.index)
28223 self.index = 0;
28228 self.index += 1;
28244 self.index = self.list.len().checked_sub(1).unwrap_or(0);
28249 self.index = self.index.checked_sub(1).unwrap_or_else(|| self.list.len());
28303 Cursor { list: self.list, current: self.current, index: self.index }
28324 // The "ghost" non-element's index has changed.
28325 self.index = self.list.len;
28343 self.index += 1;
28407 // The "ghost" non-element's index has changed.
28408 self.index = self.list.len;
28429 self.index += splice_len;
28441 let split_off_idx = if self.index == self.list.len { 0 } else { self.index + 1 };
28442 if self.index == self.list.len {
28443 // The "ghost" non-element's index has changed to 0.
28444 self.index = 0;
28457 let split_off_idx = self.index;
28458 self.index = 0;
29044 assert_eq!(cursor.index(), Some(0));
29049 assert_eq!(cursor.index(), None);
29055 assert_eq!(cursor.index(), Some(1));
29061 assert_eq!(cursor.index(), Some(5));
29066 assert_eq!(cursor.index(), None);
29072 assert_eq!(cursor.index(), Some(4));
29080 assert_eq!(cursor.index(), Some(0));
29085 assert_eq!(cursor.index(), None);
29091 assert_eq!(cursor.index(), Some(1));
29094 assert_eq!(cursor2.index(), Some(1));
29097 assert_eq!(cursor2.index(), Some(2));
29099 assert_eq!(cursor.index(), Some(1));
29107 assert_eq!(cursor.index(), Some(5));
29112 assert_eq!(cursor.index(), None);
29118 assert_eq!(cursor.index(), Some(4));
29121 assert_eq!(cursor2.index(), Some(4));
29124 assert_eq!(cursor2.index(), Some(3));
29126 assert_eq!(cursor.index(), Some(4));
29712 /// Returns either the KV index in the node at which the key (or an equivalent)
29713 /// exists, or the edge index where the key belongs, starting from a particular index.
29719 /// `start_index` must be a valid edge index for the node.
29738 /// Finds an edge index in the node delimiting the lower bound of a range.
29769 /// `start_index` must be a valid edge index for the node.
30601 /// [module-level documentation]: index.html#insert-and-complex-keys
31819 fn index(&self, key: &Q) -> &V {
32917 /// [module-level documentation]: index.html#insert-and-complex-keys
37975 /// This node's index into the parent node's `edges` array.
38365 /// `index` is in bounds of 0..CAPACITY
38366 unsafe fn key_area_mut<I, Output: ?Sized>(&mut self, index: I) -> &mut Output
38373 unsafe { self.as_leaf_mut().keys.as_mut_slice().get_unchecked_mut(index) }
38379 /// `index` is in bounds of 0..CAPACITY
38380 unsafe fn val_area_mut<I, Output: ?Sized>(&mut self, index: I) -> &mut Output
38387 unsafe { self.as_leaf_mut().vals.as_mut_slice().get_unchecked_mut(index) }
38395 /// `index` is in bounds of 0..CAPACITY + 1
38396 unsafe fn edge_area_mut<I, Output: ?Sized>(&mut self, index: I) -> &mut Output
38403 unsafe { self.as_internal_mut().edges.as_mut_slice().get_unchecked_mut(index) }
38435 /// Every item returned by `range` is a valid edge index for the node.
38735 /// Given an edge index where we want to insert into a node filled to capacity,
38736 /// computes a sensible KV index of a split point and where to perform the insertion.
38800 /// Fixes the parent pointer and index in the child node that this edge
40049 // Safety: The TrustedRandomAccess contract requires that callers only pass an index
40052 // multiple repeated reads of the same index would be safe and the
40557 /// Returns the index in the underlying buffer for a given logical element
40558 /// index.
40564 /// Returns the index in the underlying buffer for a given logical element
40565 /// index + addend.
40571 /// Returns the index in the underlying buffer for a given logical element
40572 /// index - subtrahend.
40840 /// Provides a reference to the element at the given index.
40842 /// Element at index 0 is the front of the queue.
40856 pub fn get(&self, index: usize) -> Option<&T> {
40857 if index < self.len() {
40858 let idx = self.wrap_add(self.tail, index);
40865 /// Provides a mutable reference to the element at the given index.
40867 /// Element at index 0 is the front of the queue.
40885 pub fn get_mut(&mut self, index: usize) -> Option<&mut T> {
40886 if index < self.len() {
40887 let idx = self.wrap_add(self.tail, index);
40898 /// Element at index 0 is the front of the queue.
40902 /// Panics if either index is out of bounds.
41833 /// Returns `None` if `index` is out of bounds.
41835 /// Element at index 0 is the front of the queue.
41853 pub fn swap_remove_front(&mut self, index: usize) -> Option<T> {
41855 if length > 0 && index < length && index != 0 {
41856 self.swap(index, 0);
41857 } else if index >= length {
41868 /// Returns `None` if `index` is out of bounds.
41870 /// Element at index 0 is the front of the queue.
41888 pub fn swap_remove_back(&mut self, index: usize) -> Option<T> {
41890 if length > 0 && index < length - 1 {
41891 self.swap(index, length - 1);
41892 } else if index >= length {
41898 /// Inserts an element at `index` within the `VecDeque`, shifting all elements with indices
41899 /// greater than or equal to `index` towards the back.
41901 /// Element at index 0 is the front of the queue.
41905 /// Panics if `index` is greater than `VecDeque`'s length
41922 pub fn insert(&mut self, index: usize, value: T) {
41923 assert!(index <= self.len(), "index out of bounds");
41950 let idx = self.wrap_add(self.tail, index);
41952 let distance_to_tail = index;
41953 let distance_to_head = self.len() - index;
41958 (true, true, _) if index == 0 => {
41995 // Already moved the tail, so we only copy `index - 1` elements.
41996 self.copy(self.tail, self.tail + 1, index - 1);
42027 self.copy(self.tail - 1, self.tail, index);
42057 // and is at index zero in the internal buffer:
42116 let new_idx = self.wrap_add(self.tail, index);
42122 /// Removes and returns the element at `index` from the `VecDeque`.
42125 /// Returns `None` if `index` is out of bounds.
42127 /// Element at index 0 is the front of the queue.
42144 pub fn remove(&mut self, index: usize) -> Option<T> {
42145 if self.is_empty() || self.len() <= index {
42167 let idx = self.wrap_add(self.tail, index);
42171 let distance_to_tail = index;
42172 let distance_to_head = self.len() - index;
42188 self.copy(self.tail + 1, self.tail, index);
42218 self.copy(self.tail + 1, self.tail, index);
42300 /// Splits the `VecDeque` into two at the given index.
42307 /// Element at index 0 is the front of the queue.
42411 /// The exact order may be useful for tracking external state, like an index.
42758 /// index of the matching element. If there are multiple matches, then any
42760 /// [`Result::Err`] is returned, containing the index where a matching
42818 /// index of the matching element. If there are multiple matches, then any
42820 /// [`Result::Err`] is returned, containing the index where a matching
42870 /// index of the matching element. If there are multiple matches, then any
42872 /// [`Result::Err`] is returned, containing the index where a matching
42913 /// Returns the index of the partition point according to the given predicate
42914 /// (the index of the first element of the second partition).
42987 /// Returns the index in the underlying buffer for a given logical element index.
42989 fn wrap_index(index: usize, size: usize) -> usize {
42992 index & (size - 1)
43085 fn index(&self, index: usize) -> &A {
43086 self.get(index).expect("Out of bounds access")
43093 fn index_mut(&mut self, index: usize) -> &mut A {
43094 self.get_mut(index).expect("Out of bounds access")
43390 // Safety: The TrustedRandomAccess contract requires that callers only pass an index
43882 // index to split at
44044 for (index, elem) in v.into_iter().enumerate() {
44045 if index < push_front {
44213 // Safety: The TrustedRandomAccess contract requires that callers only pass an index
44383 //! // The graph is represented as an adjacency list where each index,
44774 // so it's always a valid index to access.
44775 // It is safe to access index 0 (i.e. `ptr`), because
44812 // it's a valid index and also != hole.pos().
44861 // SAFETY: child is already proven to be a valid index and
44910 // SAFETY: child == end - 1 < self.len(), so it's a valid index
44918 // to be a valid index.
44953 // SAFETY: The index `i` is always less than self.len().
45381 /// Hole represents a hole in a slice i.e., an index without valid value
45392 /// Create a new `Hole` at index `pos`.
45414 /// Returns a reference to the element at `index`.
45416 /// Unsafe because index must be within the data slice and not equal to pos.
45418 unsafe fn get(&self, index: usize) -> &T {
45419 debug_assert!(index != self.pos);
45420 debug_assert!(index < self.data.len());
45421 unsafe { self.data.get_unchecked(index) }
45426 /// Unsafe because index must be within the data slice and not equal to pos.
45428 unsafe fn move_to(&mut self, index: usize) {
45429 debug_assert!(index != self.pos);
45430 debug_assert!(index < self.data.len());
45433 let index_ptr: *const _ = ptr.add(index);
45437 self.pos = index;
47005 /// The `Vec` type allows to access values by index, because it implements the
47013 /// However be careful: if you try to access an index which isn't in the `Vec`,
47021 /// Use [`get`] and [`get_mut`] if you want to check whether the index is in
48057 /// Panics if `index` is out of bounds.
48072 pub fn swap_remove(&mut self, index: usize) -> T {
48075 fn assert_failed(index: usize, len: usize) -> ! {
48076 panic!("swap_remove index (is {}) should be < len (is {})", index, len);
48080 if index >= len {
48081 assert_failed(index, len);
48084 // We replace self[index] with the last element. Note that if the
48086 // can be self[index] itself).
48088 let hole = self.as_mut_ptr().add(index);
48094 /// Inserts an element at position `index` within the vector, shifting all
48099 /// Panics if `index > len`.
48111 pub fn insert(&mut self, index: usize, element: T) {
48114 fn assert_failed(index: usize, len: usize) -> ! {
48115 panic!("insertion index (is {}) should be <= len (is {})", index, len);
48119 if index > len {
48120 assert_failed(index, len);
48132 let p = self.as_mut_ptr().add(index);
48134 // `index`th element into two consecutive places.)
48135 ptr::copy(p, p.offset(1), len - index);
48136 // Write it in, overwriting the first copy of the `index`th
48144 /// Removes and returns the element at position `index` within the vector,
48149 /// Panics if `index` is out of bounds.
48159 pub fn remove(&mut self, index: usize) -> T {
48162 fn assert_failed(index: usize, len: usize) -> ! {
48163 panic!("removal index (is {}) should be < len (is {})", index, len);
48167 if index >= len {
48168 assert_failed(index, len);
48175 let ptr = self.as_mut_ptr().add(index);
48181 ptr::copy(ptr.offset(1), ptr, len - index - 1);
48620 /// Splits the collection into two at the given index.
48648 panic!("`at` split index (is {}) should be <= len (is {})", at, len);
49070 /// - `src` needs to be valid index
49082 // - caller guaratees that src is a valid index
49101 // - caller guaratees that `src` is a valid index
49191 fn index(&self, index: I) -> &Self::Output {
49192 Index::index(&**self, index)
49203 fn index_mut(&mut self, index: I) -> &mut Self::Output {
49204 IndexMut::index_mut(&mut **self, index)
49764 /// The index of the item that will be inspected by the next call to `next`.
49807 // Update the index *after* the predicate is called. If the index
49809 // index would be leaked.
50129 //! See the [module-level documentation](../index.html) for more.
50331 /// See the [module-level documentation](../../std/boxed/index.html) for more.