Skip to content
This repository has been archived by the owner on Jan 13, 2025. It is now read-only.

Commit

Permalink
Use enumerate() where apt
Browse files Browse the repository at this point in the history
  • Loading branch information
carllin committed Nov 24, 2018
1 parent 1d234aa commit 29a9ef4
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
10 changes: 7 additions & 3 deletions src/db_ledger.rs
Original file line number Diff line number Diff line change
Expand Up @@ -294,8 +294,12 @@ impl DbLedger {
I: IntoIterator<Item = &'a Entry>,
{
let default_addr = SocketAddr::new(IpAddr::V4(Ipv4Addr::new(0, 0, 0, 0)), 0);
let shared_blobs = entries.into_iter().zip(0..).map(|(entry, idx)| {
entry.to_blob(Some(idx), Some(Pubkey::default()), Some(&default_addr))
let shared_blobs = entries.into_iter().enumerate().map(|(idx, entry)| {
entry.to_blob(
Some(idx as u64),
Some(Pubkey::default()),
Some(&default_addr),
)
});
self.write_shared_blobs(slot, shared_blobs)
}
Expand Down Expand Up @@ -661,7 +665,7 @@ mod tests {
let num_entries = 8;
let shared_blobs = make_tiny_test_entries(num_entries).to_blobs();

for (b, i) in shared_blobs.iter().zip(0..num_entries) {
for (i, b) in shared_blobs.iter().enumerate() {
b.write().unwrap().set_index(1 << (i * 8)).unwrap();
}

Expand Down
4 changes: 2 additions & 2 deletions src/db_window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -531,8 +531,8 @@ mod test {
assert!(gap > 3);
let num_entries = 10;
let shared_blobs = make_tiny_test_entries(num_entries).to_blobs();
for (b, i) in shared_blobs.iter().zip(0..shared_blobs.len() as u64) {
b.write().unwrap().set_index(i * gap).unwrap();
for (i, b) in shared_blobs.iter().enumerate() {
b.write().unwrap().set_index(i as u64 * gap).unwrap();
}
let blob_locks: Vec<_> = shared_blobs.iter().map(|b| b.read().unwrap()).collect();
let blobs: Vec<&Blob> = blob_locks.iter().map(|b| &**b).collect();
Expand Down

0 comments on commit 29a9ef4

Please sign in to comment.