From 607ca211d56b7850df50006631eceb5ebc9c87a6 Mon Sep 17 00:00:00 2001 From: Griffin Castles Date: Thu, 25 Jan 2024 13:59:27 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=93=83=20docs(std):=20Resolve=20example?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `must_use` has its own example while `observes` and `required` have their respective example --- docs/src/usage/std.md | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/docs/src/usage/std.md b/docs/src/usage/std.md index 61b1ed58..bd36ac16 100644 --- a/docs/src/usage/std.md +++ b/docs/src/usage/std.md @@ -67,6 +67,17 @@ 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. +Example: +```yml + table.insert: + args: + - type: table + observes: write # This way, `table.insert(x, 1)` doesn't count as a read to `x` + - type: any + - required: false + type: any +``` + #### "must_use" This field is used for checking if the return value of a function is used. @@ -78,10 +89,10 @@ Example: table.find: args: - type: table - observes: read # The table is only read from - required: true # The table to index is a required argument + observes: read + required: true - type: any - required: true # The value to find is a required argument + required: true must_use: true # The return value of this function must be used ```