1 // run-pass 2 f(x: Box<isize>)3fn f(x: Box<isize>) { 4 let y: &isize = &*x; 5 println!("{}", *x); 6 println!("{}", *y); 7 } 8 9 trait Trait { printme(&self)10 fn printme(&self); 11 } 12 13 struct Struct; 14 15 impl Trait for Struct { printme(&self)16 fn printme(&self) { 17 println!("hello world!"); 18 } 19 } 20 g(x: Box<dyn Trait>)21fn g(x: Box<dyn Trait>) { 22 x.printme(); 23 let y: &dyn Trait = &*x; 24 y.printme(); 25 } 26 main()27fn main() { 28 f(Box::new(1234)); 29 g(Box::new(Struct) as Box<dyn Trait>); 30 } 31