Skip to content

accounts is borrowed for 'info #3415

Description

@lantianlaoli
12 | #[program]
   | ^^^^^^^^^-
   | |        |
   | |        `__accounts` dropped here while still borrowed
   | borrowed value does not live long enough
   | lifetime `'info` defined here
   | argument requires that `__accounts` is borrowed for `'info`

I don't why life time error happen when I add 'b on lib.rs

pub fn battle_log<'b: 'info, 'c: 'info, 'info>(
        ctx: Context<'_, 'b, 'c, 'info, BattleLog<'info>>,
        battle_info: BattleInfo,
        warrior_card_collect_mints: Vec<Pubkey>
    ) -> Result<()> {
        battle_log_process(ctx, battle_info, warrior_card_collect_mints)
    }

I want to extract the logic of creating an account into a function, and then it will report an error, asking me to add the relationship between b and info.

fbc83ba68919fab094857cdbc31588a

The result is written in this way, but it cannot pass the limit of the problem I posted.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions