]> git.lizzy.rs Git - rust.git/blob - src/test/ui/expr-block-generic.rs
Merge branch 'master' into rusty-hermit
[rust.git] / src / test / ui / expr-block-generic.rs
1 // run-pass
2
3 fn test_generic<T: Clone, F>(expected: T, eq: F) where F: FnOnce(T, T) -> bool {
4     let actual: T = { expected.clone() };
5     assert!(eq(expected, actual));
6 }
7
8 fn test_bool() {
9     fn compare_bool(b1: bool, b2: bool) -> bool { return b1 == b2; }
10     test_generic::<bool, _>(true, compare_bool);
11 }
12
13 #[derive(Clone)]
14 struct Pair {
15     a: isize,
16     b: isize,
17 }
18
19 fn test_rec() {
20     fn compare_rec(t1: Pair, t2: Pair) -> bool {
21         t1.a == t2.a && t1.b == t2.b
22     }
23     test_generic::<Pair, _>(Pair {a: 1, b: 2}, compare_rec);
24 }
25
26 pub fn main() { test_bool(); test_rec(); }