diff options
Diffstat (limited to 'tests/ui/box/new-box.rs')
-rw-r--r-- | tests/ui/box/new-box.rs | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/tests/ui/box/new-box.rs b/tests/ui/box/new-box.rs new file mode 100644 index 000000000..96a3b197f --- /dev/null +++ b/tests/ui/box/new-box.rs @@ -0,0 +1,30 @@ +// run-pass + +fn f(x: Box<isize>) { + let y: &isize = &*x; + println!("{}", *x); + println!("{}", *y); +} + +trait Trait { + fn printme(&self); +} + +struct Struct; + +impl Trait for Struct { + fn printme(&self) { + println!("hello world!"); + } +} + +fn g(x: Box<dyn Trait>) { + x.printme(); + let y: &dyn Trait = &*x; + y.printme(); +} + +fn main() { + f(Box::new(1234)); + g(Box::new(Struct) as Box<dyn Trait>); +} |