]> git.lizzy.rs Git - rust.git/commit
Fix doc error for ExactSizeIterator
authorManuel <LifeIsHealthy@icloud.com>
Tue, 21 Mar 2017 21:18:52 +0000 (22:18 +0100)
committerGitHub <noreply@github.com>
Tue, 21 Mar 2017 21:18:52 +0000 (22:18 +0100)
commita8800bb675397e6aa06ffdac46092d5d03e0cf69
tree4eb8edbe9d56dbb2302f9126cc429bb165867e22
parent58c701f5c7dc26d9b55c631006ece52abe1ddce2
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.
src/libcore/iter/traits.rs