Skip to content

Commit

Permalink
Remove mut (#82)
Browse files Browse the repository at this point in the history
  • Loading branch information
febo authored Mar 5, 2025
1 parent e9c139a commit c8d9921
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions sdk/pinocchio/src/entrypoint/lazy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ impl InstructionContext {
/// This method can only be used after all accounts have been read; otherwise, it will
/// return a [`ProgramError::InvalidInstructionData`] error.
#[inline(always)]
pub fn instruction_data(&mut self) -> Result<&[u8], ProgramError> {
pub fn instruction_data(&self) -> Result<&[u8], ProgramError> {
if self.remaining > 0 {
return Err(ProgramError::InvalidInstructionData);
}
Expand All @@ -190,7 +190,7 @@ impl InstructionContext {
/// It is up to the caller to guarantee that all accounts have been read; calling this method
/// before reading all accounts will result in undefined behavior.
#[inline(always)]
pub unsafe fn instruction_data_unchecked(&mut self) -> &[u8] {
pub unsafe fn instruction_data_unchecked(&self) -> &[u8] {
let data_len = *(self.input.add(self.offset) as *const usize);
// shadowing the offset to avoid leaving it in an inconsistent state
let offset = self.offset + core::mem::size_of::<u64>();
Expand All @@ -202,7 +202,7 @@ impl InstructionContext {
/// This method can only be used after all accounts have been read; otherwise, it will
/// return a [`ProgramError::InvalidInstructionData`] error.
#[inline(always)]
pub fn program_id(&mut self) -> Result<&Pubkey, ProgramError> {
pub fn program_id(&self) -> Result<&Pubkey, ProgramError> {
if self.remaining > 0 {
return Err(ProgramError::InvalidInstructionData);
}
Expand All @@ -217,9 +217,8 @@ impl InstructionContext {
/// It is up to the caller to guarantee that all accounts have been read; calling this method
/// before reading all accounts will result in undefined behavior.
#[inline(always)]
pub unsafe fn program_id_unchecked(&mut self) -> &Pubkey {
pub unsafe fn program_id_unchecked(&self) -> &Pubkey {
let data_len = *(self.input.add(self.offset) as *const usize);
// shadowing the offset to avoid leaving it in an inconsistent state
&*(self
.input
.add(self.offset + core::mem::size_of::<u64>() + data_len) as *const Pubkey)
Expand Down

0 comments on commit c8d9921

Please sign in to comment.