Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

clippy: Replaces .get(0) with .first() #34048

Merged
merged 2 commits into from
Nov 13, 2023

Conversation

brooksprumo
Copy link
Contributor

Problem

There are nightly clippy warnings that will prevent upgrading our stable Rust version.

For this PR, it's this one: https://rust-lang.github.io/rust-clippy/master/index.html#/get(0)

Summary of Changes

Replaces .get(0) with .first().

@brooksprumo brooksprumo self-assigned this Nov 13, 2023
@@ -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),
Copy link
Contributor Author

@brooksprumo brooksprumo Nov 13, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One could argue that the original .get(0) is better since we do get() on 0, 1, then 2. We'd need to add a clippy-allow to go back to that way.

Using .first() doesn't bother me here; I have a slight preference for .first() versus adding a clippy-allow exception.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i could argue that using the get() interface here is a bit dubious in the first place. same with anywhere else we're doing a .get(n).unwrap()

@brooksprumo brooksprumo marked this pull request as ready for review November 13, 2023 20:49
Copy link

codecov bot commented Nov 13, 2023

Codecov Report

Merging #34048 (b509d61) into master (47a98eb) will decrease coverage by 0.1%.
Report is 3 commits behind head on master.
The diff coverage is 91.6%.

@@            Coverage Diff            @@
##           master   #34048     +/-   ##
=========================================
- Coverage    81.9%    81.9%   -0.1%     
=========================================
  Files         811      811             
  Lines      219552   219552             
=========================================
- Hits       179902   179858     -44     
- Misses      39650    39694     +44     

Copy link
Contributor

@t-nelson t-nelson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@@ -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),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i could argue that using the get() interface here is a bit dubious in the first place. same with anywhere else we're doing a .get(n).unwrap()

@brooksprumo brooksprumo merged commit 725ab37 into solana-labs:master Nov 13, 2023
42 checks passed
@brooksprumo brooksprumo deleted the clippy/get0 branch November 13, 2023 22:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants