Skip to content

Commit

Permalink
Update code for recent clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
Twey committed Nov 21, 2023
1 parent 87e98fa commit cff4632
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 11 deletions.
2 changes: 1 addition & 1 deletion linera-core/src/data_types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ impl CrossChainRequest {
CrossChainRequest::UpdateRecipient { height_map, .. } => {
height_map.iter().any(|(_, heights)| {
debug_assert!(heights.windows(2).all(|w| w[0] <= w[1]));
matches!(heights.get(0), Some(h) if *h <= height)
matches!(heights.first(), Some(h) if *h <= height)
})
}
_ => false,
Expand Down
2 changes: 1 addition & 1 deletion linera-explorer/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ async fn chains(app: &JsValue, node: &str) -> Result<ChainId> {
.serialize(&SER)
.expect("failed to serialize ChainIds");
setf(app, "chains", &chains_js);
Ok(chains.default.unwrap_or_else(|| match chains.list.get(0) {
Ok(chains.default.unwrap_or_else(|| match chains.list.first() {
None => ChainId::from(ChainDescription::Root(0)),
Some(chain_id) => *chain_id,
}))
Expand Down
4 changes: 2 additions & 2 deletions linera-views-derive/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ fn context_and_constraints(
context = Type::Path(TypePath {
qself: None,
path: template_vect
.get(0)
.first()
.expect("failed to find the first generic parameter")
.clone()
.into(),
Expand Down Expand Up @@ -126,7 +126,7 @@ fn generate_view_code(input: ItemStruct, root: bool) -> TokenStream2 {
clear_quotes.push(quote! { self.#name.clear(); });
}
let first_name_quote = name_quotes
.get(0)
.first()
.expect("list of names should be non-empty");

let increment_counter = if root {
Expand Down
6 changes: 2 additions & 4 deletions linera-views/src/queue_view.rs
Original file line number Diff line number Diff line change
Expand Up @@ -295,8 +295,7 @@ where
if count == 0 {
return Ok(Vec::new());
}
let mut values = Vec::new();
values.reserve(count);
let mut values = Vec::with_capacity(count);
if !self.was_cleared {
let stored_remainder = self.stored_count();
let start = self.stored_indices.end - stored_remainder;
Expand Down Expand Up @@ -336,8 +335,7 @@ where
if count == 0 {
return Ok(Vec::new());
}
let mut values = Vec::new();
values.reserve(count);
let mut values = Vec::with_capacity(count);
let new_back_len = self.new_back_values.len();
if count <= new_back_len || self.was_cleared {
values.extend(
Expand Down
6 changes: 3 additions & 3 deletions linera-views/tests/views_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1041,9 +1041,9 @@ async fn compute_hash_view_iter<R: RngCore>(rng: &mut R, n: usize, k: usize) {
.push(compute_hash_ordered_view(rng, &mut store3, key_value_vector.clone()).await);
}
for i in 1..n_iter {
assert_eq!(unord1_hashes.get(0).unwrap(), unord1_hashes.get(i).unwrap());
assert_eq!(unord2_hashes.get(0).unwrap(), unord2_hashes.get(i).unwrap());
assert_eq!(ord_hashes.get(0).unwrap(), ord_hashes.get(i).unwrap());
assert_eq!(unord1_hashes.first().unwrap(), unord1_hashes.get(i).unwrap());
assert_eq!(unord2_hashes.first().unwrap(), unord2_hashes.get(i).unwrap());
assert_eq!(ord_hashes.first().unwrap(), ord_hashes.get(i).unwrap());
}
}

Expand Down

0 comments on commit cff4632

Please sign in to comment.