-
Notifications
You must be signed in to change notification settings - Fork 1.7k
accounts: clippy and style fixes #11443
base: master
Are you sure you want to change the base?
Conversation
It looks like @vorot93 signed our Contributor License Agreement. 👍 Many thanks, Parity Technologies CLA Bot |
Co-Authored-By: Niklas Adolfsson <[email protected]>
Co-Authored-By: Niklas Adolfsson <[email protected]>
dst.insert(a)?; | ||
Ok(address) | ||
}).collect() | ||
let mut out = Vec::with_capacity(accounts.len()); |
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 guess that technically the lint triggered this was map().filter()
instead map_filter()
?
Then you switch to a for loop instead because it was not possible to return the error in filter_map
?
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.
Yes, I simply didn't want to untangle the mix of Option
and Result
. And in general the imperative approach seems to me much clearer than the map-and-collect of results. It also returns earlier (on first error) although I'm not sure if it's the desired behavior here.
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.
right, it seems that the actual implementation of KeyDirectory::insert
always returns Ok
but I don't know, let's ignore it for this PR.
iv.copy_from_slice(&wallet.encseed[..16]); | ||
|
||
let mut ciphertext = vec![]; | ||
let mut ciphertext = Vec::new(); |
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.
This is not a clippy-lint, right?
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.
it was not, I can drop this.
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.
It is fine for me, I like Vec::new
better but let's keep it open so the others can see this too.
let mut out = Vec::with_capacity(accounts.len()); | ||
for account in accounts { | ||
let address = account.address; | ||
if existing_accounts.contains(&address) { |
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.
to have the same behavior as before
if existing_accounts.contains(&address) { | |
if !existing_accounts.contains(&address) { |
This is the initial batch of style fixes as suggested by clippy as well as the general patterns of modern Rust. A couple of notes:
as_ref
helper method).