]>
Commit | Line | Data |
---|---|---|
416331ca | 1 | // run-pass |
ba9703b0 | 2 | #![allow(unused_braces)] |
416331ca | 3 | |
1a4d82fc JJ |
4 | fn test_generic<T: Clone, F>(expected: T, eq: F) where F: FnOnce(T, T) -> bool { |
5 | let actual: T = { expected.clone() }; | |
6 | assert!(eq(expected, actual)); | |
223e47cc LB |
7 | } |
8 | ||
9 | fn test_bool() { | |
10 | fn compare_bool(b1: bool, b2: bool) -> bool { return b1 == b2; } | |
1a4d82fc | 11 | test_generic::<bool, _>(true, compare_bool); |
223e47cc LB |
12 | } |
13 | ||
1a4d82fc JJ |
14 | #[derive(Clone)] |
15 | struct Pair { | |
c34b1796 AL |
16 | a: isize, |
17 | b: isize, | |
1a4d82fc | 18 | } |
223e47cc LB |
19 | |
20 | fn test_rec() { | |
21 | fn compare_rec(t1: Pair, t2: Pair) -> bool { | |
22 | t1.a == t2.a && t1.b == t2.b | |
23 | } | |
1a4d82fc | 24 | test_generic::<Pair, _>(Pair {a: 1, b: 2}, compare_rec); |
223e47cc LB |
25 | } |
26 | ||
27 | pub fn main() { test_bool(); test_rec(); } |