Skip to content

Commit b40b06b

Browse files
kornelskiphimuemue
authored andcommitted
Draw attention to Position::Only in docs
1 parent f26119e commit b40b06b

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1948,7 +1948,7 @@ pub trait Itertools: Iterator {
19481948
}
19491949

19501950
/// Return an iterator adaptor that combines each element with a `Position` to
1951-
/// ease special-case handling of the first or last elements.
1951+
/// ease special-case handling of the first, last, or [singular](Position::Only) elements.
19521952
///
19531953
/// Iterator element type is
19541954
/// [`(Position, Self::Item)`](Position)

src/with_position.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,14 +45,17 @@ where
4545
/// The first component of the value yielded by `WithPosition`.
4646
/// Indicates the position of this element in the iterator results.
4747
///
48+
/// When handling the first or last position,
49+
/// remember to consider the special case of [`Position::Only`].
50+
///
4851
/// See [`.with_position()`](crate::Itertools::with_position) for more information.
4952
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
5053
pub enum Position {
51-
/// This is the first element.
54+
/// This is the first element, and there is more than one element.
5255
First,
5356
/// This is neither the first nor the last element.
5457
Middle,
55-
/// This is the last element.
58+
/// This is the last element, and there was more than one element.
5659
Last,
5760
/// This is the only element.
5861
Only,

0 commit comments

Comments
 (0)