Skip to content

Account::try_from lifetime is not useable #3341

Description

@juchiast

Since 0.29, Account::try_from signature changed from

fn try_from(info: &AccountInfo<'a>) -> Result<Account<'a, T>> {

to

fn try_from(info: &'a AccountInfo<'a>) -> Result<Account<'a, T>> {

If I have an owned AccountInfo<'a> variable, I cannot borrow it again with lifetime 'a because the current scope is always smaller, for example:

fn foo<'a>(info: AccountInfo<'a>) {
    Account::try_from(&info); // not possible because reference cannot live as long as 'a
}

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