Does a resource have to be destroyed after it is created
A created resource must either be destroyed inside the module that created it via Unpack
(e.g., the T{ money } = move(t);
syntax in your example) or published to global state via move_to_sender
(either directly, or as a field of a different published resource).
(1) _ = move(x)
;
This should not work when x
is a resource type. It moves x
to the stack and then pops it, but resources cannot be popped.
(3)Define the procedure of resource destruction as below:
Note that this code will fail at runtime unless value
field of money
is zero.
I noticed that Libra has an administrator account. What privileges does that account have?
There is an “association” account 0xA550C
that has the privilege to mint and burn Libra.
I noticed that some functions have a modifier native
. What does this modifier mean?
This means that the body of the procedure is implemented in Rust instead of Move. Only standard library procedures can be native
; procedures in user-submitted modules with this annotation will not work.
I notice that the function originally named borrow_global
has been renamed borrow_global_mut
. Does borrow_global still exist?
Yes, borrow_global<T>(addr)
now returns an immutable reference to the T
resource stored at addr
. borrow_global_mut<T>(addr)
returns a mutable reference instead.