summaryrefslogtreecommitdiff
path: root/tests/codegen/src-hash-algorithm/src-hash-algorithm-sha1.rs
diff options
context:
space:
mode:
authorGunnlaugur Þór Briem <gunnlaugur@gmail.com>2022-07-14 14:41:22 +0000
committerGunnlaugur Þór Briem <gunnlaugur@gmail.com>2022-07-14 14:43:50 +0000
commit1dd207c10f90f490da9396e06228916279c3be7f (patch)
tree92c91fb4ff4ead34013b2b9b842bf71c49d5c1eb /tests/codegen/src-hash-algorithm/src-hash-algorithm-sha1.rs
parentf1a8854f9be2e5cad764d630a53d26c7b72f8162 (diff)
downloadrust-1dd207c10f90f490da9396e06228916279c3be7f.tar.gz
doc: clearer and more correct Iterator::scan
The `Iterator::scan` documentation seemed a little misleading to my newcomer eyes, and this tries to address that. * I found “similar to `fold`” unhelpful because (a) the similarity is only that they maintain state between iterations, and (b) the _dissimilarity_ is no less important: one returns a final value and the other an iterator. So this replaces that with “which, like `fold`, holds internal state, but unlike `fold`, produces a new iterator. * I found “the return value from the closure, an [`Option`], is yielded by the iterator” to be downright incorrect, because “yielded by the iterator” means “returned by the `next` method wrapped in `Some`”, so this implied that `scan` would convert an input iterator of `T` to an output iterator of `Option<T>`. So this replaces “yielded by the iterator” with “returned by the `next` method” and elaborates: “Thus the closure can return `Some(value)` to yield `value`, or `None` to end the iteration.” * This also changes the example to illustrate the latter point by returning `None` to terminate the iteration early based on `state`.
Diffstat (limited to 'tests/codegen/src-hash-algorithm/src-hash-algorithm-sha1.rs')
0 files changed, 0 insertions, 0 deletions