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

Remove Clone requirement from unique #776

Closed
wants to merge 1 commit into from

Conversation

gilhooleyd
Copy link
Contributor

This trait requirement appears to no longer be needed.

This trait requirement appears to no longer be needed.
jswrenn
jswrenn previously approved these changes Oct 6, 2023
@jswrenn jswrenn added this to the next milestone Oct 6, 2023
@Philippe-Cholet
Copy link
Member

The item has to implement clone for Unique to be an iterator

@jswrenn jswrenn dismissed their stale review October 6, 2023 14:40

Iterating over a Unique still requires Clone.

@jswrenn
Copy link
Member

jswrenn commented Oct 6, 2023

@Philippe-Cholet's right. @gilhooleyd, could you submit a PR adding the Clone bound to the Unique definition:

/// An iterator adapter to filter out duplicate elements.
///
/// See [`.unique()`](crate::Itertools::unique) for more information.
#[derive(Clone)]
#[must_use = "iterator adaptors are lazy and do nothing unless consumed"]
pub struct Unique<I: Iterator> {
iter: UniqueBy<I, I::Item, ()>,
}

@jswrenn jswrenn closed this Oct 6, 2023
@gilhooleyd
Copy link
Contributor Author

Thanks for the quick feedback! I was surprised to see that cargo test passed with this change, but it looks like there's no test code that calls unique and then iterates over it. Adding that test and then trying to remove Clone further I see that the header comments are correct (Unique does clone each item to place it in the hashmap to look for duplicates).

I'll submit another PR to add a test and the trait

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

3 participants