pub struct RemainingAccounts<'a> { /* private fields */ }Expand description
Zero-allocation remaining-accounts view.
Construct via RemainingAccounts::strict or
RemainingAccounts::passthrough from the declared slice and the
full accounts slice. #[hopper::context] emits
ctx.remaining_accounts() and ctx.remaining_accounts_passthrough()
accessors that wire these up for you.
Implementations§
Source§impl<'a> RemainingAccounts<'a>
impl<'a> RemainingAccounts<'a>
Sourcepub fn strict(
declared: &'a [&'a AccountView],
remaining: &'a [&'a AccountView],
) -> Self
pub fn strict( declared: &'a [&'a AccountView], remaining: &'a [&'a AccountView], ) -> Self
Build a strict accessor. Iteration rejects duplicates.
Sourcepub fn passthrough(
declared: &'a [&'a AccountView],
remaining: &'a [&'a AccountView],
) -> Self
pub fn passthrough( declared: &'a [&'a AccountView], remaining: &'a [&'a AccountView], ) -> Self
Build a passthrough accessor. Iteration preserves duplicates.
Sourcepub fn mode(&self) -> RemainingMode
pub fn mode(&self) -> RemainingMode
The active duplicate-handling policy for this view.
Sourcepub fn get(&self, index: usize) -> Result<Option<&'a AccountView>, ProgramError>
pub fn get(&self, index: usize) -> Result<Option<&'a AccountView>, ProgramError>
Random access by index. Passthrough returns the slot as is;
strict returns an error when the resolved slot aliases a
previously-seen account (declared or yielded before index).
Sourcepub fn iter(&self) -> RemainingIter<'a> ⓘ
pub fn iter(&self) -> RemainingIter<'a> ⓘ
Sequential iterator. Yields each account in declaration order, errors on duplicates in strict mode, preserves them in passthrough mode.