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