Macro anchor_lang::prelude::require_neq
source · macro_rules! require_neq { ($value1: expr, $value2: expr, $error_code: expr $(,)?) => { ... }; ($value1: expr, $value2: expr $(,)?) => { ... }; }
Expand description
Ensures two NON-PUBKEY values are not equal.
Use require_keys_neq to compare two pubkeys.
Can be used with or without a custom error code.
Example
ⓘ
pub fn set_data(ctx: Context<SetData>, data: u64) -> Result<()> {
require_neq!(ctx.accounts.data.data, 0);
ctx.accounts.data.data = data;
Ok(());
}