Skip to content

Commit

Permalink
πŸ“ƒ docs(std): Add must_use
Browse files Browse the repository at this point in the history
Std documentation now has `must_use` functionality with the appropriate example
  • Loading branch information
Midnightific committed Jan 24, 2024
1 parent 65174d1 commit d2ad074
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions docs/src/usage/std.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,15 +67,22 @@ This field is used for allowing smarter introspection of how the argument given
- "read" - This argument is only read from. Currently unused.
- "write" - This argument is only written to. Used by `unused_variable` to assist in detecting a variable only being written to, even if passed into a function.

#### "must_use"
This field is used for checking if the return value of a function is used.

- `true` - The default. The return value of this function must be used.
- `false` - The return value of this function does not need to be used.

Example:
```yml
table.insert:
table.find:
args:
- type: table
observes: write # This way, `table.insert(x, 1)` doesn't count as a read to `x`
observes: read # The table is only read from
required: true # The table to index is a required argument
- type: any
- required: false
type: any
required: true # The value to find is a required argument
must_use: true # The return value of this function must be used
```

#### Argument types
Expand Down

0 comments on commit d2ad074

Please sign in to comment.