From 6639a629dd6106f8fb3816023e34d2ed3d4622cd Mon Sep 17 00:00:00 2001 From: Piotr Dulikowski Date: Fri, 1 Sep 2023 07:04:30 +0200 Subject: [PATCH] treewide: fix clippy complaints about useless use of vec! Clippy started to suggest using arrays instead of `vec!` where applicable, i.e. if the vector would be converted to an iterator anyway, then we can get rid of an allocation by replacing it with an array. This is only an issue with a small number of tests and it's easy to fix, so this commit just applies clippy's suggestions. --- scylla-cql/src/frame/types.rs | 6 +++--- scylla/src/transport/session_test.rs | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/scylla-cql/src/frame/types.rs b/scylla-cql/src/frame/types.rs index 71b0f78205..fd2254c8b0 100644 --- a/scylla-cql/src/frame/types.rs +++ b/scylla-cql/src/frame/types.rs @@ -142,7 +142,7 @@ fn write_int_length(v: usize, buf: &mut impl BufMut) -> Result<(), ParseError> { #[test] fn type_int() { - let vals = vec![i32::MIN, -1, 0, 1, i32::MAX]; + let vals = [i32::MIN, -1, 0, 1, i32::MAX]; for val in vals.iter() { let mut buf = Vec::new(); write_int(*val, &mut buf); @@ -161,7 +161,7 @@ pub fn write_long(v: i64, buf: &mut impl BufMut) { #[test] fn type_long() { - let vals = vec![i64::MIN, -1, 0, 1, i64::MAX]; + let vals = [i64::MIN, -1, 0, 1, i64::MAX]; for val in vals.iter() { let mut buf = Vec::new(); write_long(*val, &mut buf); @@ -192,7 +192,7 @@ fn write_short_length(v: usize, buf: &mut impl BufMut) -> Result<(), ParseError> #[test] fn type_short() { - let vals = vec![i16::MIN, -1, 0, 1, i16::MAX]; + let vals = [i16::MIN, -1, 0, 1, i16::MAX]; for val in vals.iter() { let mut buf = Vec::new(); write_short(*val, &mut buf); diff --git a/scylla/src/transport/session_test.rs b/scylla/src/transport/session_test.rs index 6bc9f0e4f1..805217053d 100644 --- a/scylla/src/transport/session_test.rs +++ b/scylla/src/transport/session_test.rs @@ -646,7 +646,7 @@ async fn test_use_keyspace() { ))) )); - let long_name: String = vec!['a'; 49].iter().collect(); + let long_name: String = ['a'; 49].iter().collect(); assert!(matches!( session.use_keyspace(long_name, false).await, Err(QueryError::BadQuery(BadQuery::BadKeyspaceName(