Use KwArgs newtype struct#8120
Conversation
📝 WalkthroughWalkthrough
ChangesKwArgs newtype and FuncArgs migration
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
crates/vm/src/function/argument.rs (1)
452-467: Add the mutable by-reference iterator variant for API completeness.The newtype preserves owned iteration and
for ... in &kwargs, but not the previousIndexMappatternfor ... in &mut kwargs. WhileDerefMutprovides mutable access to the underlying map, it does not automatically enableIntoIteratordesugaring for&mut KwArgs<T>. AddingIntoIterator for &mut KwArgs<T>restores compatibility with the prior iteration pattern.♻️ Proposed iterator completion
impl<'a, T> IntoIterator for &'a KwArgs<T> { type Item = (&'a String, &'a T); type IntoIter = indexmap::map::Iter<'a, String, T>; fn into_iter(self) -> Self::IntoIter { self.0.iter() } } +impl<'a, T> IntoIterator for &'a mut KwArgs<T> { + type Item = (&'a String, &'a mut T); + type IntoIter = indexmap::map::IterMut<'a, String, T>; + + fn into_iter(self) -> Self::IntoIter { + self.0.iter_mut() + } +} + impl<T> IntoIterator for KwArgs<T> { type Item = (String, T); type IntoIter = indexmap::map::IntoIter<String, T>;🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@crates/vm/src/function/argument.rs` around lines 452 - 467, The KwArgs type currently has IntoIterator implementations for immutable references and owned values, but is missing the mutable by-reference variant. Add a third IntoIterator implementation for &'a mut KwArgs<T> that returns an iterator over mutable references to the key-value pairs from the underlying IndexMap. This should follow the same pattern as the existing implementations, delegating to self.0.iter_mut() to provide iteration over mutable references while maintaining API compatibility with the previous IndexMap iteration pattern.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@crates/vm/src/function/argument.rs`:
- Around line 452-467: The KwArgs type currently has IntoIterator
implementations for immutable references and owned values, but is missing the
mutable by-reference variant. Add a third IntoIterator implementation for &'a
mut KwArgs<T> that returns an iterator over mutable references to the key-value
pairs from the underlying IndexMap. This should follow the same pattern as the
existing implementations, delegating to self.0.iter_mut() to provide iteration
over mutable references while maintaining API compatibility with the previous
IndexMap iteration pattern.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yml
Review profile: CHILL
Plan: Pro
Run ID: c968e56d-243c-4f0d-b125-a9bfac09ab58
📒 Files selected for processing (3)
crates/vm/src/frame.rscrates/vm/src/function/argument.rscrates/vm/src/stdlib/_operator.rs
Summary
Summary by CodeRabbit