Skip to content

Commit

Permalink
treewide: fix clippy complaints about useless use of vec!
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
piodul committed Sep 1, 2023
1 parent 96a23f2 commit 6639a62
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions scylla-cql/src/frame/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion scylla/src/transport/session_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit 6639a62

Please sign in to comment.