Skip to content

Commit 77f8c3a

Browse files
authored
Merge pull request sekineh#10 from asomers/noclone
Don't require FnComparator to be Clone
2 parents 597aeb8 + 6c74df1 commit 77f8c3a

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/binary_heap.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ pub struct FnComparator<F>(pub F);
272272

273273
impl<T, F> Compare<T> for FnComparator<F>
274274
where
275-
F: Clone + Fn(&T, &T) -> Ordering,
275+
F: Fn(&T, &T) -> Ordering,
276276
{
277277
fn compare(&self, a: &T, b: &T) -> Ordering {
278278
self.0(a, b)
@@ -282,11 +282,11 @@ where
282282
/// The comparator ordered by key
283283
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
284284
#[derive(Clone, Copy, Default, PartialEq, Eq, Debug)]
285-
pub struct KeyComparator<F: Clone>(pub F);
285+
pub struct KeyComparator<F>(pub F);
286286

287287
impl<K: Ord, T, F> Compare<T> for KeyComparator<F>
288288
where
289-
F: Clone + Fn(&T) -> K,
289+
F: Fn(&T) -> K,
290290
{
291291
fn compare(&self, a: &T, b: &T) -> Ordering {
292292
self.0(a).cmp(&self.0(b))
@@ -496,7 +496,7 @@ impl<T: Ord> BinaryHeap<T, MinComparator> {
496496

497497
impl<T, F> BinaryHeap<T, FnComparator<F>>
498498
where
499-
F: Clone + Fn(&T, &T) -> Ordering,
499+
F: Fn(&T, &T) -> Ordering,
500500
{
501501
/// Creates an empty `BinaryHeap`.
502502
///
@@ -545,7 +545,7 @@ where
545545

546546
impl<T, F, K: Ord> BinaryHeap<T, KeyComparator<F>>
547547
where
548-
F: Clone + Fn(&T) -> K,
548+
F: Fn(&T) -> K,
549549
{
550550
/// Creates an empty `BinaryHeap`.
551551
///

0 commit comments

Comments
 (0)