]> git.proxmox.com Git - rustc.git/blob - tests/ui/higher-rank-trait-bounds/hrtb-trait-object-paren-notation.rs
New upstream version 1.68.2+dfsg1
[rustc.git] / tests / ui / higher-rank-trait-bounds / hrtb-trait-object-paren-notation.rs
1 // run-pass
2 // A basic test of using a higher-ranked trait bound.
3
4 trait FnLike<A,R> {
5 fn call(&self, arg: A) -> R;
6 }
7
8 type FnObject<'b> = dyn for<'a> FnLike<(&'a i32,), &'a i32> + 'b;
9
10 struct Identity;
11
12 impl<'a, T> FnLike<(&'a T,), &'a T> for Identity {
13 fn call(&self, (arg,): (&'a T,)) -> &'a T {
14 arg
15 }
16 }
17
18 fn call_repeatedly(f: &FnObject) {
19 let x = 3;
20 let y = f.call((&x,));
21 assert_eq!(3, *y);
22 }
23
24 fn main() {
25 call_repeatedly(&Identity);
26 }