summary refs log tree commit diff
path: root/src/libcore/iter
AgeCommit message (Collapse)AuthorLines
2017-04-15code formatking6cong-5/+5
2017-04-11Clarify Iterator::position docSebastian Hahn-2/+6
Extend the example a little bit to show behaviour better.
2017-04-03iter: Simplification in rfind's provided implementationUlrik Sverdrup-1/+1
- Prefer simpler constructs instead of going through &mut I's Iterator implementation.
2017-04-03iter: Use underlying find/rfind for the same methods in RevUlrik Sverdrup-0/+12
2017-03-23Rollup merge of #40715 - manuel-rhdt:patch-1, r=brsonCorey Farwell-3/+3
Fix doc error for ExactSizeIterator The code example in the trait documentation of ExactSizeIterator has an incorrect implementation of the len method that does not return the number of times the example iterator 'Counter' will iterate. This may confuse readers of the docs as the example code will compile but doesn't uphold the trait's contract. This is easily fixed by modifying the implementation of len and changing the assert statement to actually assert the correct behaviour. I also slightly modified a code comment to better reflect what the method returns.
2017-03-21Fix doc error for ExactSizeIteratorManuel-3/+3
The code example in the trait documentation of ExactSizeIterator has an incorrect implementation of the len method that does not return the number of times the example iterator 'Counter' will iterate. This may confuse readers of the docs as the example code will compile but doesn't uphold the trait's contract. This is easily fixed by modifying the implementation of len and changing the assert statement to actually assert the correct behaviour. I also slightly modified a code comment to better reflect what the method returns.
2017-03-21Fix invalid linking in iter docsGuillaume Gomez-3/+3
2017-03-20Fix up various linkssteveklabnik-2/+2
The unstable book, libstd, libcore, and liballoc all needed some adjustment.
2017-03-17Rollup merge of #40456 - frewsxcv:frewsxcv-docs-function-parens, ↵Corey Farwell-128/+128
r=GuillaumeGomez Remove function invokation parens from documentation links. This was never established as a convention we should follow in the 'More API Documentation Conventions' RFC: https://github.com/rust-lang/rfcs/blob/master/text/1574-more-api-documentation-conventions.md
2017-03-13Remove function invokation parens from documentation links.Corey Farwell-128/+128
This was never established as a convention we should follow in the 'More API Documentation Conventions' RFC: https://github.com/rust-lang/rfcs/blob/master/text/1574-more-api-documentation-conventions.md
2017-03-13Fix a typo in Rev docsStjepan Glavina-1/+1
2017-02-19Docs: Better explanation of return values for min, max functionsMikhail Pak-6/+22
Explain that a None is returned if the iterator is empty.
2017-02-17code order tweakking6cong-3/+3
2017-02-10iterator docs: Move paragraph about discarding; clarify "consumed"Rob Speer-5/+5
2017-02-10Rephrase my proposed edit ("objects" -> "elements")Rob Speer-1/+1
2017-02-10Fix a misleading statement in `Iterator.nth()`Rob Speer-1/+4
The `Iterator.nth()` documentation says "Note that all preceding elements will be consumed". I assumed from that that the preceding elements would be the *only* ones that were consumed, but in fact the returned element is consumed as well. The way I read the documentation, I assumed that `nth(0)` would not discard anything (as there are 0 preceding elements), so I added a sentence clarifying that it does. I also rephrased it to avoid the stunted "i.e." phrasing.
2017-02-05Rollup merge of #39393 - ollie27:stab_impls, r=alexcrichtonCorey Farwell-7/+11
Fix a few impl stability attributes The versions show up in rustdoc.
2017-02-05Rollup merge of #39107 - llogiq:branchless_filter_count, r=alexcrichtonCorey Farwell-1/+21
branchless .filter(_).count() I found that the branchless version is only slower if we have little to no branch misses, which usually isn't the case. I notice speedups between -5% (perfect prediction) and 60% (real world data).
2017-02-04Auto merge of #39399 - clarcharr:iter_rfind, r=alexcrichtonbors-0/+58
Add Iterator::rfind. I found it weird that `Iterator` has `rpostition` but not `rfind`. This adds that method.
2017-02-03Bump version, upgrade bootstrapAlex Crichton-1/+0
This commit updates the version number to 1.17.0 as we're not on that version of the nightly compiler, and at the same time this updates src/stage0.txt to bootstrap from freshly minted beta compiler and beta Cargo.
2017-02-03Move rfind to DoubleEndedIterator, add tracking issue.Clar Charr-58/+58
2017-01-29Add Iterator::rfind.Clar Charr-0/+58
2017-01-29Fix a few impl stability attributesOliver Middleton-7/+11
The versions show up in rustdoc.
2017-01-27Fix a few links in the docsOliver Middleton-3/+3
2017-01-24add explanation, fix testAndre Bogus-0/+11
2017-01-17fix style nitsAndre Bogus-7/+6
2017-01-16branchless .filter(_).count()Andre Bogus-0/+10
2017-01-13Rollup merge of #38995 - petrochenkov:minmax, r=GuillaumeGomezGuillaume Gomez-10/+10
Fix docs for min/max algorithms I thought at first "what did they think about when stabilizing this!?", but it turned out it's just wrong docs. Phew. r? @steveklabnik Test: ``` use std::cmp::Ordering; struct S(u8, u8); impl PartialEq for S { fn eq(&self, other: &Self) -> bool { self.0 == other.0 } } impl PartialOrd for S { fn partial_cmp(&self, other: &Self) -> Option<Ordering> { Some(self.0.cmp(&other.0)) } } impl Ord for S { fn cmp(&self, other: &Self) -> Ordering { self.0.cmp(&other.0) } } fn main() { let arr = [S(0, 1), S(0, 2)]; println!("min {:?}", arr.iter().min()); println!("min_by {:?}", arr.iter().min_by(|x, y| x.0.cmp(&y.0))); println!("min_by_key {:?}", arr.iter().min_by_key(|x| x.0)); println!("max {:?}", arr.iter().max()); println!("max_by {:?}", arr.iter().max_by(|x, y| x.0.cmp(&y.0))); println!("max_by_key {:?}", arr.iter().max_by_key(|x| x.0)); } ``` Output: ``` rustc 1.15.0-beta.3 (a035041ba 2017-01-07) min Some(S(0, 1)) min_by Some(S(0, 1)) min_by_key Some(S(0, 1)) max Some(S(0, 2)) max_by Some(S(0, 2)) max_by_key Some(S(0, 2)) ```
2017-01-13Rollup merge of #38636 - shahn:extend, r=steveklabnikGuillaume Gomez-1/+4
Clarify Extend behaviour wrt existing keys This seems to be consistent with all the Extend implementations I found, and isn't documented anywhere else afaik.
2017-01-11Fix docs for min/max algorithmsVadim Petrochenkov-10/+10
2017-01-10Implement `iter::Sum` and `iter::Product` for `Result`Jake Goulding-0/+81
This introduces a private iterator adapter `ResultShunt`, which allows treating an iterator of `Result<T, E>` as an iterator of `T`.
2017-01-05For Extend, document collections allowing duplicate keysSebastian Hahn-1/+3
2017-01-01Auto merge of #38713 - clarcharr:trusted_len, r=brsonbors-1/+7
TrustedLen for Empty and Once. These implementations were missing, so, I went ahead and added them.
2016-12-30TrustedLen for Empty and Once.Clar Charr-1/+7
2016-12-30impl Step for iu128Simonas Kazlauskas-0/+2
Also fix the leb128 tests
2016-12-27Clarify Extend behaviour wrt existing keysSebastian Hahn-1/+2
2016-12-16Address falloutAaron Turon-2/+0
2016-12-15Stabilize Iterator::{min_by, max_by}Aaron Turon-2/+2
2016-12-07Auto merge of #38149 - bluss:is-empty, r=alexcrichtonbors-1/+8
Forward more ExactSizeIterator methods and `is_empty` edits - Forward ExactSizeIterator methods in more places, like `&mut I` and `Box<I>` iterator impls. - Improve `VecDeque::is_empty` itself (see commit 4) - All the collections iterators now have `len` or `is_empty` forwarded if doing so is a benefit. In the remaining cases, they already use a simple size hint (using something like a stored `usize` value), which is sufficient for the default implementation of len and is_empty.
2016-12-07Auto merge of #38134 - bluss:iter-nth, r=aturonbors-1/+4
Remove Self: Sized from Iterator::nth It is an unnecessary restriction; nth neither needs self to be sized nor needs to be exempted from the trait object. It increases the utility of the nth method, because type specific implementations are available through `&mut I` or through an iterator trait object. It is a backwards compatible change due to the special cases of the `where Self: Sized` bound; it was already optional to include this bound in `Iterator` implementations.
2016-12-04iter: Forward ExactSizeIterator methods for &mut IUlrik Sverdrup-1/+8
2016-12-02core: Remove Self: Sized from Iterator::nthUlrik Sverdrup-1/+4
It is an unnecessary restriction; nth neither needs self to be sized nor needs to be exempted from the trait object. It increases the utility of the nth method, because type specific implementations are available through `&mut I` or through an iterator trait object. It is a backwards compatible change due to the special cases of the `where Self: Sized` bound; it was already optional to include this bound in `Iterator` implementations.
2016-11-26Rollup merge of #37963 - bluss:iterator-docs, r=alexcrichtonSeo Sanghyeon-4/+4
Fix two small issues in iterator docs - `collect()` is a regular method, not an adaptor (does not return an Iterator). I just randomly picked `filter` as a third common adaptor to mention instead. - Fix example in `Map`'s docs so that it uses the DoubleEndedIterator implementation
2016-11-24Auto merge of #37944 - bluss:adaptors-are-empty, r=alexcrichtonbors-6/+57
Forward ExactSizeIterator::len and is_empty for important iterator adaptors Forward ExactSizeIterator::len and is_empty for important iterator adaptors Because some iterators will provide improved version of len and/or is_empty, adaptors should forward to those implementations if possible.
2016-11-23core: Fix example for .map()Ulrik Sverdrup-1/+1
Make the example use DoubleEndedIterator for map, like it said it would.
2016-11-23core: Iterator docs, collect is not an adaptorUlrik Sverdrup-3/+3
2016-11-22core: Forward ExactSizeIterator methods for important iterator adaptorsUlrik Sverdrup-6/+57
2016-11-17core::iter: Peekable should remember peeking a NoneUlrik Sverdrup-23/+41
Peekable must remember if a None has been seen in the `.peek()` method. It ensures that `.peek(); .peek();` or `.peek(); .next();` only advances the underlying iterator at most once. This does not by itself make the iterator fused.
2016-11-12Rollup merge of #37669 - GuillaumeGomez:always_urls, r=brsonEduard-Mihai Burtescu-7/+15
Add missing urls for FusedIterator and TrustedLen traits r? @steveklabnik
2016-11-10Add missing urls for FusedIterator and TrustedLen traitsGuillaume Gomez-7/+15