]> git.lizzy.rs Git - rust.git/commitdiff
also test Box<self> receiver
authorRalf Jung <post@ralfj.de>
Thu, 7 Nov 2019 08:17:40 +0000 (09:17 +0100)
committerRalf Jung <post@ralfj.de>
Thu, 7 Nov 2019 08:17:40 +0000 (09:17 +0100)
tests/run-pass/dyn-traits.rs

index f732c7bfaf1c957d600077b51e98a47c6de66b71..33d1f4fc1cf0caac47eb0a21da611c0d7f68b231 100644 (file)
@@ -5,12 +5,18 @@ fn ref_box_dyn() {
 
     trait Trait {
         fn method(&self);
+
+        fn box_method(self: Box<Self>);
     }
 
     impl Trait for Struct {
         fn method(&self) {
             assert_eq!(self.0, 42);
         }
+
+        fn box_method(self: Box<Self>) {
+            assert_eq!(self.0, 7);
+        }
     }
 
     struct Foo<T: ?Sized>(T);
@@ -27,6 +33,9 @@ fn method(&self) {
 
     let y = &y;
     y.method();
+
+    let y: Box<dyn Trait> = Box::new(Struct(7));
+    y.box_method();
 }