From 31f5956fcaf740a8259420ceebce0b64bbb6d20c Mon Sep 17 00:00:00 2001 From: Andrew Paseltiner Date: Thu, 2 Apr 2015 15:44:37 -0400 Subject: [PATCH 1/3] remove blanket impl for comparator references This conflicted with the one for functions once rust-lang/rust#23895 landed, though this solution isn't satisfactory. --- src/lib.rs | 8 -------- 1 file changed, 8 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index f9ad600..d5b75f9 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -322,14 +322,6 @@ impl Compare for F fn compare(&self, lhs: &Lhs, rhs: &Rhs) -> Ordering { (*self)(lhs, rhs) } } -impl<'a, Lhs: ?Sized, Rhs: ?Sized, C: ?Sized> Compare for &'a C - where C: Compare { - - fn compare(&self, lhs: &Lhs, rhs: &Rhs) -> Ordering { - Compare::compare(*self, lhs, rhs) - } -} - /// A comparator that borrows its parameters before comparing them. /// /// See [`Compare::borrow`](trait.Compare.html#method.borrow) for an example. From 9cb32aa4aea18f834880f83eb2b51d87b4710707 Mon Sep 17 00:00:00 2001 From: Andrew Paseltiner Date: Fri, 3 Apr 2015 08:05:10 -0400 Subject: [PATCH 2/3] make `{max, min}` consistent with `std` per rust-lang/rust#23687 --- src/lib.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index d5b75f9..35e03b2 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -132,7 +132,7 @@ use std::default::Default; use std::marker::PhantomData; use std::fmt::{self, Debug}; -/// Returns the maximum of two values according to the given comparator, or `lhs` if they +/// Returns the maximum of two values according to the given comparator, or `rhs` if they /// are equal. /// /// # Examples @@ -147,7 +147,7 @@ use std::fmt::{self, Debug}; /// let f3 = &Foo { key: 'b', id: 3}; /// /// let cmp = Extract::new(|f: &Foo| f.key, natural()); -/// assert_eq!(max(&cmp, f1, f2).id, f1.id); +/// assert_eq!(max(&cmp, f1, f2).id, f2.id); /// assert_eq!(max(&cmp, f1, f3).id, f3.id); /// ``` // FIXME: convert to default method on `Compare` once where clauses permit equality @@ -155,7 +155,7 @@ use std::fmt::{self, Debug}; pub fn max<'a, C: ?Sized, T: ?Sized>(cmp: &C, lhs: &'a T, rhs: &'a T) -> &'a T where C: Compare { - if cmp.compares_ge(lhs, rhs) { lhs } else { rhs } + if cmp.compares_ge(rhs, lhs) { rhs } else { lhs } } /// Returns the minimum of two values according to the given comparator, or `lhs` if they From e722b60beccba515838011d3a546909abc0f4d54 Mon Sep 17 00:00:00 2001 From: Andrew Paseltiner Date: Thu, 2 Apr 2015 16:22:41 -0400 Subject: [PATCH 3/3] bump version --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 8719421..b100dc6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "compare" -version = "0.0.4" +version = "0.0.5" license = "MIT/Apache-2.0" description = "Experimental comparators for collections to be generic over"