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