Skip to content

Commit e1f24ba

Browse files
Merge #539
539: Refine intra-doc links r=jswrenn a=tranzystorek-io A few changes to make documenting code with links simpler and more uniform. Highlights: - Make some common stdlib traits into links, e.g. `IntoIterator` - Add links to docs for free functions - Use module paths uniformly in links (instead of html paths) - Link to `slice::sort*` methods in docs for sorting functions Co-authored-by: Marcin Puc <marcin.e.puc@gmail.com>
2 parents a33134e + b883c2c commit e1f24ba

18 files changed

+80
-87
lines changed

src/adaptors/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ pub struct Interleave<I, J> {
3535

3636
/// Create an iterator that interleaves elements in `i` and `j`.
3737
///
38-
/// `IntoIterator` enabled version of `i.interleave(j)`.
38+
/// [`IntoIterator`] enabled version of `i.interleave(j)`.
3939
///
4040
/// See [`.interleave()`](crate::Itertools::interleave) for more information.
4141
pub fn interleave<I, J>(i: I, j: J) -> Interleave<<I as IntoIterator>::IntoIter, <J as IntoIterator>::IntoIter>
@@ -492,7 +492,7 @@ pub type Merge<I, J> = MergeBy<I, J, MergeLte>;
492492

493493
/// Create an iterator that merges elements in `i` and `j`.
494494
///
495-
/// `IntoIterator` enabled version of `i.merge(j)`.
495+
/// [`IntoIterator`] enabled version of [`Itertools::merge`](crate::Itertools::merge).
496496
///
497497
/// ```
498498
/// use itertools::merge;

src/combinations.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,7 @@ impl<I: Iterator> Combinations<I> {
4848
pub fn k(&self) -> usize { self.indices.len() }
4949

5050
/// Returns the (current) length of the pool from which combination elements are
51-
/// selected. This value can change between invocations of [`next`].
52-
///
53-
/// [`next`]: #method.next
51+
/// selected. This value can change between invocations of [`next`](Combinations::next).
5452
#[inline]
5553
pub fn n(&self) -> usize { self.pool.len() }
5654

src/concat_impl.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
use crate::Itertools;
22

3-
/// Combine all an iterator's elements into one element by using `Extend`.
3+
/// Combine all an iterator's elements into one element by using [`Extend`].
44
///
5-
/// `IntoIterator`-enabled version of `.concat()`
5+
/// [`IntoIterator`]-enabled version of [`Itertools::concat`].
66
///
77
/// This combinator will extend the first item with each of the rest of the
88
/// items of the iterator. If the iterator is empty, the default value of

src/diff.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ pub enum Diff<I, J>
2626
}
2727

2828
/// Compares every element yielded by both `i` and `j` with the given function in lock-step and
29-
/// returns a `Diff` which describes how `j` differs from `i`.
29+
/// returns a [`Diff`] which describes how `j` differs from `i`.
3030
///
3131
/// If the number of elements yielded by `j` is less than the number of elements yielded by `i`,
3232
/// the number of `j` elements yielded will be returned along with `i`'s remaining elements as

src/duplicates_impl.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ mod private {
176176

177177
/// An iterator adapter to filter for duplicate elements.
178178
///
179-
/// See [`.duplicates_by()`](../trait.Itertools.html#method.duplicates_by) for more information.
179+
/// See [`.duplicates_by()`](crate::Itertools::duplicates_by) for more information.
180180
#[must_use = "iterator adaptors are lazy and do nothing unless consumed"]
181181
pub type DuplicatesBy<I, V, F> = private::DuplicatesBy<I, V, private::ByFn<F>>;
182182

@@ -192,7 +192,7 @@ where
192192

193193
/// An iterator adapter to filter out duplicate elements.
194194
///
195-
/// See [`.duplicates()`](../trait.Itertools.html#method.duplicates) for more information.
195+
/// See [`.duplicates()`](crate::Itertools::duplicates) for more information.
196196
pub type Duplicates<I> = private::DuplicatesBy<I, <I as Iterator>::Item, private::ById>;
197197

198198
/// Create a new `Duplicates` iterator.

src/either_or_both.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ impl<A, B> EitherOrBoth<A, B> {
2525
}
2626

2727
/// If Left, return true otherwise, return false.
28-
/// Exclusive version of [`has_left`](Self::has_left).
28+
/// Exclusive version of [`has_left`](EitherOrBoth::has_left).
2929
pub fn is_left(&self) -> bool {
3030
match *self {
3131
Left(_) => true,
@@ -34,7 +34,7 @@ impl<A, B> EitherOrBoth<A, B> {
3434
}
3535

3636
/// If Right, return true otherwise, return false.
37-
/// Exclusive version of [`has_right`](Self::has_right).
37+
/// Exclusive version of [`has_right`](EitherOrBoth::has_right).
3838
pub fn is_right(&self) -> bool {
3939
match *self {
4040
Right(_) => true,

src/free.rs

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//! Free functions that create iterator adaptors or call iterator methods.
22
//!
3-
//! The benefit of free functions is that they accept any `IntoIterator` as
3+
//! The benefit of free functions is that they accept any [`IntoIterator`] as
44
//! argument, so the resulting code may be easier to read.
55
66
#[cfg(feature = "use_alloc")]
@@ -37,7 +37,7 @@ pub use crate::rciter_impl::rciter;
3737

3838
/// Iterate `iterable` with a running index.
3939
///
40-
/// `IntoIterator` enabled version of `.enumerate()`.
40+
/// [`IntoIterator`] enabled version of [`Iterator::enumerate`].
4141
///
4242
/// ```
4343
/// use itertools::enumerate;
@@ -54,7 +54,7 @@ pub fn enumerate<I>(iterable: I) -> iter::Enumerate<I::IntoIter>
5454

5555
/// Iterate `iterable` in reverse.
5656
///
57-
/// `IntoIterator` enabled version of `.rev()`.
57+
/// [`IntoIterator`] enabled version of [`Iterator::rev`].
5858
///
5959
/// ```
6060
/// use itertools::rev;
@@ -72,7 +72,7 @@ pub fn rev<I>(iterable: I) -> iter::Rev<I::IntoIter>
7272

7373
/// Iterate `i` and `j` in lock step.
7474
///
75-
/// `IntoIterator` enabled version of `i.zip(j)`.
75+
/// [`IntoIterator`] enabled version of [`Iterator::zip`].
7676
///
7777
/// ```
7878
/// use itertools::zip;
@@ -91,7 +91,7 @@ pub fn zip<I, J>(i: I, j: J) -> Zip<I::IntoIter, J::IntoIter>
9191

9292
/// Create an iterator that first iterates `i` and then `j`.
9393
///
94-
/// `IntoIterator` enabled version of `i.chain(j)`.
94+
/// [`IntoIterator`] enabled version of [`Iterator::chain`].
9595
///
9696
/// ```
9797
/// use itertools::chain;
@@ -109,7 +109,7 @@ pub fn chain<I, J>(i: I, j: J) -> iter::Chain<<I as IntoIterator>::IntoIter, <J
109109

110110
/// Create an iterator that clones each element from &T to T
111111
///
112-
/// `IntoIterator` enabled version of `i.cloned()`.
112+
/// [`IntoIterator`] enabled version of [`Iterator::cloned`].
113113
///
114114
/// ```
115115
/// use itertools::cloned;
@@ -125,7 +125,7 @@ pub fn cloned<'a, I, T: 'a>(iterable: I) -> iter::Cloned<I::IntoIter>
125125

126126
/// Perform a fold operation over the iterable.
127127
///
128-
/// `IntoIterator` enabled version of `i.fold(init, f)`
128+
/// [`IntoIterator`] enabled version of [`Iterator::fold`].
129129
///
130130
/// ```
131131
/// use itertools::fold;
@@ -141,7 +141,7 @@ pub fn fold<I, B, F>(iterable: I, init: B, f: F) -> B
141141

142142
/// Test whether the predicate holds for all elements in the iterable.
143143
///
144-
/// `IntoIterator` enabled version of `i.all(f)`
144+
/// [`IntoIterator`] enabled version of [`Iterator::all`].
145145
///
146146
/// ```
147147
/// use itertools::all;
@@ -157,7 +157,7 @@ pub fn all<I, F>(iterable: I, f: F) -> bool
157157

158158
/// Test whether the predicate holds for any elements in the iterable.
159159
///
160-
/// `IntoIterator` enabled version of `i.any(f)`
160+
/// [`IntoIterator`] enabled version of [`Iterator::any`].
161161
///
162162
/// ```
163163
/// use itertools::any;
@@ -173,7 +173,7 @@ pub fn any<I, F>(iterable: I, f: F) -> bool
173173

174174
/// Return the maximum value of the iterable.
175175
///
176-
/// `IntoIterator` enabled version of `i.max()`.
176+
/// [`IntoIterator`] enabled version of [`Iterator::max`].
177177
///
178178
/// ```
179179
/// use itertools::max;
@@ -189,7 +189,7 @@ pub fn max<I>(iterable: I) -> Option<I::Item>
189189

190190
/// Return the minimum value of the iterable.
191191
///
192-
/// `IntoIterator` enabled version of `i.min()`.
192+
/// [`IntoIterator`] enabled version of [`Iterator::min`].
193193
///
194194
/// ```
195195
/// use itertools::min;
@@ -206,7 +206,7 @@ pub fn min<I>(iterable: I) -> Option<I::Item>
206206

207207
/// Combine all iterator elements into one String, seperated by `sep`.
208208
///
209-
/// `IntoIterator` enabled version of `iterable.join(sep)`.
209+
/// [`IntoIterator`] enabled version of [`Itertools::join`].
210210
///
211211
/// ```
212212
/// use itertools::join;
@@ -223,9 +223,7 @@ pub fn join<I>(iterable: I, sep: &str) -> String
223223

224224
/// Sort all iterator elements into a new iterator in ascending order.
225225
///
226-
/// `IntoIterator` enabled version of [`iterable.sorted()`][1].
227-
///
228-
/// [1]: crate::Itertools::sorted
226+
/// [`IntoIterator`] enabled version of [`Itertools::sorted`].
229227
///
230228
/// ```
231229
/// use itertools::sorted;

src/groupbylazy.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ impl<K, I, F> GroupInner<K, I, F>
279279
/// no allocations. It needs allocations only if several group iterators
280280
/// are alive at the same time.
281281
///
282-
/// This type implements `IntoIterator` (it is **not** an iterator
282+
/// This type implements [`IntoIterator`] (it is **not** an iterator
283283
/// itself), because the group iterators need to borrow from this
284284
/// value. It should be stored in a local variable or temporary and
285285
/// iterated.
@@ -453,7 +453,7 @@ pub fn new_chunks<J>(iter: J, size: usize) -> IntoChunks<J::IntoIter>
453453
/// `IntoChunks` behaves just like `GroupBy`: it is iterable, and
454454
/// it only buffers if several chunk iterators are alive at the same time.
455455
///
456-
/// This type implements `IntoIterator` (it is **not** an iterator
456+
/// This type implements [`IntoIterator`] (it is **not** an iterator
457457
/// itself), because the chunk iterators need to borrow from this
458458
/// value. It should be stored in a local variable or temporary and
459459
/// iterated.

src/grouping_map.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use std::hash::Hash;
77
use std::iter::Iterator;
88
use std::ops::{Add, Mul};
99

10-
/// A wrapper to allow for an easy [`into_grouping_map_by`](../trait.Itertools.html#method.into_grouping_map_by)
10+
/// A wrapper to allow for an easy [`into_grouping_map_by`](crate::Itertools::into_grouping_map_by)
1111
#[derive(Clone, Debug)]
1212
pub struct MapForGrouping<I, F>(I, F);
1313

@@ -38,7 +38,7 @@ pub fn new<I, K, V>(iter: I) -> GroupingMap<I>
3838

3939
/// `GroupingMapBy` is an intermediate struct for efficient group-and-fold operations.
4040
///
41-
/// See [`GroupingMap`](./struct.GroupingMap.html) for more informations.
41+
/// See [`GroupingMap`] for more informations.
4242
#[must_use = "GroupingMapBy is lazy and do nothing unless consumed"]
4343
pub type GroupingMapBy<I, F> = GroupingMap<MapForGrouping<I, F>>;
4444

@@ -377,7 +377,7 @@ impl<I, K, V> GroupingMap<I>
377377
/// If several elements are equally maximum, the last element is picked.
378378
/// If several elements are equally minimum, the first element is picked.
379379
///
380-
/// See [.minmax()](../trait.Itertools.html#method.minmax) for the non-grouping version.
380+
/// See [.minmax()](crate::Itertools::minmax) for the non-grouping version.
381381
///
382382
/// Differences from the non grouping version:
383383
/// - It never produces a `MinMaxResult::NoElements`

0 commit comments

Comments
 (0)