-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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
Conversation
@@ -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), |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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()
Codecov Report
@@ 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 |
There was a problem hiding this 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), |
There was a problem hiding this comment.
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()
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()
.