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

feat(cordyceps): add List::drain_filter #212

Merged
merged 4 commits into from
Jun 9, 2022
Merged

feat(cordyceps): add List::drain_filter #212

merged 4 commits into from
Jun 9, 2022

Conversation

hawkw
Copy link
Owner

@hawkw hawkw commented Jun 9, 2022

This branch adds a List::drain_filter iterator that moves items out of
the list if they match a predicate. This is based on the
drain_filter iterator on the std::collections::LinkedList type,
but modified slightly.

This branch adds a `List::drain_filter` iterator that moves items out of
the list if they match a predicate. This is based on the
[`drain_filter`] iterator on the `std::collections::LinkedList` type,
but modified slightly.

[`drain_filter`]: https://doc.rust-lang.org/stable/std/collections/struct.LinkedList.html#method.drain_filter
@hawkw hawkw requested a review from jamesmunns June 9, 2022 16:33
Signed-off-by: Eliza Weisman <eliza@buoyant.io>
Copy link
Collaborator

@jamesmunns jamesmunns left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall LGTM, one note about code re-use.

cordyceps/src/list.rs Show resolved Hide resolved
@hawkw hawkw enabled auto-merge (squash) June 9, 2022 18:24
@@ -847,13 +879,24 @@ impl<'a, T: Linked<Links<T>> + ?Sized> Cursor<'a, T> {
while let Some(node) = self.next_ptr() {
if predicate(unsafe { node.as_ref() }) {
item = Some(node);
self.len -= 1;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👀

@hawkw hawkw merged commit dc2e638 into main Jun 9, 2022
@hawkw hawkw deleted the eliza/drain-filter branch June 9, 2022 18:31
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.

None yet

2 participants