//# publish module 0x1.M { import 0x1.vector; struct R has key { v: vector } public publish(s: &signer) { let v: vector; label b0: v = vector.empty(); vector.push_back(&mut v, 100); vector.push_back(&mut v, 200); move_to(move(s), R { v: move(v) }); return; } public borrow_and_swap(addr: address) acquires R { let r: &mut Self.R; label b0: r = borrow_global_mut(move(addr)); vector.swap(&mut move(r).R::v, 0, 1); return; } public verify_effects(addr: address) acquires R { let v: &vector; label b0: v = & borrow_global(move(addr)).R::v; assert(*vector.borrow(copy(v), 0) == 200, 1000); assert(*vector.borrow(move(v), 1) == 100, 1001); return; } } //# run --signers 0x1 import 0x1.M; main(s: signer) { label b0: M.publish(&s); return; } //# run --signers 0x1 import 0x1.M; import 0x1.signer; main(s: signer) { label b0: M.borrow_and_swap(signer.address_of(&s)); return; } //# run --signers 0x1 import 0x1.M; import 0x1.signer; main(s: signer) { label b0: M.verify_effects(signer.address_of(&s)); return; }