Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: simplify upsert operation #300

Merged
merged 1 commit into from
Dec 10, 2024

Conversation

ivan-aksamentov
Copy link
Member

This uses the rust-y .entry().or_insert*() pattern as an alternative to .contains() + .insert(), to express the "upsert" (insert or update) operation of a BTreeMap more concisely.

I believe it preserves the original behavior.

This uses the rust-y `.entry().or_insert*()` [pattern](https://www.knowbe4.com/careers/blogs/engineering/on-rusts-map-entry-pattern) as an alternative to `.contains()` + `.insert()`,  to express the "upsert" (insert or update) operation of a `BTreeMap` more concisely.

I believe it preserves the original behavior.
@ivan-aksamentov ivan-aksamentov merged commit 4e9a8d2 into rust Dec 10, 2024
14 checks passed
@ivan-aksamentov ivan-aksamentov deleted the refactor/fitch-simplify-upsert branch December 10, 2024 23:27
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.

1 participant