]> git.lizzy.rs Git - rust.git/blob - tests/ui/box/new-box.rs
Auto merge of #106646 - Amanieu:ilp32-object, r=Mark-Simulacrum
[rust.git] / tests / ui / box / new-box.rs
1 // run-pass
2
3 fn f(x: Box<isize>) {
4     let y: &isize = &*x;
5     println!("{}", *x);
6     println!("{}", *y);
7 }
8
9 trait Trait {
10     fn printme(&self);
11 }
12
13 struct Struct;
14
15 impl Trait for Struct {
16     fn printme(&self) {
17         println!("hello world!");
18     }
19 }
20
21 fn g(x: Box<dyn Trait>) {
22     x.printme();
23     let y: &dyn Trait = &*x;
24     y.printme();
25 }
26
27 fn main() {
28     f(Box::new(1234));
29     g(Box::new(Struct) as Box<dyn Trait>);
30 }