rust/src/test/run-pass/expr-alt-generic-box2.rs

18 lines
386 B
Rust
Raw Normal View History

// -*- rust -*-
type compare<T> = fn@(T, T) -> bool;
fn test_generic<T: Copy>(expected: T, eq: compare<T>) {
2012-08-23 16:44:58 -05:00
let actual: T = match true { true => { expected }, _ => fail ~"wat" };
assert (eq(expected, actual));
}
fn test_vec() {
2012-08-01 19:30:05 -05:00
fn compare_box(&&v1: @int, &&v2: @int) -> bool { return v1 == v2; }
2012-06-19 21:34:01 -05:00
test_generic::<@int>(@1, compare_box);
}
fn main() { test_vec(); }