Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lang: add set_inner function to Account<'a, T> #1177

Merged
merged 2 commits into from Dec 20, 2021

Conversation

paul-schaaf
Copy link
Contributor

@paul-schaaf paul-schaaf commented Dec 20, 2021

closes #1115

pub fn new_user(ctx: Context<CreateUser>, new_user:User) -> ProgramResult {
    ctx.accounts.user_to_create.set_inner(new_user);
}

instead of

pub fn new_user(ctx: Context<CreateUser>, new_user:User) -> ProgramResult {
    (*ctx.accounts.user_to_create).name = new_user.name;
    (*ctx.accounts.user_to_create).age = new_user.age;
    (*ctx.accounts.user_to_create).address = new_user.address;
}

@paul-schaaf paul-schaaf marked this pull request as ready for review December 20, 2021 10:55
@armaniferrante armaniferrante merged commit 790fda9 into coral-xyz:master Dec 20, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Feature Request - Add .update_inner() to Account<'info, T> to update data with one line
2 participants