diff --git a/linera-core/src/data_types.rs b/linera-core/src/data_types.rs index 8eb09385389..3708f3a73c0 100644 --- a/linera-core/src/data_types.rs +++ b/linera-core/src/data_types.rs @@ -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, diff --git a/linera-explorer/src/lib.rs b/linera-explorer/src/lib.rs index 8815f311145..9503d9d63de 100644 --- a/linera-explorer/src/lib.rs +++ b/linera-explorer/src/lib.rs @@ -278,7 +278,7 @@ async fn chains(app: &JsValue, node: &str) -> Result { .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, })) diff --git a/linera-views-derive/src/lib.rs b/linera-views-derive/src/lib.rs index 06e23e52551..7c65d840e4d 100644 --- a/linera-views-derive/src/lib.rs +++ b/linera-views-derive/src/lib.rs @@ -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(), @@ -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 { diff --git a/linera-views/src/queue_view.rs b/linera-views/src/queue_view.rs index 1d5e87d58bd..0e48ae8e3b1 100644 --- a/linera-views/src/queue_view.rs +++ b/linera-views/src/queue_view.rs @@ -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; @@ -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( diff --git a/linera-views/tests/views_tests.rs b/linera-views/tests/views_tests.rs index d34d9b954f8..848f679fa62 100644 --- a/linera-views/tests/views_tests.rs +++ b/linera-views/tests/views_tests.rs @@ -1041,9 +1041,9 @@ async fn compute_hash_view_iter(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()); } }