Skip to content

Commit 87b41a5

Browse files
gilhooleydPhilippe-Cholet
authored andcommitted
Add Clone trait to Unique
Using a Unique iterator requires the Clone trait, so require this trait when creating the Unique object.
1 parent 4d2bd4e commit 87b41a5

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/unique_impl.rs

+7-3
Original file line numberDiff line numberDiff line change
@@ -165,22 +165,26 @@ where
165165
/// See [`.unique()`](crate::Itertools::unique) for more information.
166166
#[derive(Clone)]
167167
#[must_use = "iterator adaptors are lazy and do nothing unless consumed"]
168-
pub struct Unique<I: Iterator> {
168+
pub struct Unique<I>
169+
where
170+
I: Iterator,
171+
I::Item: Eq + Hash + Clone,
172+
{
169173
iter: UniqueBy<I, I::Item, ()>,
170174
}
171175

172176
impl<I> fmt::Debug for Unique<I>
173177
where
174178
I: Iterator + fmt::Debug,
175-
I::Item: Hash + Eq + fmt::Debug,
179+
I::Item: Hash + Eq + fmt::Debug + Clone,
176180
{
177181
debug_fmt_fields!(Unique, iter);
178182
}
179183

180184
pub fn unique<I>(iter: I) -> Unique<I>
181185
where
182186
I: Iterator,
183-
I::Item: Eq + Hash,
187+
I::Item: Eq + Hash + Clone,
184188
{
185189
Unique {
186190
iter: UniqueBy {

0 commit comments

Comments
 (0)