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).
21 lines
348 B
Rust
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)
|
|
}
|