rust/src/libcore/cmp.rs
Niko Matsakis 97452c0ca1 Remove modes from map API and replace with regions.
API is (for now) mostly by value, there are options to use it by
reference if you like.  Hash and equality functions must be pure
and by reference (forward looking to the day when something
like send_map becomes the standard map).
2012-08-02 15:53:28 -07:00

21 lines
348 B
Rust

/// Interfaces used for comparison.
trait ord {
pure fn lt(&&other: self) -> bool;
}
trait eq {
pure fn eq(&&other: self) -> bool;
}
pure fn lt<T: ord>(v1: &T, v2: &T) -> bool {
v1.lt(*v2)
}
pure fn le<T: ord eq>(v1: &T, v2: &T) -> bool {
v1.lt(*v2) || v1.eq(*v2)
}
pure fn eq<T: eq>(v1: &T, v2: &T) -> bool {
v1.eq(*v2)
}