]> git.proxmox.com Git - rustc.git/blame - src/test/ui/higher-rank-trait-bounds/hrtb-fn-like-trait.rs
New upstream version 1.67.1+dfsg1
[rustc.git] / src / test / ui / higher-rank-trait-bounds / hrtb-fn-like-trait.rs
CommitLineData
b7449926 1// run-pass
1a4d82fc
JJ
2// A basic test of using a higher-ranked trait bound.
3
c34b1796 4
1a4d82fc
JJ
5trait FnLike<A,R> {
6 fn call(&self, arg: A) -> R;
7}
8
9struct Identity;
10
11impl<'a, T> FnLike<&'a T, &'a T> for Identity {
12 fn call(&self, arg: &'a T) -> &'a T {
13 arg
14 }
15}
16
17fn call_repeatedly<F>(f: F)
c34b1796 18 where F : for<'a> FnLike<&'a isize, &'a isize>
1a4d82fc
JJ
19{
20 let x = 3;
21 let y = f.call(&x);
22 assert_eq!(3, *y);
23}
24
25fn main() {
26 call_repeatedly(Identity);
27}