Skip to content

Conversation

@torressam333
Copy link

Description

This PR adds a small clarification to the Methods That Consume the Iterator section in Chapter 13.

The existing text correctly explains that calling a consuming adapter like sum takes ownership of the iterator and prevents it from being used afterward. However, it does not explicitly state that the underlying collection remains valid when the iterator was created using iter().

This omission can lead readers to incorrectly infer that calling sum also invalidates the original collection. The added paragraph clarifies that:

v1_iter borrows v1

sum consumes the iterator, not the vector

v1 remains usable after the call to sum

A short sentence is added immediately after the existing explanation to make this distinction explicit, without introducing new concepts or changing the structure of the section.

Scope

  • Changes are limited to the src directory
  • No changes to nostarch
  • No formatting changes beyond the edited paragraph

Notes

I understand that non-error changes may be deferred to a larger revision. This PR is submitted in case the clarification is considered a small correctness improvement appropriate to include earlier.

Thank you for your time and for maintaining the book.

Clarify that consuming adapters consume the iterator, not the underlying collection.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

1 participant