Fix implicit BTreeMap clones on Attributes::into_iter - #2518
Open
john-h-kastner-aws wants to merge 3 commits into
Open
Fix implicit BTreeMap clones on Attributes::into_iter#2518john-h-kastner-aws wants to merge 3 commits into
Attributes::into_iter#2518john-h-kastner-aws wants to merge 3 commits into
Conversation
Signed-off-by: jkastner <jkastner@amazon.com>
whonore
approved these changes
Aug 13, 2026
victornicolet
approved these changes
Aug 14, 2026
Signed-off-by: jkastner <jkastner@amazon.com>
Coverage ReportHead Commit: Base Commit: Download the full coverage report. Coverage of Added or Modified Lines of Rust CodeRequired coverage: 80.00% Actual coverage: 88.00% Status: PASSED ✅ Details
Coverage of All Lines of Rust CodeRequired coverage: 80.00% Actual coverage: 88.36% Status: PASSED ✅ Details
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description of changes
The
IntoIterimplementation forAttributes, wasself.attrs.as_ref().clone().into_iter()whereself.attrsis anArc<BTreeMap<_, _>>, so the whole map (not theArc) was cloned on everyinto_itercall.Since the type wraps an
Arc, it can't meaningfully implementIntoIterother than by cloning the iter elements (which would be better than the current implementations), but It's preferable to have callers explicitly calliter().cloned()if they need owned elements, so I've removed theIntoIterimplementation entirely.Multiple call sites in policy validation should benefit from this.
Issue #, if available
Checklist for requesting a review
The change in this PR is (choose one, and delete the other options):
cedar-policy(e.g., changes to the signature of an existing API).cedar-policy(e.g., addition of a new API).cedar-policy.cedar-policy-core,cedar-validator, etc.)I confirm that this PR (choose one, and delete the other options):
I confirm that
cedar-spec(choose one, and delete the other options):cedar-spec, and how you have tested that your updates are correct.)cedar-spec. (Post your PR anyways, and we'll discuss in the comments.)I confirm that
docs.cedarpolicy.com(choose one, and delete the other options):cedar-docs. PRs should be targeted at astaging-X.Ybranch, notmain.)