Skip to content

Commit

Permalink
Add Clone trait to Unique
Browse files Browse the repository at this point in the history
Using a Unique iterator requires the Clone trait, so
require this trait when creating the Unique object.
  • Loading branch information
gilhooleyd authored and Philippe-Cholet committed Oct 8, 2023
1 parent 4d2bd4e commit 328f956
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/unique_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -165,22 +165,26 @@ where
/// 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> {
pub struct Unique<I>
where
I: Iterator,
I::Item: Eq + Hash + Clone,
{
iter: UniqueBy<I, I::Item, ()>,
}

impl<I> fmt::Debug for Unique<I>
where
I: Iterator + fmt::Debug,
I::Item: Hash + Eq + fmt::Debug,
I::Item: Hash + Eq + fmt::Debug + Clone,
{
debug_fmt_fields!(Unique, iter);
}

pub fn unique<I>(iter: I) -> Unique<I>
where
I: Iterator,
I::Item: Eq + Hash,
I::Item: Eq + Hash + Clone,
{
Unique {
iter: UniqueBy {
Expand Down

0 comments on commit 328f956

Please sign in to comment.