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

http://github.com/jruderman/rust · Rust · 21 lines · 14 code · 6 blank · 1 comment · 1 complexity · 206fed76a0c0c1be3faea158a3c025be MD5 · raw file

  1. // -*- rust -*-
  2. type compare<T> = fn@(@T, @T) -> bool;
  3. fn test_generic<T>(expected: @T, eq: compare<T>) {
  4. let actual: @T = { expected };
  5. assert (eq(expected, actual));
  6. }
  7. fn test_box() {
  8. fn compare_box(b1: @bool, b2: @bool) -> bool {
  9. log(debug, *b1);
  10. log(debug, *b2);
  11. return *b1 == *b2;
  12. }
  13. test_generic::<bool>(@true, compare_box);
  14. }
  15. fn main() { test_box(); }