Skip to content

Commit

Permalink
Simplify save method
Browse files Browse the repository at this point in the history
  • Loading branch information
febo committed Oct 21, 2023
1 parent 1284892 commit 70814e8
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions programs/mpl-project-name/src/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,10 @@ impl MyAccount {
}

pub fn save(&self, account: &AccountInfo) -> ProgramResult {
let mut bytes = Vec::with_capacity(account.data_len());
self.serialize(&mut bytes).map_err(|error| {
borsh::to_writer(&mut account.data.borrow_mut()[..], self).map_err(|error| {
msg!("Error: {}", error);
MplProjectNameError::SerializationError
})?;
account.try_borrow_mut_data().unwrap()[..bytes.len()].copy_from_slice(&bytes);
Ok(())
MplProjectNameError::SerializationError.into()
})
}
}

Expand Down

0 comments on commit 70814e8

Please sign in to comment.