Skip to content

Commit 3bf265d

Browse files
authored
Merge pull request #321 from JohnHeitmann/master
Document the trait extension behavior of Itertools a bit more clearly
2 parents 44c9654 + e820996 commit 3bf265d

File tree

1 file changed

+28
-3
lines changed

1 file changed

+28
-3
lines changed

src/lib.rs

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,35 @@
22
#![crate_name="itertools"]
33
#![cfg_attr(not(feature = "use_std"), no_std)]
44

5-
//! Itertools — extra iterator adaptors, functions and macros.
5+
//! Extra iterator adaptors, functions and macros.
66
//!
7-
//! To use the iterator methods in this crate, import the [`Itertools` trait](./trait.Itertools.html):
7+
//! To extend [`Iterator`] with methods in this crate, import
8+
//! the [`Itertools` trait](./trait.Itertools.html):
89
//!
910
//! ```
1011
//! use itertools::Itertools;
1112
//! ```
1213
//!
14+
//! Now, new methods like [`interleave`](./trait.Itertools.html#method.interleave)
15+
//! are available on all Iterators:
16+
//!
17+
//! ```
18+
//! use itertools::Itertools;
19+
//!
20+
//! let it = (1..3).interleave(vec![-1, -2]);
21+
//! itertools::assert_equal(it, vec![1, -1, 2, -2]);
22+
//! ```
23+
//!
24+
//! Most iterator methods are also provided as functions:
25+
//!
26+
//! ```
27+
//! use itertools::interleave;
28+
//!
29+
//! for elt in interleave(&[1, 2, 3], &[2, 3, 4]) {
30+
//! /* loop body */
31+
//! }
32+
//! ```
33+
//!
1334
//! ## Crate Features
1435
//!
1536
//! - `use_std`
@@ -22,6 +43,7 @@
2243
//!
2344
//! This version of itertools requires Rust 1.12 or later.
2445
//!
46+
//! [`Iterator`]: https://doc.rust-lang.org/std/iter/trait.Iterator.html
2547
#![doc(html_root_url="https://docs.rs/itertools/0.7/")]
2648

2749
extern crate either;
@@ -289,7 +311,8 @@ macro_rules! izip {
289311
};
290312
}
291313

292-
/// The trait `Itertools`: extra iterator adaptors and methods for iterators.
314+
/// An [`Iterator`] blanket implementation that provides extra adaptors and
315+
/// methods.
293316
///
294317
/// This trait defines a number of methods. They are divided into two groups:
295318
///
@@ -301,6 +324,8 @@ macro_rules! izip {
301324
/// return a regular value of some other kind.
302325
/// [`.next_tuple()`](#method.next_tuple) is an example and the first regular
303326
/// method in the list.
327+
///
328+
/// [`Iterator`]: https://doc.rust-lang.org/std/iter/trait.Iterator.html
304329
pub trait Itertools : Iterator {
305330
// adaptors
306331

0 commit comments

Comments
 (0)