Skip to content

Commit 57dec5c

Browse files
committed
also test Box<self> receiver
1 parent b7a8ce1 commit 57dec5c

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

tests/run-pass/dyn-traits.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,18 @@ fn ref_box_dyn() {
55

66
trait Trait {
77
fn method(&self);
8+
9+
fn box_method(self: Box<Self>);
810
}
911

1012
impl Trait for Struct {
1113
fn method(&self) {
1214
assert_eq!(self.0, 42);
1315
}
16+
17+
fn box_method(self: Box<Self>) {
18+
assert_eq!(self.0, 7);
19+
}
1420
}
1521

1622
struct Foo<T: ?Sized>(T);
@@ -27,6 +33,9 @@ fn ref_box_dyn() {
2733

2834
let y = &y;
2935
y.method();
36+
37+
let y: Box<dyn Trait> = Box::new(Struct(7));
38+
y.box_method();
3039
}
3140

3241

0 commit comments

Comments
 (0)