Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minor enum fixes #86

Merged
merged 1 commit into from
Jul 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion reference/src/SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
- [Conditional Expressions](control-flow/conditionals.md)
- [Loops](control-flow/loops.md)
- [Labeled Control FLow](control-flow/labeled-control-flow.md)
- [Patterm Matching](control-flow/pattern-matching.md)
- [Pattern Matching](control-flow/pattern-matching.md)
- [Functions](functions.md)
- [Structs](structs.md)
- [Enums](enums.md)
Expand Down
2 changes: 1 addition & 1 deletion reference/src/control-flow/pattern-matching.md
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ match (1) {
Similarly, the following would also result in a type error because `MyEnum` and `MyStruct` are
different types:

```
```move
match (MyStruct { x: 0, y: 0 }) {
MyEnum::Variant(..) => 1,
// TYPE ERROR: expected type MyEnum, found MyStruct
Expand Down
14 changes: 7 additions & 7 deletions reference/src/enums.md
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ You can pattern match on Move values by value, immutable reference, and mutable
pattern matching by value, the value is moved into the match arm. When pattern matching by
reference, the value is borrowed into the match arm (either immutably or mutably). We'll go through
a brief description of pattern matching using `match` here, but for more information on pattern
matching using `match` in Move see the [Pattern Matching](./control-flow/pattern_matching.md)
matching using `match` in Move see the [Pattern Matching](./control-flow/pattern-matching.md)
section.

A `match` statement is used to pattern match on a Move value and consists of a number of _match
Expand Down Expand Up @@ -259,14 +259,14 @@ module a::m {
}

public fun incr_enum_variant1(simple_enum: &mut SimpleEnum) {
match simple_enum {
match (simple_enum) {
SimpleEnum::Variant1(mut value) => *value += 1,
_ => (),
}
}

public fun incr_enum_variant2(simple_enum: &mut SimpleEnum) {
match simple_enum {
match (simple_enum) {
SimpleEnum::Variant2(mut value) => *value += 1,
_ => (),
}
Expand Down Expand Up @@ -299,8 +299,8 @@ module a::m {
public enum X { Variant { x: u64 } }

public fun bad(x: X) {
match x {
_ => ()
match (x) {
_ => (),
// ^ ERROR! value of type `X` is not consumed or destructured in this match arm
}
}
Expand All @@ -315,9 +315,9 @@ module a::m {
public enum X { Variant { x: u64 } }

public fun good(x: X) {
match x {
match (x) {
// OK! Compiles since the value is destructured
X::Variant { x: _ } => ()
X::Variant { x: _ } => (),
}
}
}
Expand Down
Loading