PageRenderTime 5ms CodeModel.GetById 1ms app.highlight 2ms RepoModel.GetById 1ms app.codeStats 0ms

/src/test/run-pass/expr-alt-generic-box1.rs

http://github.com/jruderman/rust
Rust | 17 lines | 10 code | 6 blank | 1 comment | 1 complexity | 38537d47e7592addd3bc19a9b4f2775b MD5 | raw file
 1
 2
 3
 4// -*- rust -*-
 5type compare<T> = fn@(@T, @T) -> bool;
 6
 7fn test_generic<T>(expected: @T, eq: compare<T>) {
 8    let actual: @T = match check true { true => { expected } };
 9    assert (eq(expected, actual));
10}
11
12fn test_box() {
13    fn compare_box(b1: @bool, b2: @bool) -> bool { return *b1 == *b2; }
14    test_generic::<bool>(@true, compare_box);
15}
16
17fn main() { test_box(); }