From be03f09325192674ea634823d54880e5b0a832a0 Mon Sep 17 00:00:00 2001 From: Denis Cornehl Date: Fri, 6 Oct 2023 07:01:09 +0200 Subject: [PATCH] fix new clippy warnings --- src/test/mod.rs | 15 ++++++++++----- src/web/mod.rs | 4 ++-- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/src/test/mod.rs b/src/test/mod.rs index cae38f059..e6e183a44 100644 --- a/src/test/mod.rs +++ b/src/test/mod.rs @@ -18,6 +18,7 @@ use reqwest::{ }; use std::thread::{self, JoinHandle}; use std::{ + fmt::Write as _, fs, net::{SocketAddr, TcpListener}, panic, @@ -508,7 +509,7 @@ impl TestDatabase { crate::db::migrate(None, &mut conn)?; // Move all sequence start positions 10000 apart to avoid overlapping primary keys - let query: String = conn + let query = conn .query( " SELECT relname @@ -523,11 +524,15 @@ impl TestDatabase { .into_iter() .map(|row| row.get(0)) .enumerate() - .map(|(i, sequence): (_, String)| { + .fold(String::new(), |mut query, (i, sequence): (_, String)| { let offset = (i + 1) * 10000; - format!(r#"ALTER SEQUENCE "{sequence}" RESTART WITH {offset};"#) - }) - .collect(); + write!( + query, + r#"ALTER SEQUENCE "{sequence}" RESTART WITH {offset};"# + ) + .expect("could not write to string"); + query + }); conn.batch_execute(&query)?; Ok(TestDatabase { pool, schema }) diff --git a/src/web/mod.rs b/src/web/mod.rs index 1714a81df..367aff9d1 100644 --- a/src/web/mod.rs +++ b/src/web/mod.rs @@ -550,7 +550,7 @@ impl MetaData { } fn parse_doc_targets(targets: Value) -> Vec { - let mut targets = targets + let mut targets: Vec<_> = targets .as_array() .map(|array| { array @@ -558,7 +558,7 @@ impl MetaData { .filter_map(|item| item.as_str().map(|s| s.to_owned())) .collect() }) - .unwrap_or_else(Vec::new); + .unwrap_or_default(); targets.sort_unstable(); targets }