I follow hackernoon-solana to see the syntax in non anchor project. this is the function signature
pub fn process_instruction(program_id:&Pubkey,accounts:&[AccountInfo],input:&[u8])->ProgramResult{}
we pass accounts:&[AccountInfo]
array as an arg. Args are always byte array
// Iterating accounts is safer then indexing
let accounts_iter = &mut accounts.iter();
Then I get the first account
let account = next_account_info(accounts_iter)?;
then deserialize the passed arg. in rust arguments are an array of bytes
let mut greeting_account = GreetingAccount::try_from_slice(&account.data.borrow())?;
So far so good. but I did not understand this line:
greeting_account.serialize(&mut &mut account.data.borrow_mut()[..])?;
We are storing the data inside greeting_account
. BUt what is this [..]
for? account
is a single object, how can we use a range operator on an object?