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

Unclear documentation for remove_if #310

Open
anlumo opened this issue Sep 18, 2024 · 0 comments
Open

Unclear documentation for remove_if #310

anlumo opened this issue Sep 18, 2024 · 0 comments

Comments

@anlumo
Copy link

anlumo commented Sep 18, 2024

The documentation for DashMap::remove_if says

Removes an entry from the map, returning the key and value if the entry existed and the provided conditional function returned true.

This could be interpreted in two ways:

  • Removes an entry from the map, (returning the key and value if the entry existed and the provided conditional function returned true).
  • (Removes an entry from the map, returning the key and value) if the entry existed and the provided conditional function returned true.

Reading the code:

dashmap/src/lib.rs

Lines 991 to 996 in f2d248e

if f(k, v.get()) {
let ((k, v), _) = unsafe { shard.remove(bucket) };
Some((k, v.into_inner()))
} else {
None
}

it's clear that the latter is the approach actually implemented, but it shouldn't be necessary to look into the code for this.

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

No branches or pull requests

1 participant