2011-09-23 14:58:06 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// -*- rust -*-
|
2011-10-18 15:07:40 -07:00
|
|
|
type compare<T> = fn@(T, T) -> bool;
|
2011-09-23 14:58:06 -07:00
|
|
|
|
2011-11-18 12:39:20 +01:00
|
|
|
fn test_generic<copy T>(expected: T, eq: compare<T>) {
|
2011-09-23 14:58:06 -07:00
|
|
|
let actual: T = { expected };
|
|
|
|
assert (eq(expected, actual));
|
|
|
|
}
|
|
|
|
|
|
|
|
fn test_vec() {
|
2011-10-06 12:50:24 +02:00
|
|
|
fn compare_vec(&&v1: ~int, &&v2: ~int) -> bool { ret v1 == v2; }
|
2011-09-23 14:58:06 -07:00
|
|
|
let eq = bind compare_vec(_, _);
|
|
|
|
test_generic::<~int>(~1, eq);
|
|
|
|
}
|
|
|
|
|
|
|
|
fn main() { test_vec(); }
|