]> git.lizzy.rs Git - rust.git/blob - src/test/run-pass/regions-infer-contravariance-due-to-ret.rs
Infer variance of types with respect to the region parameter.
[rust.git] / src / test / run-pass / regions-infer-contravariance-due-to-ret.rs
1 struct boxed_int {
2     f: ∫
3 }
4
5 fn max(bi: &r/boxed_int, f: &r/int) -> int {
6     if *bi.f > *f {*bi.f} else {*f}
7 }
8
9 fn with(bi: &boxed_int) -> int {
10     let i = 22;
11     max(bi, &i)
12 }
13
14 fn main() {
15     let g = 21;
16     let foo = boxed_int { f: &g };
17     assert with(&foo) == 22;
18 }