From 08036afa06227e84c324d9ae4eb14af5df42afbb Mon Sep 17 00:00:00 2001 From: Marcin Puc Date: Sun, 2 May 2021 18:24:37 +0200 Subject: [PATCH 1/6] Link to common traits, structs, etc. --- src/adaptors/mod.rs | 4 ++-- src/concat_impl.rs | 4 ++-- src/diff.rs | 2 +- src/free.rs | 24 ++++++++++++------------ src/groupbylazy.rs | 4 ++-- src/lib.rs | 12 ++++++------ src/peek_nth.rs | 2 +- src/sources.rs | 2 +- src/zip_eq_impl.rs | 2 +- src/ziptuple.rs | 2 +- 10 files changed, 29 insertions(+), 29 deletions(-) diff --git a/src/adaptors/mod.rs b/src/adaptors/mod.rs index dfc68978f..0c01eafb8 100644 --- a/src/adaptors/mod.rs +++ b/src/adaptors/mod.rs @@ -35,7 +35,7 @@ pub struct Interleave { /// Create an iterator that interleaves elements in `i` and `j`. /// -/// `IntoIterator` enabled version of `i.interleave(j)`. +/// [`IntoIterator`] enabled version of `i.interleave(j)`. /// /// See [`.interleave()`](crate::Itertools::interleave) for more information. pub fn interleave(i: I, j: J) -> Interleave<::IntoIter, ::IntoIter> @@ -481,7 +481,7 @@ pub type Merge = MergeBy; /// Create an iterator that merges elements in `i` and `j`. /// -/// `IntoIterator` enabled version of `i.merge(j)`. +/// [`IntoIterator`] enabled version of `i.merge(j)`. /// /// ``` /// use itertools::merge; diff --git a/src/concat_impl.rs b/src/concat_impl.rs index 0233d01f6..422fecd9e 100644 --- a/src/concat_impl.rs +++ b/src/concat_impl.rs @@ -1,8 +1,8 @@ use crate::Itertools; -/// Combine all an iterator's elements into one element by using `Extend`. +/// Combine all an iterator's elements into one element by using [`Extend`]. /// -/// `IntoIterator`-enabled version of `.concat()` +/// [`IntoIterator`]-enabled version of `.concat()` /// /// This combinator will extend the first item with each of the rest of the /// items of the iterator. If the iterator is empty, the default value of diff --git a/src/diff.rs b/src/diff.rs index b8d26cdd3..1731f0639 100644 --- a/src/diff.rs +++ b/src/diff.rs @@ -26,7 +26,7 @@ pub enum Diff } /// Compares every element yielded by both `i` and `j` with the given function in lock-step and -/// returns a `Diff` which describes how `j` differs from `i`. +/// returns a [`Diff`] which describes how `j` differs from `i`. /// /// If the number of elements yielded by `j` is less than the number of elements yielded by `i`, /// the number of `j` elements yielded will be returned along with `i`'s remaining elements as diff --git a/src/free.rs b/src/free.rs index 0520eb5e6..d77a6dd3f 100644 --- a/src/free.rs +++ b/src/free.rs @@ -1,6 +1,6 @@ //! Free functions that create iterator adaptors or call iterator methods. //! -//! The benefit of free functions is that they accept any `IntoIterator` as +//! The benefit of free functions is that they accept any [`IntoIterator`] as //! argument, so the resulting code may be easier to read. #[cfg(feature = "use_alloc")] @@ -37,7 +37,7 @@ pub use crate::rciter_impl::rciter; /// Iterate `iterable` with a running index. /// -/// `IntoIterator` enabled version of `.enumerate()`. +/// [`IntoIterator`] enabled version of `.enumerate()`. /// /// ``` /// use itertools::enumerate; @@ -54,7 +54,7 @@ pub fn enumerate(iterable: I) -> iter::Enumerate /// Iterate `iterable` in reverse. /// -/// `IntoIterator` enabled version of `.rev()`. +/// [`IntoIterator`] enabled version of `.rev()`. /// /// ``` /// use itertools::rev; @@ -72,7 +72,7 @@ pub fn rev(iterable: I) -> iter::Rev /// Iterate `i` and `j` in lock step. /// -/// `IntoIterator` enabled version of `i.zip(j)`. +/// [`IntoIterator`] enabled version of `i.zip(j)`. /// /// ``` /// use itertools::zip; @@ -109,7 +109,7 @@ pub fn chain(i: I, j: J) -> iter::Chain<::IntoIter, (iterable: I) -> iter::Cloned /// Perform a fold operation over the iterable. /// -/// `IntoIterator` enabled version of `i.fold(init, f)` +/// [`IntoIterator`] enabled version of `i.fold(init, f)` /// /// ``` /// use itertools::fold; @@ -141,7 +141,7 @@ pub fn fold(iterable: I, init: B, f: F) -> B /// Test whether the predicate holds for all elements in the iterable. /// -/// `IntoIterator` enabled version of `i.all(f)` +/// [`IntoIterator`] enabled version of `i.all(f)` /// /// ``` /// use itertools::all; @@ -157,7 +157,7 @@ pub fn all(iterable: I, f: F) -> bool /// Test whether the predicate holds for any elements in the iterable. /// -/// `IntoIterator` enabled version of `i.any(f)` +/// [`IntoIterator`] enabled version of `i.any(f)` /// /// ``` /// use itertools::any; @@ -173,7 +173,7 @@ pub fn any(iterable: I, f: F) -> bool /// Return the maximum value of the iterable. /// -/// `IntoIterator` enabled version of `i.max()`. +/// [`IntoIterator`] enabled version of `i.max()`. /// /// ``` /// use itertools::max; @@ -189,7 +189,7 @@ pub fn max(iterable: I) -> Option /// Return the minimum value of the iterable. /// -/// `IntoIterator` enabled version of `i.min()`. +/// [`IntoIterator`] enabled version of `i.min()`. /// /// ``` /// use itertools::min; @@ -206,7 +206,7 @@ pub fn min(iterable: I) -> Option /// Combine all iterator elements into one String, seperated by `sep`. /// -/// `IntoIterator` enabled version of `iterable.join(sep)`. +/// [`IntoIterator`] enabled version of `iterable.join(sep)`. /// /// ``` /// use itertools::join; @@ -223,7 +223,7 @@ pub fn join(iterable: I, sep: &str) -> String /// Sort all iterator elements into a new iterator in ascending order. /// -/// `IntoIterator` enabled version of [`iterable.sorted()`][1]. +/// [`IntoIterator`] enabled version of [`iterable.sorted()`][1]. /// /// [1]: crate::Itertools::sorted /// diff --git a/src/groupbylazy.rs b/src/groupbylazy.rs index b57d4046b..91c52ea59 100644 --- a/src/groupbylazy.rs +++ b/src/groupbylazy.rs @@ -279,7 +279,7 @@ impl GroupInner /// no allocations. It needs allocations only if several group iterators /// are alive at the same time. /// -/// This type implements `IntoIterator` (it is **not** an iterator +/// This type implements [`IntoIterator`] (it is **not** an iterator /// itself), because the group iterators need to borrow from this /// value. It should be stored in a local variable or temporary and /// iterated. @@ -453,7 +453,7 @@ pub fn new_chunks(iter: J, size: usize) -> IntoChunks /// `IntoChunks` behaves just like `GroupBy`: it is iterable, and /// it only buffers if several chunk iterators are alive at the same time. /// -/// This type implements `IntoIterator` (it is **not** an iterator +/// This type implements [`IntoIterator`] (it is **not** an iterator /// itself), because the chunk iterators need to borrow from this /// value. It should be stored in a local variable or temporary and /// iterated. diff --git a/src/lib.rs b/src/lib.rs index 4d6dd93ac..812bbe84b 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -595,7 +595,7 @@ pub trait Itertools : Iterator { /// allocations. It needs allocations only if several group iterators /// are alive at the same time. /// - /// This type implements `IntoIterator` (it is **not** an iterator + /// This type implements [`IntoIterator`] (it is **not** an iterator /// itself), because the group iterators need to borrow from this /// value. It should be stored in a local variable or temporary and /// iterated. @@ -824,7 +824,7 @@ pub trait Itertools : Iterator { adaptors::step(self, n) } - /// Convert each item of the iterator using the `Into` trait. + /// Convert each item of the iterator using the [`Into`] trait. /// /// ```rust /// use itertools::Itertools; @@ -1915,7 +1915,7 @@ pub trait Itertools : Iterator { self.for_each(f) } - /// Combine all an iterator's elements into one element by using `Extend`. + /// Combine all an iterator's elements into one element by using [`Extend`]. /// /// This combinator will extend the first item with each of the rest of the /// items of the iterator. If the iterator is empty, the default value of @@ -2865,7 +2865,7 @@ pub trait Itertools : Iterator { /// Return the minimum and maximum element of an iterator, as determined by /// the specified function. /// - /// The return value is a variant of `MinMaxResult` like for `minmax()`. + /// The return value is a variant of [`MinMaxResult`] like for `minmax()`. /// /// For the minimum, the first minimal element is returned. For the maximum, /// the last maximal element wins. This matches the behavior of the standard @@ -2882,7 +2882,7 @@ pub trait Itertools : Iterator { /// Return the minimum and maximum element of an iterator, as determined by /// the specified comparison function. /// - /// The return value is a variant of `MinMaxResult` like for `minmax()`. + /// The return value is a variant of [`MinMaxResult`] like for `minmax()`. /// /// For the minimum, the first minimal element is returned. For the maximum, /// the last maximal element wins. This matches the behavior of the standard @@ -3370,7 +3370,7 @@ impl Itertools for T where T: Iterator { } /// (elements pairwise equal and sequences of the same length), /// `false` otherwise. /// -/// This is an `IntoIterator` enabled function that is similar to the standard +/// This is an [`IntoIterator`] enabled function that is similar to the standard /// library method `Iterator::eq`. /// /// ``` diff --git a/src/peek_nth.rs b/src/peek_nth.rs index 48b44bb70..bcca45838 100644 --- a/src/peek_nth.rs +++ b/src/peek_nth.rs @@ -13,7 +13,7 @@ where buf: VecDeque, } -/// A drop-in replacement for `std::iter::Peekable` which adds a `peek_nth` +/// A drop-in replacement for [`std::iter::Peekable`] which adds a `peek_nth` /// method allowing the user to `peek` at a value several iterations forward /// without advancing the base iterator. /// diff --git a/src/sources.rs b/src/sources.rs index 5bb6afe4a..b4a7bf707 100644 --- a/src/sources.rs +++ b/src/sources.rs @@ -67,7 +67,7 @@ impl Iterator for RepeatCall /// `unfold` is a general iterator builder: it has a mutable state value, /// and a closure with access to the state that produces the next value. /// -/// This more or less equivalent to a regular struct with an `Iterator` +/// This more or less equivalent to a regular struct with an [`Iterator`] /// implementation, and is useful for one-off iterators. /// /// ``` diff --git a/src/zip_eq_impl.rs b/src/zip_eq_impl.rs index 864930bc0..552afea73 100644 --- a/src/zip_eq_impl.rs +++ b/src/zip_eq_impl.rs @@ -14,7 +14,7 @@ pub struct ZipEq { /// /// **Panics** if the iterators are not of the same length. /// -/// `IntoIterator` enabled version of `i.zip_eq(j)`. +/// [`IntoIterator`] enabled version of `i.zip_eq(j)`. /// /// ``` /// use itertools::zip_eq; diff --git a/src/ziptuple.rs b/src/ziptuple.rs index fe9659ee5..b7902ae53 100644 --- a/src/ziptuple.rs +++ b/src/ziptuple.rs @@ -10,7 +10,7 @@ pub struct Zip { /// An iterator that generalizes *.zip()* and allows running multiple iterators in lockstep. /// /// The iterator `Zip<(I, J, ..., M)>` is formed from a tuple of iterators (or values that -/// implement `IntoIterator`) and yields elements +/// implement [`IntoIterator`]) and yields elements /// until any of the subiterators yields `None`. /// /// The iterator element type is a tuple like like `(A, B, ..., E)` where `A` to `E` are the From 9933ea130b5859f68ea9870bbc6481eebf52b188 Mon Sep 17 00:00:00 2001 From: Marcin Puc Date: Sun, 2 May 2021 18:50:16 +0200 Subject: [PATCH 2/6] Add method links in docs of free functions --- src/adaptors/mod.rs | 2 +- src/concat_impl.rs | 2 +- src/free.rs | 22 +++++++++++----------- src/lib.rs | 4 ++-- src/zip_eq_impl.rs | 2 +- 5 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/adaptors/mod.rs b/src/adaptors/mod.rs index 0c01eafb8..fce4e6ca1 100644 --- a/src/adaptors/mod.rs +++ b/src/adaptors/mod.rs @@ -481,7 +481,7 @@ pub type Merge = MergeBy; /// Create an iterator that merges elements in `i` and `j`. /// -/// [`IntoIterator`] enabled version of `i.merge(j)`. +/// [`IntoIterator`] enabled version of [`Itertools::merge`](crate::Itertools::merge). /// /// ``` /// use itertools::merge; diff --git a/src/concat_impl.rs b/src/concat_impl.rs index 422fecd9e..450f7fce1 100644 --- a/src/concat_impl.rs +++ b/src/concat_impl.rs @@ -2,7 +2,7 @@ use crate::Itertools; /// Combine all an iterator's elements into one element by using [`Extend`]. /// -/// [`IntoIterator`]-enabled version of `.concat()` +/// [`IntoIterator`]-enabled version of [`Itertools::concat`]. /// /// This combinator will extend the first item with each of the rest of the /// items of the iterator. If the iterator is empty, the default value of diff --git a/src/free.rs b/src/free.rs index d77a6dd3f..2c74dab5d 100644 --- a/src/free.rs +++ b/src/free.rs @@ -37,7 +37,7 @@ pub use crate::rciter_impl::rciter; /// Iterate `iterable` with a running index. /// -/// [`IntoIterator`] enabled version of `.enumerate()`. +/// [`IntoIterator`] enabled version of [`Iterator::enumerate`]. /// /// ``` /// use itertools::enumerate; @@ -54,7 +54,7 @@ pub fn enumerate(iterable: I) -> iter::Enumerate /// Iterate `iterable` in reverse. /// -/// [`IntoIterator`] enabled version of `.rev()`. +/// [`IntoIterator`] enabled version of [`Iterator::rev`]. /// /// ``` /// use itertools::rev; @@ -72,7 +72,7 @@ pub fn rev(iterable: I) -> iter::Rev /// Iterate `i` and `j` in lock step. /// -/// [`IntoIterator`] enabled version of `i.zip(j)`. +/// [`IntoIterator`] enabled version of [`Iterator::zip`]. /// /// ``` /// use itertools::zip; @@ -91,7 +91,7 @@ pub fn zip(i: I, j: J) -> Zip /// Create an iterator that first iterates `i` and then `j`. /// -/// `IntoIterator` enabled version of `i.chain(j)`. +/// [`IntoIterator`] enabled version of [`Iterator::chain`]. /// /// ``` /// use itertools::chain; @@ -109,7 +109,7 @@ pub fn chain(i: I, j: J) -> iter::Chain<::IntoIter, (iterable: I) -> iter::Cloned /// Perform a fold operation over the iterable. /// -/// [`IntoIterator`] enabled version of `i.fold(init, f)` +/// [`IntoIterator`] enabled version of [`Iterator::fold`]. /// /// ``` /// use itertools::fold; @@ -141,7 +141,7 @@ pub fn fold(iterable: I, init: B, f: F) -> B /// Test whether the predicate holds for all elements in the iterable. /// -/// [`IntoIterator`] enabled version of `i.all(f)` +/// [`IntoIterator`] enabled version of [`Iterator::all`]. /// /// ``` /// use itertools::all; @@ -157,7 +157,7 @@ pub fn all(iterable: I, f: F) -> bool /// Test whether the predicate holds for any elements in the iterable. /// -/// [`IntoIterator`] enabled version of `i.any(f)` +/// [`IntoIterator`] enabled version of [`Iterator::any`]. /// /// ``` /// use itertools::any; @@ -173,7 +173,7 @@ pub fn any(iterable: I, f: F) -> bool /// Return the maximum value of the iterable. /// -/// [`IntoIterator`] enabled version of `i.max()`. +/// [`IntoIterator`] enabled version of [`Iterator::max`]. /// /// ``` /// use itertools::max; @@ -189,7 +189,7 @@ pub fn max(iterable: I) -> Option /// Return the minimum value of the iterable. /// -/// [`IntoIterator`] enabled version of `i.min()`. +/// [`IntoIterator`] enabled version of [`Iterator::min`]. /// /// ``` /// use itertools::min; @@ -206,7 +206,7 @@ pub fn min(iterable: I) -> Option /// Combine all iterator elements into one String, seperated by `sep`. /// -/// [`IntoIterator`] enabled version of `iterable.join(sep)`. +/// [`IntoIterator`] enabled version of [`Itertools::join`]. /// /// ``` /// use itertools::join; diff --git a/src/lib.rs b/src/lib.rs index 812bbe84b..eb26c70b1 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -3371,7 +3371,7 @@ impl Itertools for T where T: Iterator { } /// `false` otherwise. /// /// This is an [`IntoIterator`] enabled function that is similar to the standard -/// library method `Iterator::eq`. +/// library method [`Iterator::eq`]. /// /// ``` /// assert!(itertools::equal(vec![1, 2, 3], 1..4)); @@ -3396,7 +3396,7 @@ pub fn equal(a: I, b: J) -> bool } /// Assert that two iterables produce equal sequences, with the same -/// semantics as *equal(a, b)*. +/// semantics as [`equal(a, b)`](equal). /// /// **Panics** on assertion failure with a message that shows the /// two iteration elements. diff --git a/src/zip_eq_impl.rs b/src/zip_eq_impl.rs index 552afea73..a079b326a 100644 --- a/src/zip_eq_impl.rs +++ b/src/zip_eq_impl.rs @@ -14,7 +14,7 @@ pub struct ZipEq { /// /// **Panics** if the iterators are not of the same length. /// -/// [`IntoIterator`] enabled version of `i.zip_eq(j)`. +/// [`IntoIterator`] enabled version of [`Itertools::zip_eq`](crate::Itertools::zip_eq). /// /// ``` /// use itertools::zip_eq; From 0366c2d0ff1d3bc46d0348cb2574ce56edb72f3f Mon Sep 17 00:00:00 2001 From: Marcin Puc Date: Sun, 2 May 2021 19:11:13 +0200 Subject: [PATCH 3/6] Simplify link paths --- src/combinations.rs | 4 +--- src/duplicates_impl.rs | 4 ++-- src/either_or_both.rs | 4 ++-- src/free.rs | 4 +--- src/grouping_map.rs | 6 +++--- src/lib.rs | 20 ++++++++++---------- src/powerset.rs | 2 +- src/process_results_impl.rs | 2 +- src/repeatn.rs | 2 +- src/sources.rs | 9 ++++----- 10 files changed, 26 insertions(+), 31 deletions(-) diff --git a/src/combinations.rs b/src/combinations.rs index 1ed04087b..05f649d51 100644 --- a/src/combinations.rs +++ b/src/combinations.rs @@ -47,9 +47,7 @@ impl Combinations { pub fn k(&self) -> usize { self.indices.len() } /// Returns the (current) length of the pool from which combination elements are - /// selected. This value can change between invocations of [`next`]. - /// - /// [`next`]: #method.next + /// selected. This value can change between invocations of [`next`](Combinations::next). #[inline] pub fn n(&self) -> usize { self.pool.len() } diff --git a/src/duplicates_impl.rs b/src/duplicates_impl.rs index a581cc04d..42049df35 100644 --- a/src/duplicates_impl.rs +++ b/src/duplicates_impl.rs @@ -176,7 +176,7 @@ mod private { /// An iterator adapter to filter for duplicate elements. /// -/// See [`.duplicates_by()`](../trait.Itertools.html#method.duplicates_by) for more information. +/// See [`.duplicates_by()`](crate::Itertools::duplicates_by) for more information. #[must_use = "iterator adaptors are lazy and do nothing unless consumed"] pub type DuplicatesBy = private::DuplicatesBy>; @@ -192,7 +192,7 @@ where /// An iterator adapter to filter out duplicate elements. /// -/// See [`.duplicates()`](../trait.Itertools.html#method.duplicates) for more information. +/// See [`.duplicates()`](crate::Itertools::duplicates) for more information. pub type Duplicates = private::DuplicatesBy::Item, private::ById>; /// Create a new `Duplicates` iterator. diff --git a/src/either_or_both.rs b/src/either_or_both.rs index 982b85189..31c18ef2f 100644 --- a/src/either_or_both.rs +++ b/src/either_or_both.rs @@ -25,7 +25,7 @@ impl EitherOrBoth { } /// If Left, return true otherwise, return false. - /// Exclusive version of [`has_left`](Self::has_left). + /// Exclusive version of [`has_left`](EitherOrBoth::has_left). pub fn is_left(&self) -> bool { match *self { Left(_) => true, @@ -34,7 +34,7 @@ impl EitherOrBoth { } /// If Right, return true otherwise, return false. - /// Exclusive version of [`has_right`](Self::has_right). + /// Exclusive version of [`has_right`](EitherOrBoth::has_right). pub fn is_right(&self) -> bool { match *self { Right(_) => true, diff --git a/src/free.rs b/src/free.rs index 2c74dab5d..c78dc1d02 100644 --- a/src/free.rs +++ b/src/free.rs @@ -223,9 +223,7 @@ pub fn join(iterable: I, sep: &str) -> String /// Sort all iterator elements into a new iterator in ascending order. /// -/// [`IntoIterator`] enabled version of [`iterable.sorted()`][1]. -/// -/// [1]: crate::Itertools::sorted +/// [`IntoIterator`] enabled version of [`Itertools::sorted`]. /// /// ``` /// use itertools::sorted; diff --git a/src/grouping_map.rs b/src/grouping_map.rs index cc89efe13..1212be866 100644 --- a/src/grouping_map.rs +++ b/src/grouping_map.rs @@ -7,7 +7,7 @@ use std::hash::Hash; use std::iter::Iterator; use std::ops::{Add, Mul}; -/// A wrapper to allow for an easy [`into_grouping_map_by`](../trait.Itertools.html#method.into_grouping_map_by) +/// A wrapper to allow for an easy [`into_grouping_map_by`](crate::Itertools::into_grouping_map_by) #[derive(Clone, Debug)] pub struct MapForGrouping(I, F); @@ -38,7 +38,7 @@ pub fn new(iter: I) -> GroupingMap /// `GroupingMapBy` is an intermediate struct for efficient group-and-fold operations. /// -/// See [`GroupingMap`](./struct.GroupingMap.html) for more informations. +/// See [`GroupingMap`] for more informations. #[must_use = "GroupingMapBy is lazy and do nothing unless consumed"] pub type GroupingMapBy = GroupingMap>; @@ -377,7 +377,7 @@ impl GroupingMap /// If several elements are equally maximum, the last element is picked. /// If several elements are equally minimum, the first element is picked. /// - /// See [.minmax()](../trait.Itertools.html#method.minmax) for the non-grouping version. + /// See [.minmax()](crate::Itertools::minmax) for the non-grouping version. /// /// Differences from the non grouping version: /// - It never produces a `MinMaxResult::NoElements` diff --git a/src/lib.rs b/src/lib.rs index eb26c70b1..2eba67049 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -421,11 +421,11 @@ macro_rules! chain { /// /// * *Adaptors* take an iterator and parameter as input, and return /// a new iterator value. These are listed first in the trait. An example -/// of an adaptor is [`.interleave()`](#method.interleave) +/// of an adaptor is [`.interleave()`](Itertools::interleave) /// /// * *Regular methods* are those that don't return iterators and instead /// return a regular value of some other kind. -/// [`.next_tuple()`](#method.next_tuple) is an example and the first regular +/// [`.next_tuple()`](Itertools::next_tuple) is an example and the first regular /// method in the list. pub trait Itertools : Iterator { // adaptors @@ -740,7 +740,7 @@ pub trait Itertools : Iterator { /// Return an iterator that groups the items in tuples of a specific size /// (up to 4). /// - /// See also the method [`.next_tuple()`](#method.next_tuple). + /// See also the method [`.next_tuple()`](Itertools::next_tuple). /// /// ``` /// use itertools::Itertools; @@ -838,7 +838,7 @@ pub trait Itertools : Iterator { adaptors::map_into(self) } - /// See [`.map_ok()`](#method.map_ok). + /// See [`.map_ok()`](Itertools::map_ok). #[deprecated(note="Use .map_ok() instead", since="0.10.0")] fn map_results(self, f: F) -> MapOk where Self: Iterator> + Sized, @@ -1354,7 +1354,7 @@ pub trait Itertools : Iterator { /// `peeking_take_while` is done. /// /// - /// See also [`.take_while_ref()`](#method.take_while_ref) + /// See also [`.take_while_ref()`](Itertools::take_while_ref) /// which is a similar adaptor. fn peeking_take_while(&mut self, accept: F) -> PeekingTakeWhile where Self: Sized + PeekingNext, @@ -2094,7 +2094,7 @@ pub trait Itertools : Iterator { format::new_format(self, sep, format) } - /// See [`.fold_ok()`](#method.fold_ok). + /// See [`.fold_ok()`](Itertools::fold_ok). #[deprecated(note="Use .fold_ok() instead", since="0.10.0")] fn fold_results(&mut self, start: B, f: F) -> Result where Self: Iterator>, @@ -2794,7 +2794,7 @@ pub trait Itertools : Iterator { /// value of type `K` will be used as key to identify the groups and the /// value of type `V` as value for the folding operation. /// - /// See [`GroupingMap`](./structs/struct.GroupingMap.html) for more informations + /// See [`GroupingMap`] for more informations /// on what operations are available. #[cfg(feature = "use_std")] fn into_grouping_map(self) -> GroupingMap @@ -2810,7 +2810,7 @@ pub trait Itertools : Iterator { /// The values from this iterator will be used as values for the folding operation /// while the keys will be obtained from the values by calling `key_mapper`. /// - /// See [`GroupingMap`](./structs/struct.GroupingMap.html) for more informations + /// See [`GroupingMap`] for more informations /// on what operations are available. #[cfg(feature = "use_std")] fn into_grouping_map_by(self, key_mapper: F) -> GroupingMapBy @@ -3471,9 +3471,9 @@ pub fn partition<'a, A: 'a, I, F>(iter: I, mut pred: F) -> usize split_index } -/// An enum used for controlling the execution of `.fold_while()`. +/// An enum used for controlling the execution of `fold_while`. /// -/// See [`.fold_while()`](crate::Itertools::fold_while) for more information. +/// See [`.fold_while()`](Itertools::fold_while) for more information. #[derive(Copy, Clone, Debug, Eq, PartialEq)] pub enum FoldWhile { /// Continue folding with this value diff --git a/src/powerset.rs b/src/powerset.rs index ef17752b3..465e1bfa7 100644 --- a/src/powerset.rs +++ b/src/powerset.rs @@ -7,7 +7,7 @@ use super::size_hint; /// An iterator to iterate through the powerset of the elements from an iterator. /// -/// See [`.powerset()`](../trait.Itertools.html#method.powerset) for more +/// See [`.powerset()`](crate::Itertools::powerset) for more /// information. #[must_use = "iterator adaptors are lazy and do nothing unless consumed"] pub struct Powerset { diff --git a/src/process_results_impl.rs b/src/process_results_impl.rs index d74925ade..9da108b15 100644 --- a/src/process_results_impl.rs +++ b/src/process_results_impl.rs @@ -2,7 +2,7 @@ /// An iterator that produces only the `T` values as long as the /// inner iterator produces `Ok(T)`. /// -/// Used by [`process_results`](../fn.process_results.html), see its docs +/// Used by [`process_results`](crate::process_results), see its docs /// for more information. #[must_use = "iterator adaptors are lazy and do nothing unless consumed"] #[derive(Debug)] diff --git a/src/repeatn.rs b/src/repeatn.rs index 8bc485083..176431adb 100644 --- a/src/repeatn.rs +++ b/src/repeatn.rs @@ -1,7 +1,7 @@ /// An iterator that produces *n* repetitions of an element. /// -/// See [`repeat_n()`](../fn.repeat_n.html) for more information. +/// See [`repeat_n()`](crate::repeat_n) for more information. #[must_use = "iterators are lazy and do nothing unless consumed"] #[derive(Clone, Debug)] pub struct RepeatN { diff --git a/src/sources.rs b/src/sources.rs index b4a7bf707..3877ce3c8 100644 --- a/src/sources.rs +++ b/src/sources.rs @@ -5,7 +5,7 @@ use std::fmt; use std::mem; -/// See [`repeat_call`](../fn.repeat_call.html) for more information. +/// See [`repeat_call`](crate::repeat_call) for more information. #[derive(Clone)] #[deprecated(note="Use std repeat_with() instead", since="0.8.0")] pub struct RepeatCall { @@ -112,7 +112,7 @@ impl fmt::Debug for Unfold debug_fmt_fields!(Unfold, state); } -/// See [`unfold`](../fn.unfold.html) for more information. +/// See [`unfold`](crate::unfold) for more information. #[derive(Clone)] #[must_use = "iterators are lazy and do nothing unless consumed"] pub struct Unfold { @@ -134,9 +134,8 @@ impl Iterator for Unfold /// An iterator that infinitely applies function to value and yields results. /// -/// This `struct` is created by the [`iterate()`] function. See its documentation for more. -/// -/// [`iterate()`]: ../fn.iterate.html +/// This `struct` is created by the [`iterate()`](crate::iterate) function. +/// See its documentation for more. #[derive(Clone)] #[must_use = "iterators are lazy and do nothing unless consumed"] pub struct Iterate { From ba7d4e2d3f3a59e0182ef919ec5110718efa7c6a Mon Sep 17 00:00:00 2001 From: Marcin Puc Date: Sun, 2 May 2021 19:15:48 +0200 Subject: [PATCH 4/6] Add missing links --- src/lib.rs | 32 ++++++++++++++++---------------- src/minmax.rs | 5 +++-- 2 files changed, 19 insertions(+), 18 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 2eba67049..4a088c514 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -948,7 +948,7 @@ pub trait Itertools : Iterator { } /// Return an iterator adaptor that merges the two base iterators in order. - /// This is much like `.merge()` but allows for a custom ordering. + /// This is much like [`.merge()`](Itertools::merge) but allows for a custom ordering. /// /// This can be especially useful for sequences of tuples. /// @@ -1935,7 +1935,7 @@ pub trait Itertools : Iterator { concat(self) } - /// `.collect_vec()` is simply a type specialization of `.collect()`, + /// `.collect_vec()` is simply a type specialization of [`Iterator::collect`], /// for convenience. #[cfg(feature = "use_alloc")] fn collect_vec(self) -> Vec @@ -2057,7 +2057,7 @@ pub trait Itertools : Iterator { /// Format all iterator elements, separated by `sep`. /// - /// This is a customizable version of `.format()`. + /// This is a customizable version of [`.format()`](Itertools::format). /// /// The supplied closure `format` is called once per iterator element, /// with two arguments: the element and a callback that takes a @@ -2164,7 +2164,7 @@ pub trait Itertools : Iterator { /// value is returned inside `Some`. Otherwise, the operation terminates /// and returns `None`. No iterator elements are consumed after the `None`. /// - /// This is the `Option` equivalent to `fold_ok`. + /// This is the `Option` equivalent to [`fold_ok`](Itertools::fold_ok). /// /// ``` /// use std::ops::Add; @@ -2318,7 +2318,7 @@ pub trait Itertools : Iterator { /// An iterator method that applies a function, producing a single, final value. /// - /// `fold_while()` is basically equivalent to `fold()` but with additional support for + /// `fold_while()` is basically equivalent to [`Iterator::fold`] but with additional support for /// early exit via short-circuiting. /// /// ``` @@ -2437,7 +2437,7 @@ pub trait Itertools : Iterator { /// Sort all iterator elements into a new iterator in ascending order. /// /// **Note:** This consumes the entire iterator, uses the - /// `slice::sort_unstable()` method and returns the result as a new + /// [`slice::sort_unstable`] method and returns the result as a new /// iterator that owns its elements. /// /// The sorted iterator, if directly collected to a `Vec`, is converted @@ -2466,7 +2466,7 @@ pub trait Itertools : Iterator { /// Sort all iterator elements into a new iterator in ascending order. /// /// **Note:** This consumes the entire iterator, uses the - /// `slice::sort_unstable_by()` method and returns the result as a new + /// [`slice::sort_unstable_by`] method and returns the result as a new /// iterator that owns its elements. /// /// The sorted iterator, if directly collected to a `Vec`, is converted @@ -2499,7 +2499,7 @@ pub trait Itertools : Iterator { /// Sort all iterator elements into a new iterator in ascending order. /// /// **Note:** This consumes the entire iterator, uses the - /// `slice::sort_unstable_by_key()` method and returns the result as a new + /// [`slice::sort_unstable_by_key`] method and returns the result as a new /// iterator that owns its elements. /// /// The sorted iterator, if directly collected to a `Vec`, is converted @@ -2533,7 +2533,7 @@ pub trait Itertools : Iterator { /// Sort all iterator elements into a new iterator in ascending order. /// /// **Note:** This consumes the entire iterator, uses the - /// `slice::sort()` method and returns the result as a new + /// [`slice::sort`] method and returns the result as a new /// iterator that owns its elements. /// /// The sorted iterator, if directly collected to a `Vec`, is converted @@ -2562,7 +2562,7 @@ pub trait Itertools : Iterator { /// Sort all iterator elements into a new iterator in ascending order. /// /// **Note:** This consumes the entire iterator, uses the - /// `slice::sort_by()` method and returns the result as a new + /// [`slice::sort_by`] method and returns the result as a new /// iterator that owns its elements. /// /// The sorted iterator, if directly collected to a `Vec`, is converted @@ -2595,7 +2595,7 @@ pub trait Itertools : Iterator { /// Sort all iterator elements into a new iterator in ascending order. /// /// **Note:** This consumes the entire iterator, uses the - /// `slice::sort_by_key()` method and returns the result as a new + /// [`slice::sort_by_key`] method and returns the result as a new /// iterator that owns its elements. /// /// The sorted iterator, if directly collected to a `Vec`, is converted @@ -2664,7 +2664,7 @@ pub trait Itertools : Iterator { } /// Collect all iterator elements into one of two - /// partitions. Unlike `Iterator::partition`, each partition may + /// partitions. Unlike [`Iterator::partition`], each partition may /// have a distinct type. /// /// ``` @@ -2865,11 +2865,11 @@ pub trait Itertools : Iterator { /// Return the minimum and maximum element of an iterator, as determined by /// the specified function. /// - /// The return value is a variant of [`MinMaxResult`] like for `minmax()`. + /// The return value is a variant of [`MinMaxResult`] like for [`.minmax()`](Itertools::minmax). /// /// For the minimum, the first minimal element is returned. For the maximum, /// the last maximal element wins. This matches the behavior of the standard - /// `Iterator::min()` and `Iterator::max()` methods. + /// [`Iterator::min`] and [`Iterator::max`] methods. /// /// The keys can be floats but no particular result is guaranteed /// if a key is NaN. @@ -2882,11 +2882,11 @@ pub trait Itertools : Iterator { /// Return the minimum and maximum element of an iterator, as determined by /// the specified comparison function. /// - /// The return value is a variant of [`MinMaxResult`] like for `minmax()`. + /// The return value is a variant of [`MinMaxResult`] like for [`.minmax()`](Itertools::minmax). /// /// For the minimum, the first minimal element is returned. For the maximum, /// the last maximal element wins. This matches the behavior of the standard - /// `Iterator::min()` and `Iterator::max()` methods. + /// [`Iterator::min`] and [`Iterator::max`] methods. fn minmax_by(self, mut compare: F) -> MinMaxResult where Self: Sized, F: FnMut(&Self::Item, &Self::Item) -> Ordering { diff --git a/src/minmax.rs b/src/minmax.rs index 38180ef6d..52b2f115d 100644 --- a/src/minmax.rs +++ b/src/minmax.rs @@ -1,6 +1,7 @@ -/// `MinMaxResult` is an enum returned by `minmax`. See `Itertools::minmax()` for -/// more detail. +/// `MinMaxResult` is an enum returned by `minmax`. +/// +/// See [`.minmax()`](crate::Itertools::minmax) for more detail. #[derive(Copy, Clone, PartialEq, Debug)] pub enum MinMaxResult { /// Empty iterator From dcb6f778e8859495e7c79e72493d009afa3861ef Mon Sep 17 00:00:00 2001 From: Marcin Puc Date: Sun, 2 May 2021 19:17:08 +0200 Subject: [PATCH 5/6] Refine links in docs for the chain! macro --- src/lib.rs | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 4a088c514..8d4705a60 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -354,23 +354,20 @@ macro_rules! izip { /// The comma-separated arguments must implement [`IntoIterator`]. /// The final argument may be followed by a trailing comma. /// -/// [`chain`]: https://doc.rust-lang.org/std/iter/trait.Iterator.html#method.chain -/// [`IntoIterator`]: https://doc.rust-lang.org/std/iter/trait.IntoIterator.html +/// [`chain`]: Iterator::chain /// /// # Examples /// -/// [`iter::empty`]: https://doc.rust-lang.org/std/iter/fn.empty.html -/// -/// Empty invocations of `chain!` expand to an invocation of [`iter::empty`]: +/// Empty invocations of `chain!` expand to an invocation of [`std::iter::empty`]: /// ``` -/// # use std::iter; +/// use std::iter; /// use itertools::chain; /// /// let _: iter::Empty<()> = chain!(); /// let _: iter::Empty = chain!(); /// ``` /// -/// Invocations of `chain!` with one argument expand to [`arg.into_iter()`][`IntoIterator`]: +/// Invocations of `chain!` with one argument expand to [`arg.into_iter()`](IntoIterator): /// ``` /// use std::{ops::Range, slice}; /// use itertools::chain; @@ -378,7 +375,7 @@ macro_rules! izip { /// let _: <&[_] as IntoIterator>::IntoIter = chain!(&[2, 3, 4]); /// ``` /// -/// Invocations of `chain!` with multiple arguments [`.into_iter()`][`IntoIterator`] each +/// Invocations of `chain!` with multiple arguments [`.into_iter()`](IntoIterator) each /// argument, and then [`chain`] them together: /// ``` /// use std::{iter::*, ops::Range, slice}; From b883c2c7ac7b98bf693506dd5c512fd0822b1292 Mon Sep 17 00:00:00 2001 From: Marcin Puc Date: Sun, 2 May 2021 19:18:06 +0200 Subject: [PATCH 6/6] Reformat link to the Itertools trait in main doc section --- src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib.rs b/src/lib.rs index 8d4705a60..e4fc044c2 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -5,7 +5,7 @@ //! Extra iterator adaptors, functions and macros. //! //! To extend [`Iterator`] with methods in this crate, import -//! the [`Itertools` trait](Itertools): +//! the [`Itertools`] trait: //! //! ``` //! use itertools::Itertools;