]> git.lizzy.rs Git - rust.git/blob - src/test/ui/regions/regions-early-bound-used-in-type-param.rs
Rollup merge of #89468 - FabianWolff:issue-89358, r=jackh726
[rust.git] / src / test / ui / regions / regions-early-bound-used-in-type-param.rs
1 // run-pass
2 // Tests that you can use a fn lifetime parameter as part of
3 // the value for a type parameter in a bound.
4
5
6 trait Get<T> {
7     fn get(&self) -> T;
8 }
9
10 #[derive(Copy, Clone)]
11 struct Box<T> {
12     t: T
13 }
14
15 impl<T:Clone> Get<T> for Box<T> {
16     fn get(&self) -> T {
17         self.t.clone()
18     }
19 }
20
21 fn add<'a,G:Get<&'a isize>>(g1: G, g2: G) -> isize {
22     *g1.get() + *g2.get()
23 }
24
25 pub fn main() {
26     let b1 = Box { t: &3 };
27     assert_eq!(add(b1, b1), 6);
28 }