Skip to content
This repository was archived by the owner on Mar 11, 2025. It is now read-only.

Commit 10559ae

Browse files
committed
Reduce mut usage
1 parent 1bcd07d commit 10559ae

File tree

1 file changed

+5
-14
lines changed

1 file changed

+5
-14
lines changed

token/program-2022/src/processor.rs

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -839,9 +839,7 @@ impl Processor {
839839
}
840840

841841
let mut source_account_data = source_account_info.data.borrow_mut();
842-
if let Ok(mut source_account) =
843-
StateWithExtensionsMut::<Account>::unpack(&mut source_account_data)
844-
{
842+
if let Ok(source_account) = StateWithExtensions::<Account>::unpack(&source_account_data) {
845843
if !source_account.base.is_native() && source_account.base.amount != 0 {
846844
return Err(TokenError::NonNativeHasBalance.into());
847845
}
@@ -859,24 +857,17 @@ impl Processor {
859857
account_info_iter.as_slice(),
860858
)?;
861859

862-
// TODO use get_extension when
863-
// https://github.com/solana-labs/solana-program-library/pull/2822 lands
864860
if let Ok(confidential_transfer_state) =
865-
source_account.get_extension_mut::<ConfidentialTransferAccount>()
861+
source_account.get_extension::<ConfidentialTransferAccount>()
866862
{
867863
confidential_transfer_state.closable()?
868864
}
869865

870-
// TODO use get_extension when
871-
// https://github.com/solana-labs/solana-program-library/pull/2822 lands
872-
if let Ok(transfer_fee_state) = source_account.get_extension_mut::<TransferFeeAmount>()
873-
{
866+
if let Ok(transfer_fee_state) = source_account.get_extension::<TransferFeeAmount>() {
874867
transfer_fee_state.closable()?
875868
}
876-
} else if let Ok(mut mint) =
877-
StateWithExtensionsMut::<Mint>::unpack(&mut source_account_data)
878-
{
879-
let extension = mint.get_extension_mut::<MintCloseAuthority>()?;
869+
} else if let Ok(mint) = StateWithExtensions::<Mint>::unpack(&source_account_data) {
870+
let extension = mint.get_extension::<MintCloseAuthority>()?;
880871
let maybe_authority: Option<Pubkey> = extension.close_authority.into();
881872
let authority = maybe_authority.ok_or(TokenError::AuthorityTypeNotSupported)?;
882873
Self::validate_owner(

0 commit comments

Comments
 (0)