]> git.lizzy.rs Git - rust.git/blob - src/test/run-pass/alignment-gep-tup-like-1.rs
Rollup merge of #53110 - Xanewok:save-analysis-remap-path, r=nrc
[rust.git] / src / test / run-pass / alignment-gep-tup-like-1.rs
1 // Copyright 2012 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
4 //
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
10
11 #![feature(box_syntax)]
12
13 struct pair<A,B> {
14     a: A, b: B
15 }
16
17 trait Invokable<A> {
18     fn f(&self) -> (A, u16);
19 }
20
21 struct Invoker<A> {
22     a: A,
23     b: u16,
24 }
25
26 impl<A:Clone> Invokable<A> for Invoker<A> {
27     fn f(&self) -> (A, u16) {
28         (self.a.clone(), self.b)
29     }
30 }
31
32 fn f<A:Clone + 'static>(a: A, b: u16) -> Box<Invokable<A>+'static> {
33     box Invoker {
34         a: a,
35         b: b,
36     } as (Box<Invokable<A>+'static>)
37 }
38
39 pub fn main() {
40     let (a, b) = f(22_u64, 44u16).f();
41     println!("a={} b={}", a, b);
42     assert_eq!(a, 22u64);
43     assert_eq!(b, 44u16);
44 }