| type Item | type Item = (usize, &'a str) | - | Тип элементов, по которым выполняется итерация (пара: индекс и срез строки) |
| next | fn next(&mut self) -> Option<(usize, &'a str)> | let first_match = match_indices.next(); | Перемещает итератор и возвращает следующее значение |
| next_chunk | fn next_chunk<const N: usize>(&mut self) -> Result<[Self::Item; N], IntoIter<Self::Item, N>> | let chunk = match_indices.next_chunk::<3>()?; | 🔬 Возвращает массив, содержащий следующие N значений |
| size_hint | fn size_hint(&self) -> (usize, Option<usize>) | let hint = match_indices.size_hint(); | Возвращает границы оставшейся длины итератора |
| count | fn count(self) -> usize | let total_matches = match_indices.count(); | Подсчитывает количество итераций и возвращает его |
| last | fn last(self) -> Option<Self::Item> | let last_match = match_indices.last(); | Возвращает последний элемент итератора |
| advance_by | fn advance_by(&mut self, n: usize) -> Result<(), NonZero<usize>> | match_indices.advance_by(2)?; | 🔬 Перемещает итератор на n элементов |
| nth | fn nth(&mut self, n: usize) -> Option<Self::Item> | let third_match = match_indices.nth(2); | Возвращает n-й элемент итератора |
| step_by (с версии 1.28.0) | fn step_by(self, step: usize) -> StepBy<Self> ⓘ | let every_second = match_indices.step_by(2); | Создает итератор с заданным шагом |
| chain | fn chain<U>(self, other: U) -> Chain<Self, <U as IntoIterator>::IntoIter> ⓘ | let combined = match_indices.chain(other_matches); | Объединяет два итератора в последовательный |
| zip | fn zip<U>(self, other: U) -> Zip<Self, <U as IntoIterator>::IntoIter> ⓘ | let paired = match_indices.zip(other_data); | "Объединяет" два итератора в итератор пар |
| intersperse | fn intersperse(self, separator: Self::Item) -> Intersperse<Self> ⓘ | let with_sep = match_indices.intersperse((0, "")); | 🔬 Помещает копию separator между элементами |
| intersperse_with | fn intersperse_with<G>(self, separator: G) -> IntersperseWith<Self, G> ⓘ | `let with_sep = match_indices.intersperse_with( | |
| map | fn map<B, F>(self, f: F) -> Map<Self, F> ⓘ | `let indices = match_indices.map( | (i, _) |
| for_each | fn for_each<F>(self, f: F) | `match_indices.for_each( | (i, s) |
| filter | fn filter<P>(self, predicate: P) -> Filter<Self, P> ⓘ | `let long_matches = match_indices.filter( | (_, s) |
| filter_map | fn filter_map<B, F>(self, f: F) -> FilterMap<Self, F> ⓘ | `let lengths = match_indices.filter_map( | (i, s) |
| enumerate | fn enumerate(self) -> Enumerate<Self> ⓘ | for (j, (i, s)) in match_indices.enumerate() { ... } | Добавляет индекс к каждому элементу |
| peekable | fn peekable(self) -> Peekable<Self> ⓘ | let peekable = match_indices.peekable(); | Создает итератор с возможностью просмотра следующего элемента |
| skip_while | fn skip_while<P>(self, predicate: P) -> SkipWhile<Self, P> ⓘ | `let skipped = match_indices.skip_while( | (i, _) |
| take_while | fn take_while<P>(self, predicate: P) -> TakeWhile<Self, P> ⓘ | `let taken = match_indices.take_while( | (i, _) |
| map_while (с версии 1.57.0) | fn map_while<B, P>(self, predicate: P) -> MapWhile<Self, P> ⓘ | `let mapped = match_indices.map_while( | (i, s) |
| skip | fn skip(self, n: usize) -> Skip<Self> ⓘ | let skipped = match_indices.skip(3); | Пропускает первые n элементов |
| take | fn take(self, n: usize) -> Take<Self> ⓘ | let taken = match_indices.take(5); | Берет первые n элементов |
| scan | fn scan<St, B, F>(self, initial_state: St, f: F) -> Scan<Self, St, F> ⓘ | `let scanned = match_indices.scan(vec![], | state, (i, s) |
| flat_map | fn flat_map<U, F>(self, f: F) -> FlatMap<Self, U, F> ⓘ | `let chars = match_indices.flat_map( | (_, s) |
| flatten (с версии 1.29.0) | fn flatten(self) -> Flatten<Self> ⓘ | let flattened = match_indices.flatten(); | Сглаживает вложенную структуру |
| map_windows | fn map_windows<F, R, const N: usize>(self, f: F) -> MapWindows<Self, F, N> ⓘ | `let windows = match_indices.map_windows::<_, _, 2>( | arr |
| fuse | fn fuse(self) -> Fuse<Self> ⓘ | let fused = match_indices.fuse(); | Создает итератор, завершающийся после первого None |
| inspect | fn inspect<F>(self, f: F) -> Inspect<Self, F> ⓘ | `let inspected = match_indices.inspect( | (i, s) |
| by_ref | fn by_ref(&mut self) -> &mut Self | let part = match_indices.by_ref().take(5).collect::<Vec<_>>(); | Создает адаптер "по ссылке" для итератора |
| collect | fn collect<B>(self) -> B | let vec: Vec<(usize, &str)> = match_indices.collect(); | Преобразует итератор в коллекцию |
| try_collect | fn try_collect<B>(&mut self) -> <<Self::Item as Try>::Residual as Residual<B>>::TryType | let result: Result<Vec<(usize, &str)>, _> = match_indices.try_collect(); | 🔬 Преобразует итератор в коллекцию с обработкой ошибок |
| collect_into | fn collect_into<E>(self, collection: &mut E) -> &mut E | let mut vec = Vec::new(); match_indices.collect_into(&mut vec); | 🔬 Собирает все элементы в коллекцию |
| partition | fn partition<B, F>(self, f: F) -> (B, B) | `let (early, late): (Vec<>, Vec<>) = match_indices.partition( | (i, _) |
| partition_in_place | fn partition_in_place<'a, T, P>(self, predicate: P) -> usize | `let count = match_indices.partition_in_place( | (i, _) |
| is_partitioned | fn is_partitioned<P>(self, predicate: P) -> bool | `let partitioned = match_indices.is_partitioned( | (i, _) |
| try_fold (с версии 1.27.0) | fn try_fold<B, F, R>(&mut self, init: B, f: F) -> R | `let total_len = match_indices.try_fold(0, | acc, (_, s) |
| try_for_each (с версии 1.27.0) | fn try_for_each<F, R>(&mut self, f: F) -> R | `let result: Result<(), _> = match_indices.try_for_each( | (i, s) |
| fold | fn fold<B, F>(self, init: B, f: F) -> B | `let total_len = match_indices.fold(0, | acc, (_, s) |
| reduce (с версии 1.51.0) | fn reduce<F>(self, f: F) -> Option<Self::Item> | `let longest = match_indices.reduce( | a, b |
| try_reduce | fn try_reduce<R>(&mut self, f: impl FnMut(Self::Item, Self::Item) -> R) -> <<R as Try>::Residual as Residual<Option<<R as Try>::Output>>>::TryType | `let result: Result<Option<(usize, &str)>, _> = match_indices.try_reduce( | a, b |
| all | fn all<F>(&mut self, f: F) -> bool | `let all_long = match_indices.all( | (_, s) |
| any | fn any<F>(&mut self, f: F) -> bool | `let has_empty = match_indices.any( | (_, s) |
| find | fn find<P>(&mut self, predicate: P) -> Option<Self::Item> | `let first_long = match_indices.find( | (_, s) |
| find_map (с версии 1.30.0) | fn find_map<B, F>(&mut self, f: F) -> Option<B> | `let first_num = match_indices.find_map( | (i, s) |
| try_find | fn try_find<R>(&mut self, f: impl FnMut(&Self::Item) -> R) -> <<R as Try>::Residual as Residual<Option<Self::Item>>>::TryType | `let result: Result<Option<(usize, &str)>, _> = match_indices.try_find( | (_, s) |
| position | fn position<P>(&mut self, predicate: P) -> Option<usize> | `let pos = match_indices.position( | (_, s) |
| rposition | fn rposition<P>(&mut self, predicate: P) -> Option<usize> | `let pos = match_indices.rposition( | (_, s) |
| max | fn max(self) -> Option<Self::Item> | let longest = match_indices.max(); | Возвращает максимальный элемент (лексикографически) |
| min | fn min(self) -> Option<Self::Item> | let shortest = match_indices.min(); | Возвращает минимальный элемент (лексикографически) |
| max_by_key (с версии 1.6.0) | fn max_by_key<B, F>(self, f: F) -> Option<Self::Item> | `let latest = match_indices.max_by_key( | (i, _) |
| max_by (с версии 1.15.0) | fn max_by<F>(self, compare: F) -> Option<Self::Item> | `let longest = match_indices.max_by( | a, b |
| min_by_key (с версии 1.6.0) | fn min_by_key<B, F>(self, f: F) -> Option<Self::Item> | `let earliest = match_indices.min_by_key( | (i, _) |
| min_by (с версии 1.15.0) | fn min_by<F>(self, compare: F) -> Option<Self::Item> | `let shortest = match_indices.min_by( | a, b |
| rev | fn rev(self) -> Rev<Self> ⓘ | let reversed = match_indices.rev(); | Изменяет направление итератора |
| unzip | fn unzip<A, B, FromA, FromB>(self) -> (FromA, FromB) | let (indices, matches): (Vec<usize>, Vec<&str>) = match_indices.unzip(); | Преобразует итератор пар в пару контейнеров |
| copied (с версии 1.36.0) | fn copied<'a, T>(self) -> Copied<Self> ⓘ | let copied = match_indices.copied(); | Создает итератор, который копирует все элементы |
| cloned | fn cloned<'a, T>(self) -> Cloned<Self> ⓘ | let cloned = match_indices.cloned(); | Создает итератор, который клонирует все элементы |
| cycle | fn cycle(self) -> Cycle<Self> ⓘ | let cycled = match_indices.cycle(); | Бесконечно повторяет итератор |
| array_chunks | fn array_chunks<const N: usize>(self) -> ArrayChunks<Self, N> ⓘ | for chunk in match_indices.array_chunks::<3>() { ... } | 🔬 Возвращает итератор по N элементов за раз |
| sum (с версии 1.11.0) | fn sum<S>(self) -> S | `let total_len: usize = match_indices.map( | (_, s) |
| product (с версии 1.11.0) | fn product<P>(self) -> P | `let product: usize = match_indices.map( | (_, s) |
| cmp (с версии 1.5.0) | fn cmp<I>(self, other: I) -> Ordering | let ordering = match_indices.cmp(other_matches); | Лексикографически сравнивает элементы с другими |
| cmp_by | fn cmp_by<I, F>(self, other: I, cmp: F) -> Ordering | `let ordering = match_indices.cmp_by(other_matches, | a, b |
| partial_cmp (с версии 1.5.0) | fn partial_cmp<I>(self, other: I) -> Option<Ordering> | let ordering = match_indices.partial_cmp(other_matches); | Частично сравнивает элементы с другими |
| partial_cmp_by | fn partial_cmp_by<I, F>(self, other: I, partial_cmp: F) -> Option<Ordering> | `let ordering = match_indices.partial_cmp_by(other_matches, | a, b |
| eq (с версии 1.5.0) | fn eq<I>(self, other: I) -> bool | let equal = match_indices.eq(other_matches); | Проверяет равенство элементов с другими |
| eq_by | fn eq_by<I, F>(self, other: I, eq: F) -> bool | `let equal = match_indices.eq_by(other_matches, | a, b |
| ne (с версии 1.5.0) | fn ne<I>(self, other: I) -> bool | let not_equal = match_indices.ne(other_matches); | Проверяет неравенство элементов с другими |
| lt (с версии 1.5.0) | fn lt<I>(self, other: I) -> bool | let less = match_indices.lt(other_matches); | Проверяет, меньше ли элементы, чем другие |
| le (с версии 1.5.0) | fn le<I>(self, other: I) -> bool | let less_or_equal = match_indices.le(other_matches); | Проверяет, меньше или равны ли элементы |
| gt (с версии 1.5.0) | fn gt<I>(self, other: I) -> bool | let greater = match_indices.gt(other_matches); | Проверяет, больше ли элементы, чем другие |
| ge (с версии 1.5.0) | fn ge<I>(self, other: I) -> bool | let greater_or_equal = match_indices.ge(other_matches); | Проверяет, больше или равны ли элементы |
| is_sorted (с версии 1.82.0) | fn is_sorted(self) -> bool | let sorted = match_indices.is_sorted(); | Проверяет, отсортированы ли элементы (по индексу) |
| is_sorted_by (с версии 1.82.0) | fn is_sorted_by<F>(self, compare: F) -> bool | `let sorted = match_indices.is_sorted_by( | a, b |
| is_sorted_by_key (с версии 1.82.0) | fn is_sorted_by_key<F, K>(self, f: F) -> bool | `let sorted = match_indices.is_sorted_by_key( | (i, _) |