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-10-25 15:56:55 +02:00
|
|
|
fn test_generic<T>(expected: ~T, eq: compare<T>) {
|
2011-09-23 14:58:06 -07:00
|
|
|
let actual: ~T = { expected };
|
|
|
|
assert (eq(expected, actual));
|
|
|
|
}
|
|
|
|
|
|
|
|
fn test_box() {
|
|
|
|
fn compare_box(b1: ~bool, b2: ~bool) -> bool {
|
|
|
|
log *b1;
|
|
|
|
log *b2;
|
|
|
|
ret *b1 == *b2;
|
|
|
|
}
|
|
|
|
let eq = bind compare_box(_, _);
|
|
|
|
test_generic::<bool>(~true, eq);
|
|
|
|
}
|
|
|
|
|
|
|
|
fn main() { test_box(); }
|