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));
9 fn compare_bool(b1: bool, b2: bool) -> bool { return b1 == b2; }
10 test_generic::<bool, _>(true, compare_bool);
20 fn compare_rec(t1: Pair, t2: Pair) -> bool {
21 t1.a == t2.a && t1.b == t2.b
23 test_generic::<Pair, _>(Pair {a: 1, b: 2}, compare_rec);
26 pub fn main() { test_bool(); test_rec(); }