Skip to content

Commit

Permalink
Rust 1.82.0: Use core::iter::repeat_n
Browse files Browse the repository at this point in the history
  • Loading branch information
Tumas committed Dec 9, 2024
1 parent 4fdd627 commit 273b9e8
Show file tree
Hide file tree
Showing 10 changed files with 19 additions and 17 deletions.
2 changes: 2 additions & 0 deletions clippy.toml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ disallowed-methods = [
{ path = 'tokio::fs::write', reason = 'use fs_err::tokio::write for more helpful error messages' },

{ path = 'axum::Router::nest', reason = 'specify full resource paths for searchability' },

{ path = 'itertools::repeat_n', reason = 'use core::iter::repeat_n' },
]
disallowed-types = [
{ path = 'std::fs::DirEntry', reason = 'use fs_err::DirEntry for more helpful error messages' },
Expand Down
4 changes: 2 additions & 2 deletions fork_choice_store/src/store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ impl<P: Preset> Store<P> {
};

let validator_count = anchor_state.validators().len_usize();
let latest_messages = itertools::repeat_n(None, validator_count).collect();
let latest_messages = core::iter::repeat_n(None, validator_count).collect();

Self {
chain_config,
Expand Down Expand Up @@ -2446,7 +2446,7 @@ impl<P: Preset> Store<P> {
fn extend_latest_messages_after_finalization(&mut self) {
let old_length = self.latest_messages.len();
let new_length = self.last_finalized().state(self).validators().len_usize();
let added_vacancies = itertools::repeat_n(None, new_length - old_length);
let added_vacancies = core::iter::repeat_n(None, new_length - old_length);

self.latest_messages.extend(added_vacancies);
}
Expand Down
2 changes: 1 addition & 1 deletion ssz/src/contiguous_vector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ impl<T, N: ArrayLength<T>> ContiguousVector<T, N> {
where
T: Clone,
{
Self::try_from_iter(itertools::repeat_n(element, N::USIZE))
Self::try_from_iter(core::iter::repeat_n(element, N::USIZE))
.expect("length of iterator matches type parameter")
}
}
Expand Down
4 changes: 2 additions & 2 deletions ssz/src/merkle_tree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -393,12 +393,12 @@ mod tests {
let ff_hash_1 = hashing::hash_256_256(ff_hash_0, ff_hash_0);
let ff_hash_2 = hashing::hash_256_256(ff_hash_1, ff_hash_1);

let chunks = itertools::repeat_n(ff_hash_0, capacity);
let chunks = core::iter::repeat_n(ff_hash_0, capacity);
let chunk_indices = 0..capacity;
let proof_indices = chunk_indices.clone();

let expected_proof = [ff_hash_0, ff_hash_1, ff_hash_2, hash_of_length(capacity)].into();
let expected_proofs = itertools::repeat_n(expected_proof, capacity);
let expected_proofs = core::iter::repeat_n(expected_proof, capacity);

let actual_proofs = MerkleTree::<Depth>::default().extend_and_construct_proofs(
chunks,
Expand Down
4 changes: 2 additions & 2 deletions transition_functions/src/altair/epoch_intermediates.rs
Original file line number Diff line number Diff line change
Expand Up @@ -366,12 +366,12 @@ mod spec_tests {

TestDeltas::assert_equal(
epoch_deltas.iter().map(|deltas| deltas.head_reward),
itertools::repeat_n(0, epoch_deltas.len()),
core::iter::repeat_n(0, epoch_deltas.len()),
case.ssz_default("head_deltas"),
);

TestDeltas::assert_equal(
itertools::repeat_n(0, epoch_deltas.len()),
core::iter::repeat_n(0, epoch_deltas.len()),
epoch_deltas.iter().map(|deltas| deltas.inactivity_penalty),
case.ssz_default("inactivity_penalty_deltas"),
);
Expand Down
4 changes: 2 additions & 2 deletions transition_functions/src/bellatrix/epoch_intermediates.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,12 +148,12 @@ mod spec_tests {

TestDeltas::assert_equal(
epoch_deltas.iter().map(|deltas| deltas.head_reward),
itertools::repeat_n(0, epoch_deltas.len()),
core::iter::repeat_n(0, epoch_deltas.len()),
case.ssz_default("head_deltas"),
);

TestDeltas::assert_equal(
itertools::repeat_n(0, epoch_deltas.len()),
core::iter::repeat_n(0, epoch_deltas.len()),
epoch_deltas.iter().map(|deltas| deltas.inactivity_penalty),
case.ssz_default("inactivity_penalty_deltas"),
);
Expand Down
4 changes: 2 additions & 2 deletions transition_functions/src/capella/epoch_intermediates.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,12 +148,12 @@ mod spec_tests {

TestDeltas::assert_equal(
epoch_deltas.iter().map(|deltas| deltas.head_reward),
itertools::repeat_n(0, epoch_deltas.len()),
core::iter::repeat_n(0, epoch_deltas.len()),
case.ssz_default("head_deltas"),
);

TestDeltas::assert_equal(
itertools::repeat_n(0, epoch_deltas.len()),
core::iter::repeat_n(0, epoch_deltas.len()),
epoch_deltas.iter().map(|deltas| deltas.inactivity_penalty),
case.ssz_default("inactivity_penalty_deltas"),
);
Expand Down
4 changes: 2 additions & 2 deletions transition_functions/src/deneb/epoch_intermediates.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,12 +148,12 @@ mod spec_tests {

TestDeltas::assert_equal(
epoch_deltas.iter().map(|deltas| deltas.head_reward),
itertools::repeat_n(0, epoch_deltas.len()),
core::iter::repeat_n(0, epoch_deltas.len()),
case.ssz_default("head_deltas"),
);

TestDeltas::assert_equal(
itertools::repeat_n(0, epoch_deltas.len()),
core::iter::repeat_n(0, epoch_deltas.len()),
epoch_deltas.iter().map(|deltas| deltas.inactivity_penalty),
case.ssz_default("inactivity_penalty_deltas"),
);
Expand Down
4 changes: 2 additions & 2 deletions transition_functions/src/electra/epoch_intermediates.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,12 +148,12 @@ mod spec_tests {

TestDeltas::assert_equal(
epoch_deltas.iter().map(|deltas| deltas.head_reward),
itertools::repeat_n(0, epoch_deltas.len()),
core::iter::repeat_n(0, epoch_deltas.len()),
case.ssz_default("head_deltas"),
);

TestDeltas::assert_equal(
itertools::repeat_n(0, epoch_deltas.len()),
core::iter::repeat_n(0, epoch_deltas.len()),
epoch_deltas.iter().map(|deltas| deltas.inactivity_penalty),
case.ssz_default("inactivity_penalty_deltas"),
);
Expand Down
4 changes: 2 additions & 2 deletions transition_functions/src/phase0/epoch_intermediates.rs
Original file line number Diff line number Diff line change
Expand Up @@ -818,12 +818,12 @@ mod spec_tests {
deltas
.iter()
.map(|deltas| deltas.proposer_reward + deltas.inclusion_delay_reward),
itertools::repeat_n(0, deltas.len()),
core::iter::repeat_n(0, deltas.len()),
case.ssz_default("inclusion_delay_deltas"),
);

TestDeltas::assert_equal(
itertools::repeat_n(0, deltas.len()),
core::iter::repeat_n(0, deltas.len()),
deltas
.iter()
.map(|deltas| deltas.canceling_penalty + deltas.inactivity_penalty),
Expand Down

0 comments on commit 273b9e8

Please sign in to comment.