From 7b86aed638ca2b86099ca0d839ddb264690c3c26 Mon Sep 17 00:00:00 2001 From: zklock <49580849+zkwarlock@users.noreply.github.com> Date: Mon, 15 Nov 2021 17:39:30 +0530 Subject: [PATCH] lang: Document init_if_needed (#1023) --- lang/derive/accounts/src/lib.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/lang/derive/accounts/src/lib.rs b/lang/derive/accounts/src/lib.rs index f176e57d5..529c5bec6 100644 --- a/lang/derive/accounts/src/lib.rs +++ b/lang/derive/accounts/src/lib.rs @@ -40,6 +40,7 @@ use syn::parse_macro_input; /// | `#[account(signer)]`

`#[account(signer @ )]` | On raw `AccountInfo` structs. | Checks the given account signed the transaction. Custom errors are supported via `@`. | /// | `#[account(mut)]`

`#[account(mut @ )]` | On `AccountInfo`, `ProgramAccount` or `CpiAccount` structs. | Marks the account as mutable and persists the state transition. Custom errors are supported via `@`. | /// | `#[account(init)]` | On `ProgramAccount` structs. | Marks the account as being initialized, creating the account via the system program. | +/// | `#[account(init_if_needed)]` | On `ProgramAccount` structs. | Same as `init` but skip if already initialized. | /// | `#[account(zero)]` | On `ProgramAccount` structs. | Asserts the account discriminator is zero. | /// | `#[account(close = )]` | On `ProgramAccount` and `Loader` structs. | Marks the account as being closed at the end of the instruction's execution, sending the rent exemption lamports to the specified . | /// | `#[account(has_one = )]`

`#[account(has_one = @ )]` | On `ProgramAccount` or `CpiAccount` structs | Checks the `target` field on the account matches the `target` field in the struct deriving `Accounts`. Custom errors are supported via `@`. |