diff options
| author | bors <bors@rust-lang.org> | 2017-09-21 23:44:11 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2017-09-21 23:44:11 +0000 |
| commit | 17600c1ea77ad8709ea072ad1b258bf9398b9d38 (patch) | |
| tree | c422cfcca0b9f5e27f0475979dc3a408822a82b0 /src/libcore/iter/iterator.rs | |
| parent | 17f56c549c35bb2cb316e5abff116e65277c7bb1 (diff) | |
| parent | 41a42263dffdfed9076029a3db973e1efad5f792 (diff) | |
Auto merge of #44682 - bluss:iter-rfold, r=dtolnay
Add iterator method .rfold(init, function); the reverse of fold rfold is the reverse version of fold. Fold allows iterators to implement a different (non-resumable) internal iteration when it is more efficient than the external iteration implemented through the next method. (Common examples are VecDeque and .chain()). Introduce rfold() so that the same customization is available for reverse iteration. This is achieved by both adding the method, and by having the Rev\<I> adaptor connect Rev::rfold → I::fold and Rev::fold → I::rfold. On the surface, rfold(..) is just .rev().fold(..), but the special case implementations allow a data structure specific fold to be used through for example .iter().rev(); we thus have gains even for users never calling exactly rfold themselves.
Diffstat (limited to 'src/libcore/iter/iterator.rs')
| -rw-r--r-- | src/libcore/iter/iterator.rs | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/libcore/iter/iterator.rs b/src/libcore/iter/iterator.rs index edafd0ce2c2..36bf9633b4a 100644 --- a/src/libcore/iter/iterator.rs +++ b/src/libcore/iter/iterator.rs @@ -1337,7 +1337,7 @@ pub trait Iterator { (left, right) } - /// An iterator adaptor that applies a function, producing a single, final value. + /// An iterator method that applies a function, producing a single, final value. /// /// `fold()` takes two arguments: an initial value, and a closure with two /// arguments: an 'accumulator', and an element. The closure returns the value that |
