Skip to content

Commit

Permalink
Sway Ref: Style guide enum intro (FuelLabs#4653)
Browse files Browse the repository at this point in the history
  • Loading branch information
Braqzen authored Jun 14, 2023
1 parent c9175cb commit 4081e70
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
library;

// ANCHOR: style_enums
pub enum Error {
StateError: StateError,
UserError: UserError,
Expand All @@ -15,6 +16,7 @@ pub enum UserError {
InsufficientPermissions: (),
Unauthorized: (),
}
// ANCHOR_END: style_enums

fn preferred() {
// ANCHOR: use
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
# Enums

> TODO: intro, show enums
An [`enum`](../../language/built-ins/enums.md) may contain many types including other enums.

```sway
{{#include ../../../code/language/style-guide/enum_style/src/lib.sw:style_enums}}
```

## Encouraged

The preferred way to use [enums](../built-ins/enums.md) is to use the individual (not nested) enums directly because they are easy to follow and the lines are short:
The preferred way to use [`enums`](../built-ins/enums.md) is to use the individual (not nested) enums directly because they are easy to follow and the lines are short:

```sway
{{#include ../../../code/language/style-guide/enum_style/src/lib.sw:use}}
Expand Down

0 comments on commit 4081e70

Please sign in to comment.