diff --git a/bench/usage/cornucopia_benches/mod.rs b/bench/usage/cornucopia_benches/mod.rs index d81081f7..46343a75 100644 --- a/bench/usage/cornucopia_benches/mod.rs +++ b/bench/usage/cornucopia_benches/mod.rs @@ -47,15 +47,11 @@ pub fn bench_insert(b: &mut Bencher, client: &mut Client, size: usize) { let mut stmt = insert_user(); b.iter(|| { block_on(async { - let mut tx = client.transaction().await.unwrap(); + let tx = client.transaction().await.unwrap(); for x in 0..size { - stmt.bind( - &mut tx, - &format!("User {}", x).as_str(), - &Some("hair_color"), - ) - .await - .unwrap(); + stmt.bind(&tx, &format!("User {x}").as_str(), &Some("hair_color")) + .await + .unwrap(); } tx.commit().await.unwrap(); }) @@ -105,8 +101,7 @@ pub fn loading_associations_sequentially(b: &mut Bencher, client: &Client) { } users - .into_iter() - .map(|(_, users_with_post_and_comment)| users_with_post_and_comment) + .into_values() .collect::)>)>>() }) }) @@ -156,12 +151,8 @@ pub mod sync { b.iter(|| { let mut tx = client.transaction().unwrap(); for x in 0..size { - stmt.bind( - &mut tx, - &format!("User {}", x).as_str(), - &Some("hair_color"), - ) - .unwrap(); + stmt.bind(&mut tx, &format!("User {x}").as_str(), &Some("hair_color")) + .unwrap(); } tx.commit().unwrap(); }) @@ -205,8 +196,7 @@ pub mod sync { } users - .into_iter() - .map(|(_, users_with_post_and_comment)| users_with_post_and_comment) + .into_values() .collect::)>)>>() }) } diff --git a/bench/usage/diesel_benches.rs b/bench/usage/diesel_benches.rs index 307b1c80..5c7407e1 100644 --- a/bench/usage/diesel_benches.rs +++ b/bench/usage/diesel_benches.rs @@ -114,7 +114,7 @@ fn insert_users Option<&'static str>, const N: usize>( let mut data = Box::new([DUMMY_USER; N]); for (idx, user) in data.iter_mut().enumerate() { - *user = NewUser::new(&format!("User {}", idx), hair_color_init(idx)); + *user = NewUser::new(&format!("User {idx}"), hair_color_init(idx)); } insert_into(users::table) @@ -125,7 +125,7 @@ fn insert_users Option<&'static str>, const N: usize>( let mut data = [DUMMY_USER; N]; for (idx, user) in data.iter_mut().enumerate() { - *user = NewUser::new(&format!("User {}", idx), hair_color_init(idx)); + *user = NewUser::new(&format!("User {idx}"), hair_color_init(idx)); } insert_into(users::table) diff --git a/bench/usage/main.rs b/bench/usage/main.rs index 8768c904..f5b53d4c 100644 --- a/bench/usage/main.rs +++ b/bench/usage/main.rs @@ -37,7 +37,7 @@ fn prepare_client( 2 * x + 2 ) .unwrap(); - params.push((format!("User {}", x), hair_color_init(x))); + params.push((format!("User {x}"), hair_color_init(x))); } let params = params @@ -63,7 +63,7 @@ fn prepare_full(client: &mut Client) { let data = user_ids .iter() .flat_map(|user_id| { - (0..10).map(move |i| (format!("Post {} by user {}", i, user_id), user_id, None)) + (0..10).map(move |i| (format!("Post {i} by user {user_id}"), user_id, None)) }) .collect::>(); @@ -100,7 +100,7 @@ fn prepare_full(client: &mut Client) { let data = all_posts .iter() .flat_map(|post_id| { - (0..10).map(move |i| (format!("Comment {} on post {}", i, post_id), post_id)) + (0..10).map(move |i| (format!("Comment {i} on post {post_id}"), post_id)) }) .collect::>(); diff --git a/bench/usage/postgres_benches.rs b/bench/usage/postgres_benches.rs index 1d4dd8ce..8c0116ed 100644 --- a/bench/usage/postgres_benches.rs +++ b/bench/usage/postgres_benches.rs @@ -65,16 +65,12 @@ pub fn bench_medium_complex_query(b: &mut Bencher, client: &mut Client) { name: row.get(1), hair_color: row.get(2), }; - let post = if let Some(id) = row.get(3) { - Some(Post { - id, - user_id: row.get(4), - title: row.get(5), - body: row.get(6), - }) - } else { - None - }; + let post = row.get::>(3).map(|id| Post { + id, + user_id: row.get(4), + title: row.get(5), + body: row.get(6), + }); Ok((user, post)) }) .collect::>() @@ -97,7 +93,7 @@ pub fn bench_insert(b: &mut Bencher, client: &mut Client, size: usize) { 2 * x + 2 ) .unwrap(); - params.push((format!("User {}", x), Some("hair_color"))); + params.push((format!("User {x}"), Some("hair_color"))); } let params = params @@ -206,8 +202,7 @@ pub fn loading_associations_sequentially(b: &mut Bencher, client: &mut Client) { } users - .into_iter() - .map(|(_, users_with_post_and_comment)| users_with_post_and_comment) + .into_values() .collect::)>)>>() }) } diff --git a/bench/usage/tokio_postgres_benches.rs b/bench/usage/tokio_postgres_benches.rs index ba7b3dbb..4a11f4e2 100644 --- a/bench/usage/tokio_postgres_benches.rs +++ b/bench/usage/tokio_postgres_benches.rs @@ -80,16 +80,12 @@ pub fn bench_medium_complex_query(b: &mut Bencher, client: &mut Client) { name: row.get(1), hair_color: row.get(2), }, - if let Some(id) = row.get(3) { - Some(Post { - id, - user_id: row.get(4), - title: row.get(5), - body: row.get(6), - }) - } else { - None - }, + row.get::>(3).map(|id| Post { + id, + user_id: row.get(4), + title: row.get(5), + body: row.get(6), + }), ) }) }) @@ -116,7 +112,7 @@ pub fn bench_insert(b: &mut Bencher, client: &mut Client, size: usize) { 2 * x + 2 ) .unwrap(); - params.push((format!("User {}", x), Some("hair_color"))); + params.push((format!("User {x}"), Some("hair_color"))); } let params = params @@ -236,8 +232,7 @@ pub fn loading_associations_sequentially(b: &mut Bencher, client: &mut Client) { } users - .into_iter() - .map(|(_, users_with_post_and_comment)| users_with_post_and_comment) + .into_values() .collect::)>)>>() }); }) diff --git a/cornucopia/src/type_registrar.rs b/cornucopia/src/type_registrar.rs index c26b538a..bf199cb2 100644 --- a/cornucopia/src/type_registrar.rs +++ b/cornucopia/src/type_registrar.rs @@ -242,7 +242,7 @@ impl CornucopiaType { } => { if !is_copy && !is_params { let path = custom_ty_path(pg_ty.schema(), struct_name, ctx); - format!("{}Params<'a>", path) + format!("{path}Params<'a>") } else { self.brw_ty(is_inner_nullable, true, ctx) } @@ -293,7 +293,7 @@ impl CornucopiaType { if *is_copy { path } else { - format!("{}Borrowed<{lifetime}>", path) + format!("{path}Borrowed<{lifetime}>") } } } @@ -302,13 +302,13 @@ impl CornucopiaType { pub fn custom_ty_path(schema: &str, struct_name: &str, ctx: &GenCtx) -> String { if ctx.depth == 0 { - format!("{}::{}", schema, struct_name) + format!("{schema}::{struct_name}") } else if ctx.depth == 1 { - format!("super::{}::{}", schema, struct_name) + format!("super::{schema}::{struct_name}") } else { ctx.path( ctx.depth, - format_args!("types::{}::{}", schema, struct_name), + format_args!("types::{schema}::{struct_name}"), ) } }