Skip to content

Implement IntoIterator for &mut LinearMap - #692

Open
anyingiit wants to merge 1 commit into
rust-embedded:mainfrom
anyingiit:linear-map-into-iter-mut
Open

anyingiit wants to merge 1 commit into
rust-embedded:mainfrom
anyingiit:linear-map-into-iter-mut

Conversation

@anyingiit

Copy link
Copy Markdown

Description

&LinearMap implements IntoIterator, but &mut LinearMap does not, so for (k, v) in &mut map { ... } fails to compile even though LinearMap::iter_mut() already exists.

This adds impl IntoIterator for &'a mut LinearMapInner<K, V, S> (mirroring the existing &'a LinearMapInner impl), returning the existing IterMut<'a, K, V>. Because it is implemented on LinearMapInner<K, V, S> with S: LinearMapStorage + ?Sized, it covers both &mut LinearMap<K, V, N> and &mut LinearMapView<K, V>. A unit test (linear_map::test::into_iter_mut) exercises both; it fails to compile without the impl. A CHANGELOG entry is added under Unreleased.

Motivation / disclosure: I had some spare AI-assistant quota (Claude Code) and am using it to try to
help projects with open good-first-issues. The change was prepared with Claude Code and verified as listed
below. If it doesn't fit, isn't up to your bar, or you'd simply rather not take it — please feel free to
close it, no hard feelings at all 🙂

Related issue

Closes #492

Checklist

  • Tests pass locally (cargo test --lib → 250 passed; cargo test --doc --features alloc → 197 passed; new test fails to compile without the fix and passes with it; cargo clippy --all-targets --features "alloc,defmt,portable-atomic-critical-section,serde,ufmt,bytes,zeroize,embedded-io-v0.7" (host target) → no warnings; cargo +nightly fmt --all -- --check → clean)
  • CHANGELOG.md is updated (if applicable) — added an entry under [Unreleased]
  • Documentation is updated (if applicable) — n/a (trait impl, shows up in rustdoc automatically)

Allows iterating mutably over a LinearMap (or LinearMapView) with
`for (k, v) in &mut map`, reusing the existing IterMut iterator.

Closes rust-embedded#492
@zeenix
zeenix enabled auto-merge October 2, 2026 10:31
@sgued

sgued commented Oct 6, 2026

Copy link
Copy Markdown
Contributor

Just FIY these kinds of PR sent over the fence for the maintainers to review is pretty rude, especially using a AI generated PR description full of obvious and duplicate text.

The current code of conduct doesn't ban this, but it will likely be the case in the future.

@zeenix

zeenix commented Oct 6, 2026

Copy link
Copy Markdown
Contributor

Just FIY these kinds of PR sent over the fence for the maintainers to review is pretty rude, especially using a AI generated PR description full of obvious and duplicate text.

You're likely wasting your breath. I doubt a person is looking at this. :)


Anyway, I looked at the changes so that you don't have to and they seemed fine and trivial. Hence the approval. I didn't realize there was a conflict after I enabled auto-merge. Given that the contributor didn't bother updating the PR, gives me even more confidence that no human was involved directly here.

This branch has not been deployed

No deployments
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.

&mut LinearMap does not implement IntoIter

3 participants