Skip to content

exploration: ignoring arrays in method dispatch #84133

Closed
@nikomatsakis

Description

@nikomatsakis

In #65819, we are considering adding an impl of IntoIterator for [T; N] for all N. However, this breaks existing code that relies on method dispatch:

let array = [true; 3];
for x in array.into_iter() {
    let _ = *x; // x is a reference
}

In this code, array.into_iter() winds up unsizing to a slice and hence resolving to <&[bool] as IntoIterator>::into_iter (and thus executing on refs to booleans). This issue describes a possible modification to older Rust editions that would allow us to add the impl without breaking existing code or compromising our edition guarantees.

Metadata

Metadata

Assignees

Labels

A-maybe-future-editionSomething we may consider for a future edition.E-mentorCall for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion.T-langRelevant to the language team, which will review and decide on the PR/issue.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions