rust/library/core/src/iter
Guillaume Gomez 931735a1b1
Rollup merge of #139780 - ongardie:iterator-take-by_ref-example, r=workingjubilee
docs: Add example to `Iterator::take` with `by_ref`

If you want to logically split an iterator after `n` items, you might first discover `take`. Before this change, you'd find that `take` consumes the iterator, and you'd probably be stuck. The answer involves `by_ref`, but that's hard to discover, especially since `by_ref` is a bit abstract and `Iterator` has many methods.

After this change, you'd see the example showing `take` along with `by_ref`, which allows you to continue using the rest of the iterator. `by_ref` had a good example involving `take` already, so this change just duplicates that existing example under `take`.
2025-05-01 22:27:20 +02:00
..
adapters Rollup merge of #139090 - yotamofek:pr/peekable-next-if-docs, r=tgross35 2025-04-27 11:54:58 +02:00
sources core: optimize RepeatN 2025-03-22 13:35:46 +01:00
traits docs: Add example to Iterator::take with by_ref 2025-04-13 19:52:34 -07:00
mod.rs re-export core::iter::FromCoroutine 2025-01-18 16:35:54 +01:00
range.rs distinguish overflow and unimplemented in Step::steps_between 2024-11-21 15:49:55 -08:00
sources.rs re-export core::iter::FromCoroutine 2025-01-18 16:35:54 +01:00