pub fn next_account_infos<'a, 'b>(
iter: &mut Iter<'a, AccountInfo<'b>>,
count: usize,
) -> Result<&'a [AccountInfo<'b>], ProgramError>where
'b: 'a,
Expand description
Convenience function for accessing multiple next items in an AccountInfo
iterator.
Returns a slice containing the next count
AccountInfo
s.
§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(())
}