Skip to content

Commit

Permalink
Minor enum fixes (#86)
Browse files Browse the repository at this point in the history
  • Loading branch information
tzakian authored Jul 16, 2024
1 parent e73a9bf commit da2f47f
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
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

0 comments on commit da2f47f

Please sign in to comment.