Skip to content

Commit

Permalink
[move 2024] Method syntax docs (MystenLabs#16760)
Browse files Browse the repository at this point in the history
## Description 

Book chapter for methods

## Test Plan 

- 👓 

---
If your changes are not user-facing and do not break anything, you can
skip the following section. Otherwise, please briefly describe what has
changed under the Release Notes section.

### Type of Change (Check all that apply)

- [ ] protocol change
- [ ] user-visible impact
- [ ] breaking change for a client SDKs
- [ ] breaking change for FNs (FN binary must upgrade)
- [ ] breaking change for validators or node operators (must upgrade
binaries)
- [ ] breaking change for on-chain data layout
- [ ] necessitate either a data wipe or data migration

### Release notes

---------

Co-authored-by: ronny-mysten <[email protected]>
  • Loading branch information
tnowacki and ronny-mysten authored Mar 19, 2024
1 parent 75bc597 commit 93709f7
Show file tree
Hide file tree
Showing 6 changed files with 490 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
module a::m {
public struct X() has copy, drop;
public fun u(_: &X): u64 { 0 }
public fun b(_: &X): bool { false }
}

module b::other {
use a::m::X;

use fun a::m::u as X.f;

fun example(x: &X) {
let _: u64 = x.f();
{
use a::m::b as f;
let _: bool = x.f();
};
let _: u64 = x.f();
{
use fun a::m::b as X.f;
let _: bool = x.f();
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
module a::m {
public struct X() has copy, drop;
public fun by_val(_: X) {}
public fun by_ref(_: &X) {}
public fun by_mut(_: &mut X) {}

public struct Y { x: X }
public fun drop_y(y: Y) { let Y { x: _ } = y; }

fun example(y: Y) {
y.x.by_val();
y.drop_y();
}
}
13 changes: 7 additions & 6 deletions external-crates/move/documentation/book/src/SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

[Introduction](introduction.md)

## Getting Started
# Getting Started

- [Modules](modules.md)

## Primitive Types
# Primitive Types

- [Integers](integers.md)
- [Bool](bool.md)
Expand All @@ -15,7 +15,7 @@
- [References](references.md)
- [Tuples and Unit](tuples.md)

## Basic Concepts
# Basic Concepts

- [Local Variables and Scopes](variables.md)
- [Equality](equality.md)
Expand All @@ -33,14 +33,15 @@
- [Packages](packages.md)
- [Unit Tests](unit-testing.md)

## Advanced Concepts
# Advanced Concepts

- [Method Syntax](method-syntax.md)
- [Index Syntax Methods](index-syntax.md)

## Reference
# Reference

- [Coding Conventions](coding-conventions.md)

## Deprecated
# Deprecated

- [Friends](friends.md)
2 changes: 1 addition & 1 deletion external-crates/move/documentation/book/src/functions.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Functions are declared with the `fun` keyword followed by the function name, typ
parameters, a return type, and finally the function body.

```text
<visibility>? <entry>? fun <identifier><[type_parameters: constraint],*>([identifier: type],*): <return_type> <acquires [identifier],*> <function_body>
<visibility>? <entry>? fun <identifier><[type_parameters: constraint],*>([identifier: type],*): <return_type> <function_body>
```

For example
Expand Down
Loading

0 comments on commit 93709f7

Please sign in to comment.