Skip to content

Commit

Permalink
chore(tests): Test trait override of MutableReference of struct
Browse files Browse the repository at this point in the history
  • Loading branch information
ymadzhunkov committed Oct 6, 2023
1 parent db1e736 commit 8276ed8
Showing 1 changed file with 18 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@ impl F for Bar {
fn f3(self) -> Field { 30 }
}

impl F for &mut Bar {
fn f1(self) -> Field { 101 }
fn f5(self) -> Field { 505 }
}

fn main(x: Field) {
let first = Foo::method2(x);
assert(first == 3 * x);
Expand All @@ -50,4 +55,17 @@ fn main(x: Field) {
assert(bar.f3() == 30);
assert(bar.f4() == 4);
assert(bar.f5() == 50);

let mut bar_mut = Bar{};
assert((&mut bar_mut).f1() == 101);
assert((&mut bar_mut).f2() == 2);
assert((&mut bar_mut).f3() == 3);
assert((&mut bar_mut).f4() == 4);
assert((&mut bar_mut).f5() == 505);

assert(bar_mut.f1() == 10);
assert(bar_mut.f2() == 2);
assert(bar_mut.f3() == 30);
assert(bar_mut.f4() == 4);
assert(bar_mut.f5() == 50);
}

0 comments on commit 8276ed8

Please sign in to comment.