Skip to content

Commit

Permalink
fix new clippy warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
syphar committed Oct 6, 2023
1 parent af91b40 commit be03f09
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
15 changes: 10 additions & 5 deletions src/test/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ use reqwest::{
};
use std::thread::{self, JoinHandle};
use std::{
fmt::Write as _,
fs,
net::{SocketAddr, TcpListener},
panic,
Expand Down Expand Up @@ -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
Expand All @@ -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 })
Expand Down
4 changes: 2 additions & 2 deletions src/web/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -550,15 +550,15 @@ impl MetaData {
}

fn parse_doc_targets(targets: Value) -> Vec<String> {
let mut targets = targets
let mut targets: Vec<_> = targets
.as_array()
.map(|array| {
array
.iter()
.filter_map(|item| item.as_str().map(|s| s.to_owned()))
.collect()
})
.unwrap_or_else(Vec::new);
.unwrap_or_default();
targets.sort_unstable();
targets
}
Expand Down

0 comments on commit be03f09

Please sign in to comment.