Skip to content

cmp: remove duplicate free functions #7028

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

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions src/libextra/priority_queue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -186,13 +186,12 @@ impl<T:Ord> PriorityQueue<T> {
#[cfg(test)]
mod tests {
use sort::merge_sort;
use core::cmp::le;
use priority_queue::PriorityQueue;

#[test]
fn test_top_and_pop() {
let data = ~[2, 4, 6, 2, 1, 8, 10, 3, 5, 7, 0, 9, 1];
let mut sorted = merge_sort(data, le);
let data = ~[2u, 4, 6, 2, 1, 8, 10, 3, 5, 7, 0, 9, 1];
let mut sorted = merge_sort(data, |x, y| x.le(y));
let mut heap = PriorityQueue::from_vec(data);
while !heap.is_empty() {
assert_eq!(heap.top(), sorted.last());
Expand Down Expand Up @@ -274,8 +273,9 @@ mod tests {

fn check_to_vec(data: ~[int]) {
let heap = PriorityQueue::from_vec(copy data);
assert_eq!(merge_sort((copy heap).to_vec(), le), merge_sort(data, le));
assert_eq!(heap.to_sorted_vec(), merge_sort(data, le));
assert_eq!(merge_sort((copy heap).to_vec(), |x, y| x.le(y)),
merge_sort(data, |x, y| x.le(y)));
assert_eq!(heap.to_sorted_vec(), merge_sort(data, |x, y| x.le(y)));
}

#[test]
Expand Down
38 changes: 18 additions & 20 deletions src/libextra/time.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1229,36 +1229,34 @@ mod tests {
}

fn test_timespec_eq_ord() {
use core::cmp::{eq, ge, gt, le, lt, ne};

let a = &Timespec::new(-2, 1);
let b = &Timespec::new(-1, 2);
let c = &Timespec::new(1, 2);
let d = &Timespec::new(2, 1);
let e = &Timespec::new(2, 1);

assert!(eq(d, e));
assert!(ne(c, e));
assert!(d.eq(e));
assert!(c.ne(e));

assert!(lt(a, b));
assert!(lt(b, c));
assert!(lt(c, d));
assert!(a.lt(b));
assert!(b.lt(c));
assert!(c.lt(d));

assert!(le(a, b));
assert!(le(b, c));
assert!(le(c, d));
assert!(le(d, e));
assert!(le(e, d));
assert!(a.le(b));
assert!(b.le(c));
assert!(c.le(d));
assert!(d.le(e));
assert!(e.le(d));

assert!(ge(b, a));
assert!(ge(c, b));
assert!(ge(d, c));
assert!(ge(e, d));
assert!(ge(d, e));
assert!(b.ge(a));
assert!(c.ge(b));
assert!(d.ge(c));
assert!(e.ge(d));
assert!(d.ge(e));

assert!(gt(b, a));
assert!(gt(c, b));
assert!(gt(d, c));
assert!(b.gt(a));
assert!(c.gt(b));
assert!(d.gt(c));
}

#[test]
Expand Down
30 changes: 0 additions & 30 deletions src/libstd/cmp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -172,36 +172,6 @@ pub trait Ord {
fn gt(&self, other: &Self) -> bool;
}

#[inline(always)]
pub fn lt<T:Ord>(v1: &T, v2: &T) -> bool {
(*v1).lt(v2)
}

#[inline(always)]
pub fn le<T:Ord>(v1: &T, v2: &T) -> bool {
(*v1).le(v2)
}

#[inline(always)]
pub fn eq<T:Eq>(v1: &T, v2: &T) -> bool {
(*v1).eq(v2)
}

#[inline(always)]
pub fn ne<T:Eq>(v1: &T, v2: &T) -> bool {
(*v1).ne(v2)
}

#[inline(always)]
pub fn ge<T:Ord>(v1: &T, v2: &T) -> bool {
(*v1).ge(v2)
}

#[inline(always)]
pub fn gt<T:Ord>(v1: &T, v2: &T) -> bool {
(*v1).gt(v2)
}

/// The equivalence relation. Two values may be equivalent even if they are
/// of different types. The most common use case for this relation is
/// container types; e.g. it is often desirable to be able to use `&str`
Expand Down