reference icon indicating copy to clipboard operation
reference copied to clipboard

Mention `IntoIterator` special case for `Box<[T]>` for pre-Rust 2024 editions

Open xinyufort opened this issue 9 months ago • 2 comments

Apologies if this has already been raised elsewhere, or if this is a non-issue.

I noticed that the current reference, under the section for "Method call expressions," only mentions the edition-specific handling of the into_iter() method call stemming from the introduction of IntoIterator trait for arrays. (Here is the link to the relevant PR that updated the Reference.)

Now that there's a similar change in Rust 2024 (as per this page on the Edition Guide), perhaps the Reference needs to be updated again? Specifically, I'm referring to this section:

However, this would normally be a breaking change because existing code that manually called .into_iter() on a boxed slice would change from having an iterator over references to an iterator over values. To resolve this problem, method calls of .into_iter() on boxed slices have edition-dependent behavior. In editions before 2024, it continues to return an iterator over references, and starting in Edition 2024 it returns an iterator over values.

If needed, I can help open a PR for this.


For what it's worth, I see that on the tracking issue for adding IntoIterator for Box<[T]> in Rust 2024, the step "Add documentation to the reference" is marked as "N/A." I don't know if that was intentional or not.

xinyufort avatar Feb 25 '25 00:02 xinyufort

Thanks for the report! I vaguely recall discussing this, but don't remember why we skipped it. Looks like it should probably be included, though.

ehuss avatar Feb 25 '25 16:02 ehuss

Hey, apologies for going cold here.

@ehuss (or others) -- would you like me to open a PR for this?

xinyufort avatar Apr 10 '25 22:04 xinyufort