Skip to content

Add IntoIterator impls for VecM by value and ref#514

Open
leighmcculloch wants to merge 1 commit intomainfrom
vecm-into-iterator-impls
Open

Add IntoIterator impls for VecM by value and ref#514
leighmcculloch wants to merge 1 commit intomainfrom
vecm-into-iterator-impls

Conversation

@leighmcculloch
Copy link
Member

@leighmcculloch leighmcculloch commented Mar 16, 2026

What

Add two IntoIterator implementations for VecM<T, MAX>: one that consumes the value (gated on the alloc feature, delegating to the inner Vec's iterator), and one for shared references (returning a core::slice::Iter). The impls are added to the generator header and both generated files (curr and next). Tests cover owned iteration, reference iteration, and for loop usage.

Why

VecM previously only implemented IntoIterator for &mut VecM, leaving for item in vecm and for item in &vecm unsupported. Callers had to call .iter() explicitly or dereference to a slice, which was inconsistent with standard Rust collection ergonomics.

Close #459

@leighmcculloch leighmcculloch marked this pull request as ready for review March 16, 2026 03:36
Copilot AI review requested due to automatic review settings March 16, 2026 03:36
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds missing Rust-idiomatic iteration support for VecM<T, MAX> to match standard collection ergonomics and address #459.

Changes:

  • Implement IntoIterator for VecM<T, MAX> by value under alloc (delegates to inner Vec<T> iterator).
  • Implement IntoIterator for &VecM<T, MAX> (returns core::slice::Iter).
  • Add integration tests covering owned iteration, reference iteration, and for loop usage.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.

File Description
xdr-generator/generator/header.rs Adds the new IntoIterator impls to the generator header so future regeneration includes them.
src/curr/generated.rs Applies the new IntoIterator impls to the current XDR channel generated output.
src/next/generated.rs Applies the new IntoIterator impls to the next XDR channel generated output.
tests/vecm.rs Adds tests validating both owned and shared-ref iteration behavior and for loop support.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Impl IntoIterator for VecM

2 participants