diff --git a/accounts-db/src/accounts_db.rs b/accounts-db/src/accounts_db.rs index e8435ff2218edb..7e8992aa3ca4a7 100644 --- a/accounts-db/src/accounts_db.rs +++ b/accounts-db/src/accounts_db.rs @@ -10938,7 +10938,7 @@ pub mod tests { expected[0].push(raw_expected[index]); } let mut result2 = (0..range).map(|_| Vec::default()).collect::>(); - if let Some(m) = result.get(0) { + if let Some(m) = result.first() { m.load_all(&mut result2, bin, &PubkeyBinCalculator24::new(bins)); } else { result2 = vec![]; diff --git a/banks-server/src/banks_server.rs b/banks-server/src/banks_server.rs index a04d542108e923..a97019a1207fba 100644 --- a/banks-server/src/banks_server.rs +++ b/banks-server/src/banks_server.rs @@ -217,7 +217,7 @@ impl Banks for BanksServer { .root_bank() .get_blockhash_last_valid_block_height(blockhash) .unwrap(); - let signature = transaction.signatures.get(0).cloned().unwrap_or_default(); + let signature = transaction.signatures.first().cloned().unwrap_or_default(); let info = TransactionInfo::new( signature, serialize(&transaction).unwrap(), diff --git a/cli/src/program.rs b/cli/src/program.rs index 4222c732e07fde..04f1a4b3f72a55 100644 --- a/cli/src/program.rs +++ b/cli/src/program.rs @@ -2104,7 +2104,7 @@ fn check_payer( } if !write_messages.is_empty() { // Assume all write messages cost the same - if let Some(message) = write_messages.get(0) { + if let Some(message) = write_messages.first() { fee += rpc_client.get_fee_for_message(message)? * (write_messages.len() as u64); } } diff --git a/cli/src/program_v4.rs b/cli/src/program_v4.rs index 324f3040b83d4c..198ecf7ea6dc7b 100644 --- a/cli/src/program_v4.rs +++ b/cli/src/program_v4.rs @@ -795,7 +795,7 @@ fn check_payer( } if !write_messages.is_empty() { // Assume all write messages cost the same - if let Some(message) = write_messages.get(0) { + if let Some(message) = write_messages.first() { fee += rpc_client.get_fee_for_message(message)? * (write_messages.len() as u64); } } diff --git a/cli/src/stake.rs b/cli/src/stake.rs index 337b2843ff2229..31cbaab21802e1 100644 --- a/cli/src/stake.rs +++ b/cli/src/stake.rs @@ -2603,8 +2603,8 @@ pub fn process_delegate_stake( // filter should return at most one result let rpc_vote_account = current - .get(0) - .or_else(|| delinquent.get(0)) + .first() + .or_else(|| delinquent.first()) .ok_or(CliError::RpcRequestError(format!( "Vote account not found: {vote_account_pubkey}" )))?; diff --git a/core/src/banking_stage/consumer.rs b/core/src/banking_stage/consumer.rs index 9f9edcf89fd6bb..19a3aa515a0e8b 100644 --- a/core/src/banking_stage/consumer.rs +++ b/core/src/banking_stage/consumer.rs @@ -1264,7 +1264,7 @@ mod tests { let commit_transactions_result = commit_transactions_result.unwrap(); assert_eq!(commit_transactions_result.len(), 2); assert_matches!( - commit_transactions_result.get(0), + commit_transactions_result.first(), Some(CommitTransactionDetails::Committed { .. }) ); assert_matches!( @@ -1274,7 +1274,7 @@ mod tests { assert_eq!(retryable_transaction_indexes, vec![1]); let expected_block_cost = if !apply_cost_tracker_during_replay_enabled { - let actual_bpf_execution_cost = match commit_transactions_result.get(0).unwrap() { + let actual_bpf_execution_cost = match commit_transactions_result.first().unwrap() { CommitTransactionDetails::Committed { compute_units } => *compute_units, CommitTransactionDetails::NotCommitted => { unreachable!() diff --git a/core/src/banking_stage/latest_unprocessed_votes.rs b/core/src/banking_stage/latest_unprocessed_votes.rs index 10772b74dee3cc..03184ae120ff38 100644 --- a/core/src/banking_stage/latest_unprocessed_votes.rs +++ b/core/src/banking_stage/latest_unprocessed_votes.rs @@ -64,7 +64,7 @@ impl LatestValidatorVotePacket { let &pubkey = message .message .static_account_keys() - .get(0) + .first() .ok_or(DeserializedPacketError::VoteTransactionError)?; let slot = vote_state_update_instruction.last_voted_slot().unwrap_or(0); let timestamp = vote_state_update_instruction.timestamp(); diff --git a/core/src/consensus/tower_storage.rs b/core/src/consensus/tower_storage.rs index 2e03d2006ef08e..61f3c07245105c 100644 --- a/core/src/consensus/tower_storage.rs +++ b/core/src/consensus/tower_storage.rs @@ -317,7 +317,7 @@ impl TowerStorage for EtcdTowerStorage { for op_response in response.op_responses() { if let etcd_client::TxnOpResponse::Get(get_response) = op_response { - if let Some(kv) = get_response.kvs().get(0) { + if let Some(kv) = get_response.kvs().first() { return bincode::deserialize_from(kv.value()) .map_err(|e| e.into()) .and_then(|t: SavedTowerVersions| t.try_into_tower(node_pubkey)); diff --git a/ledger/src/blockstore/blockstore_purge.rs b/ledger/src/blockstore/blockstore_purge.rs index f6b3662ed19e28..4b599a353d569c 100644 --- a/ledger/src/blockstore/blockstore_purge.rs +++ b/ledger/src/blockstore/blockstore_purge.rs @@ -401,7 +401,7 @@ impl Blockstore { .into_iter() .flat_map(|entry| entry.transactions); for (i, transaction) in transactions.enumerate() { - if let Some(&signature) = transaction.signatures.get(0) { + if let Some(&signature) = transaction.signatures.first() { batch.delete::((signature, slot))?; batch.delete::((signature, slot))?; if !primary_indexes.is_empty() { diff --git a/program-runtime/src/invoke_context.rs b/program-runtime/src/invoke_context.rs index 6ee87fefa7ccdc..db736722f834a5 100644 --- a/program-runtime/src/invoke_context.rs +++ b/program-runtime/src/invoke_context.rs @@ -984,7 +984,7 @@ mod tests { (solana_sdk::pubkey::new_rand(), loader_account), ]; let metas = vec![ - AccountMeta::new(transaction_accounts.get(0).unwrap().0, false), + AccountMeta::new(transaction_accounts.first().unwrap().0, false), AccountMeta::new(transaction_accounts.get(1).unwrap().0, false), AccountMeta::new_readonly(transaction_accounts.get(2).unwrap().0, false), ]; diff --git a/program-runtime/src/loaded_programs.rs b/program-runtime/src/loaded_programs.rs index ac16578acf6183..c4e5d20bb6b472 100644 --- a/program-runtime/src/loaded_programs.rs +++ b/program-runtime/src/loaded_programs.rs @@ -1382,7 +1382,7 @@ mod tests { .get(&program1) .expect("Failed to find the entry"); assert_eq!(second_level.len(), 1); - assert!(second_level.get(0).unwrap().is_tombstone()); + assert!(second_level.first().unwrap().is_tombstone()); assert_eq!(tombstone.deployment_slot, 10); assert_eq!(tombstone.effective_slot, 10); @@ -1398,7 +1398,7 @@ mod tests { .get(&program2) .expect("Failed to find the entry"); assert_eq!(second_level.len(), 1); - assert!(!second_level.get(0).unwrap().is_tombstone()); + assert!(!second_level.first().unwrap().is_tombstone()); let tombstone = set_tombstone( &mut cache, @@ -1411,7 +1411,7 @@ mod tests { .get(&program2) .expect("Failed to find the entry"); assert_eq!(second_level.len(), 2); - assert!(!second_level.get(0).unwrap().is_tombstone()); + assert!(!second_level.first().unwrap().is_tombstone()); assert!(second_level.get(1).unwrap().is_tombstone()); assert!(tombstone.is_tombstone()); assert_eq!(tombstone.deployment_slot, 60); diff --git a/programs/bpf_loader/src/lib.rs b/programs/bpf_loader/src/lib.rs index dd944b7c8a1513..2b745d88815775 100644 --- a/programs/bpf_loader/src/lib.rs +++ b/programs/bpf_loader/src/lib.rs @@ -2687,7 +2687,7 @@ mod tests { &elf_orig, &elf_new, ); - *instruction_accounts.get_mut(3).unwrap() = instruction_accounts.get(0).unwrap().clone(); + *instruction_accounts.get_mut(3).unwrap() = instruction_accounts.first().unwrap().clone(); process_instruction( transaction_accounts, instruction_accounts, diff --git a/programs/bpf_loader/src/syscalls/mod.rs b/programs/bpf_loader/src/syscalls/mod.rs index 5519ed3aa5db7b..2c5da75c8742d7 100644 --- a/programs/bpf_loader/src/syscalls/mod.rs +++ b/programs/bpf_loader/src/syscalls/mod.rs @@ -1644,7 +1644,7 @@ declare_builtin_function!( invoke_context.get_check_aligned(), invoke_context.get_check_size(), )? - .get(0) + .first() .ok_or(SyscallError::InvalidLength)?; if params.base_len > 512 || params.exponent_len > 512 || params.modulus_len > 512 { diff --git a/remote-wallet/src/locator.rs b/remote-wallet/src/locator.rs index ca8e7d696cffe2..581b87f609dda4 100644 --- a/remote-wallet/src/locator.rs +++ b/remote-wallet/src/locator.rs @@ -124,7 +124,7 @@ impl Locator { let host = uri.host().map(|h| h.to_string()); match (scheme, host) { (Some(scheme), Some(host)) if scheme == "usb" => { - let path = uri.path().segments().get(0).and_then(|s| { + let path = uri.path().segments().first().and_then(|s| { if !s.is_empty() { Some(s.as_str()) } else { diff --git a/rpc-test/tests/nonblocking.rs b/rpc-test/tests/nonblocking.rs index 45b1c9e8bb2237..2a346c93e25a3a 100644 --- a/rpc-test/tests/nonblocking.rs +++ b/rpc-test/tests/nonblocking.rs @@ -40,7 +40,7 @@ async fn test_tpu_send_transaction() { .get_signature_statuses(&signatures) .await .unwrap(); - if statuses.value.get(0).is_some() { + if statuses.value.first().is_some() { break; } } diff --git a/rpc-test/tests/rpc.rs b/rpc-test/tests/rpc.rs index f1c2d4acb95b28..d0245608d172d1 100644 --- a/rpc-test/tests/rpc.rs +++ b/rpc-test/tests/rpc.rs @@ -496,7 +496,7 @@ fn run_tpu_send_transaction(tpu_use_quic: bool) { loop { assert!(now.elapsed() < timeout); let statuses = rpc_client.get_signature_statuses(&signatures).unwrap(); - if statuses.value.get(0).is_some() { + if statuses.value.first().is_some() { return; } } diff --git a/runtime/src/bank.rs b/runtime/src/bank.rs index 3bf2d720933443..468ccc6fc332f6 100644 --- a/runtime/src/bank.rs +++ b/runtime/src/bank.rs @@ -6384,7 +6384,7 @@ impl Bank { pub fn process_transaction(&self, tx: &Transaction) -> Result<()> { self.try_process_transactions(std::iter::once(tx))?[0].clone()?; tx.signatures - .get(0) + .first() .map_or(Ok(()), |sig| self.get_signature_status(sig).unwrap()) } diff --git a/runtime/src/bank_client.rs b/runtime/src/bank_client.rs index 3d7f7e3e244261..e2d7012ecca908 100644 --- a/runtime/src/bank_client.rs +++ b/runtime/src/bank_client.rs @@ -44,7 +44,7 @@ impl AsyncClient for BankClient { &self, transaction: VersionedTransaction, ) -> Result { - let signature = transaction.signatures.get(0).cloned().unwrap_or_default(); + let signature = transaction.signatures.first().cloned().unwrap_or_default(); let transaction_sender = self.transaction_sender.lock().unwrap(); transaction_sender.send(transaction).unwrap(); Ok(signature) @@ -60,7 +60,7 @@ impl SyncClient for BankClient { let blockhash = self.bank.last_blockhash(); let transaction = Transaction::new(keypairs, message, blockhash); self.bank.process_transaction(&transaction)?; - Ok(transaction.signatures.get(0).cloned().unwrap_or_default()) + Ok(transaction.signatures.first().cloned().unwrap_or_default()) } /// Create and process a transaction from a single instruction. diff --git a/sdk/cargo-build-bpf/src/main.rs b/sdk/cargo-build-bpf/src/main.rs index a003a0b91cab67..3635901eeceb4d 100644 --- a/sdk/cargo-build-bpf/src/main.rs +++ b/sdk/cargo-build-bpf/src/main.rs @@ -16,7 +16,7 @@ fn main() { s.replace("--bpf", "--sbf") }) .collect::>(); - let program = if let Some(arg0) = args.get(0) { + let program = if let Some(arg0) = args.first() { let arg0 = arg0.replace("build-bpf", "build-sbf"); args.remove(0); PathBuf::from(arg0) @@ -25,7 +25,7 @@ fn main() { }; // When run as a cargo subcommand, the first program argument is the subcommand name. // Remove it - if let Some(arg0) = args.get(0) { + if let Some(arg0) = args.first() { if arg0 == "build-bpf" { args.remove(0); } diff --git a/sdk/cargo-test-bpf/src/main.rs b/sdk/cargo-test-bpf/src/main.rs index 3befa78779318e..21b8735787de19 100644 --- a/sdk/cargo-test-bpf/src/main.rs +++ b/sdk/cargo-test-bpf/src/main.rs @@ -16,7 +16,7 @@ fn main() { let cargo_build_sbf = cargo_build_bpf.replace("build-bpf", "build-sbf"); env::set_var("CARGO_BUILD_SBF", cargo_build_sbf); } - let program = if let Some(arg0) = args.get(0) { + let program = if let Some(arg0) = args.first() { let cargo_test_sbf = arg0.replace("test-bpf", "test-sbf"); let cargo_build_sbf = cargo_test_sbf.replace("test-sbf", "build-sbf"); env::set_var("CARGO_BUILD_SBF", cargo_build_sbf); @@ -27,7 +27,7 @@ fn main() { }; // When run as a cargo subcommand, the first program argument is the subcommand name. // Remove it - if let Some(arg0) = args.get(0) { + if let Some(arg0) = args.first() { if arg0 == "test-bpf" { args.remove(0); } diff --git a/turbine/src/broadcast_stage/standard_broadcast_run.rs b/turbine/src/broadcast_stage/standard_broadcast_run.rs index f574dca0d4bba4..82bd7f940c508d 100644 --- a/turbine/src/broadcast_stage/standard_broadcast_run.rs +++ b/turbine/src/broadcast_stage/standard_broadcast_run.rs @@ -580,7 +580,7 @@ mod test { // Slot 2 interrupted slot 1 let shreds = run.finish_prev_slot(&keypair, 0, &mut ProcessShredsStats::default()); let shred = shreds - .get(0) + .first() .expect("Expected a shred that signals an interrupt"); // Validate the shred diff --git a/validator/src/main.rs b/validator/src/main.rs index bb8fa537b8ecdb..0037fea465d50f 100644 --- a/validator/src/main.rs +++ b/validator/src/main.rs @@ -244,7 +244,7 @@ fn wait_for_restart_window( Err("Current epoch is almost complete".to_string()) } else { while leader_schedule - .get(0) + .front() .map(|slot| *slot < epoch_info.absolute_slot) .unwrap_or(false) { @@ -258,7 +258,7 @@ fn wait_for_restart_window( upcoming_idle_windows.pop(); } - match leader_schedule.get(0) { + match leader_schedule.front() { None => { Ok(()) // Validator has no leader slots } diff --git a/vote/src/vote_parser.rs b/vote/src/vote_parser.rs index 4b4e12770ec291..5ca00fa9445ed1 100644 --- a/vote/src/vote_parser.rs +++ b/vote/src/vote_parser.rs @@ -23,7 +23,7 @@ pub fn parse_sanitized_vote_transaction(tx: &SanitizedTransaction) -> Option Option { let first_account = usize::from(*first_instruction.accounts.first()?); let key = message.account_keys.get(first_account)?; let (vote, switch_proof_hash) = parse_vote_instruction_data(&first_instruction.data)?; - let signature = tx.signatures.get(0).cloned().unwrap_or_default(); + let signature = tx.signatures.first().cloned().unwrap_or_default(); Some((*key, vote, switch_proof_hash, signature)) } diff --git a/zk-token-sdk/src/instruction/batched_grouped_ciphertext_validity.rs b/zk-token-sdk/src/instruction/batched_grouped_ciphertext_validity.rs index 2d412f5746c3bc..ece282d8af346a 100644 --- a/zk-token-sdk/src/instruction/batched_grouped_ciphertext_validity.rs +++ b/zk-token-sdk/src/instruction/batched_grouped_ciphertext_validity.rs @@ -116,10 +116,10 @@ impl ZkProofData let grouped_ciphertext_hi: GroupedElGamalCiphertext<2> = self.context.grouped_ciphertext_hi.try_into()?; - let destination_handle_lo = grouped_ciphertext_lo.handles.get(0).unwrap(); + let destination_handle_lo = grouped_ciphertext_lo.handles.first().unwrap(); let auditor_handle_lo = grouped_ciphertext_lo.handles.get(1).unwrap(); - let destination_handle_hi = grouped_ciphertext_hi.handles.get(0).unwrap(); + let destination_handle_hi = grouped_ciphertext_hi.handles.first().unwrap(); let auditor_handle_hi = grouped_ciphertext_hi.handles.get(1).unwrap(); let proof: BatchedGroupedCiphertext2HandlesValidityProof = self.proof.try_into()?; diff --git a/zk-token-sdk/src/instruction/grouped_ciphertext_validity.rs b/zk-token-sdk/src/instruction/grouped_ciphertext_validity.rs index 59d19d11838623..c5fa91fcade304 100644 --- a/zk-token-sdk/src/instruction/grouped_ciphertext_validity.rs +++ b/zk-token-sdk/src/instruction/grouped_ciphertext_validity.rs @@ -105,7 +105,7 @@ impl ZkProofData let grouped_ciphertext: GroupedElGamalCiphertext<2> = self.context.grouped_ciphertext.try_into()?; - let destination_handle = grouped_ciphertext.handles.get(0).unwrap(); + let destination_handle = grouped_ciphertext.handles.first().unwrap(); let auditor_handle = grouped_ciphertext.handles.get(1).unwrap(); let proof: GroupedCiphertext2HandlesValidityProof = self.proof.try_into()?; diff --git a/zk-token-sdk/src/instruction/transfer/encryption.rs b/zk-token-sdk/src/instruction/transfer/encryption.rs index f9d40c0889b0e0..b554da16439bac 100644 --- a/zk-token-sdk/src/instruction/transfer/encryption.rs +++ b/zk-token-sdk/src/instruction/transfer/encryption.rs @@ -35,7 +35,7 @@ impl TransferAmountCiphertext { pub fn get_source_handle(&self) -> &DecryptHandle { // `TransferAmountCiphertext` is a wrapper for `GroupedElGamalCiphertext<3>`, which // holds exactly three decryption handles. - self.0.handles.get(0).unwrap() + self.0.handles.first().unwrap() } pub fn get_destination_handle(&self) -> &DecryptHandle { @@ -80,7 +80,7 @@ impl FeeEncryption { pub fn get_destination_handle(&self) -> &DecryptHandle { // `FeeEncryption` is a wrapper for `GroupedElGamalCiphertext<2>`, which holds // exactly two decryption handles. - self.0.handles.get(0).unwrap() + self.0.handles.first().unwrap() } pub fn get_withdraw_withheld_authority_handle(&self) -> &DecryptHandle {