solana_program::account_info

Function next_account_infos

source
pub fn next_account_infos<'a, 'b: 'a>(
    iter: &mut Iter<'a, AccountInfo<'b>>,
    count: usize,
) -> Result<&'a [AccountInfo<'b>], ProgramError>
Expand description

Convenience function for accessing multiple next items in an AccountInfo iterator.

Returns a slice containing the next count AccountInfos.

§Errors

Returns ProgramError::NotEnoughAccountKeys if there are not enough items in the iterator to satisfy the request.

§Examples

use solana_program::{
   account_info::{AccountInfo, next_account_info, next_account_infos},
   entrypoint::ProgramResult,
   pubkey::Pubkey,
};

pub fn process_instruction(
    program_id: &Pubkey,
    accounts: &[AccountInfo],
    instruction_data: &[u8],
) -> ProgramResult {
    let accounts_iter = &mut accounts.iter();
    let signer = next_account_info(accounts_iter)?;
    let payer = next_account_info(accounts_iter)?;
    let outputs = next_account_infos(accounts_iter, 3)?;

    // do stuff ...

    Ok(())
}