module MoneyHolder { import 0x0.LibraCoin; resource T { money: R#LibraCoin.T } public new(m: R#LibraCoin.T): R#Self.T { return T{ money: move(m) }; } public value(this :&R#Self.T): u64 { let ref: &R#LibraCoin.T; let val: u64; ref = ©(this).money; val = LibraCoin.value(move(ref)); release(move(this)); return move(val); } public destroy_t(t: R#Self.T) { let money: R#LibraCoin.T; T{ money } = move(t); LibraCoin.destroy_zero(move(money)); return; } } //! new-transaction module Bar { struct T{baz: u64} public new(m: u64): V#Self.T { return T{baz: move(m)}; } public value(this: &V#Self.T): u64 { let ref: &u64; ref = &move(this).baz; return *move(ref); } } //! new-transaction import {{default}}.MoneyHolder; import {{default}}.Bar; import 0x0.LibraCoin; main() { let coin: R#LibraCoin.T; let money_holder: R#MoneyHolder.T; let money_holder_ref: &R#MoneyHolder.T; let value: u64; let v: u64; let bar: V#Bar.T; let bar_ref: &V#Bar.T; let v2: u64; coin = LibraCoin.zero(); money_holder = MoneyHolder.new(move(coin)); money_holder_ref = &money_holder; value = MoneyHolder.value(move(money_holder_ref)); assert(copy(value) == 0, 42); MoneyHolder.destroy_t(move(money_holder)); v = 1; bar = Bar.new(copy(v)); bar_ref = &bar; v2 = Bar.value(move(bar_ref)); assert(copy(v) == copy(v2), 42); return; }