2011-04-05 22:42:33 -05:00
|
|
|
// -*- rust -*-
|
|
|
|
|
|
|
|
type compare[T] = fn(&T t1, &T t2) -> bool;
|
|
|
|
|
|
|
|
fn test_generic[T](&T expected, &compare[T] eq) {
|
|
|
|
let T actual = alt (true) {
|
|
|
|
case (true) {
|
|
|
|
expected
|
|
|
|
}
|
|
|
|
};
|
2011-05-02 19:47:24 -05:00
|
|
|
assert (eq(expected, actual));
|
2011-04-05 22:42:33 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
fn test_vec() {
|
2011-05-01 11:21:08 -05:00
|
|
|
fn compare_vec(&vec[int] v1, &vec[int] v2) -> bool {
|
2011-04-05 22:42:33 -05:00
|
|
|
ret v1 == v2;
|
|
|
|
}
|
|
|
|
auto eq = bind compare_vec(_, _);
|
2011-05-16 20:21:22 -05:00
|
|
|
test_generic[vec[int]]([1, 2, 3], eq);
|
2011-04-05 22:42:33 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
test_vec();
|
|
|
|
}
|