Skip to content

Commit

Permalink
Update ch2-using-objects.md to make code paths absolute (MystenLabs#1904
Browse files Browse the repository at this point in the history
)

* Update ch2-using-objects.md

to make code paths absolute

* Update ch2-using-objects.md

Fix another link to same file
  • Loading branch information
Clay-Mysten authored May 12, 2022
1 parent 6862a8f commit ab72fb2
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions doc/src/build/programming-with-objects/ch2-using-objects.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,14 +76,14 @@ TestScenario::next_tx(scenario, &owner);
### Pass objects by value
Objects can also be passed by value into an entry function. By doing so, the object is moved out of Sui storage (a.k.a. deleted). It is then up to the Move code to decide where this object should go.

> :books: Since every [Sui object struct type](./ch1-object-basics.md#define-sui-object) must include `VersionedID` as a field, and the [VersionedID struct](../../../../sui_programmability/framework/sources/ID.move) does not have the `drop` ability, the Sui object struct type [must not](https://github.com/diem/move/blob/main/language/documentation/book/src/abilities.md#drop) have `drop` ability either. Hence, any Sui object cannot be arbitrarily dropped and must be either consumed or unpacked.
> :books: Since every [Sui object struct type](./ch1-object-basics.md#define-sui-object) must include `VersionedID` as a field, and the [VersionedID struct](https://github.com/MystenLabs/sui/blob/main/sui_programmability/framework/sources/ID.move) does not have the `drop` ability, the Sui object struct type [must not](https://github.com/diem/move/blob/main/language/documentation/book/src/abilities.md#drop) have `drop` ability either. Hence, any Sui object cannot be arbitrarily dropped and must be either consumed or unpacked.
There are two ways we can deal with a pass-by-value Sui object in Move:

#### Option 1. Delete the object
If the intention is to actually delete the object, we can unpack the object. This can be done only in the module that defined the struct type, due to Move's [privileged struct operations rules](https://github.com/diem/move/blob/main/language/documentation/book/src/structs-and-resources.md#privileged-struct-operations). Upon unpacking, if any field is also of struct type, recursive unpacking and deletion will be required.

However, the `id` field of a Sui object requires special handling. We must call the following API in the [ID](../../../../sui_programmability/framework/sources/ID.move) module to signal Sui that we intend to delete this object:
However, the `id` field of a Sui object requires special handling. We must call the following API in the [ID](https://github.com/MystenLabs/sui/blob/main/sui_programmability/framework/sources/ID.move) module to signal Sui that we intend to delete this object:
```rust
public fun delete(versioned_id: VersionedID);
```
Expand Down

0 comments on commit ab72fb2

Please sign in to comment.