]> git.lizzy.rs Git - rust.git/blob - tests/ui/expr-block-generic.rs
Rollup merge of #107576 - P1n3appl3:master, r=tmandry
[rust.git] / tests / ui / expr-block-generic.rs
1 // run-pass
2 #![allow(unused_braces)]
3
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));
7 }
8
9 fn test_bool() {
10     fn compare_bool(b1: bool, b2: bool) -> bool { return b1 == b2; }
11     test_generic::<bool, _>(true, compare_bool);
12 }
13
14 #[derive(Clone)]
15 struct Pair {
16     a: isize,
17     b: isize,
18 }
19
20 fn test_rec() {
21     fn compare_rec(t1: Pair, t2: Pair) -> bool {
22         t1.a == t2.a && t1.b == t2.b
23     }
24     test_generic::<Pair, _>(Pair {a: 1, b: 2}, compare_rec);
25 }
26
27 pub fn main() { test_bool(); test_rec(); }