Skip to content

Commit a824e84

Browse files
authored
Cleanup format arguments (transact-rs#2650)
Inlined format args make code more readable, and code more compact. I ran this clippy command to fix most cases, and then cleaned up a few trailing commas and uncaught edge cases. ``` cargo clippy --bins --examples --benches --tests --lib --workspace --fix -- -A clippy::all -W clippy::uninlined_format_args ```
1 parent 9463b75 commit a824e84

80 files changed

Lines changed: 270 additions & 307 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

examples/mysql/todos/src/main.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,16 @@ async fn main() -> anyhow::Result<()> {
2121

2222
match args.cmd {
2323
Some(Command::Add { description }) => {
24-
println!("Adding new todo with description '{}'", &description);
24+
println!("Adding new todo with description '{description}'");
2525
let todo_id = add_todo(&pool, description).await?;
26-
println!("Added new todo with id {}", todo_id);
26+
println!("Added new todo with id {todo_id}");
2727
}
2828
Some(Command::Done { id }) => {
29-
println!("Marking todo {} as done", id);
29+
println!("Marking todo {id} as done");
3030
if complete_todo(&pool, id).await? {
31-
println!("Todo {} is marked as done", id);
31+
println!("Todo {id} is marked as done");
3232
} else {
33-
println!("Invalid id {}", id);
33+
println!("Invalid id {id}");
3434
}
3535
}
3636
None => {

examples/postgres/axum-social-with-tests/src/http/error.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ impl IntoResponse for Error {
4949

5050
// Normally you wouldn't just print this, but it's useful for debugging without
5151
// using a logging framework.
52-
println!("API error: {:?}", self);
52+
println!("API error: {self:?}");
5353

5454
(
5555
self.status_code(),

examples/postgres/axum-social-with-tests/tests/common.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,20 +53,20 @@ pub async fn response_json(resp: &mut Response<BoxBody>) -> serde_json::Value {
5353
pub fn expect_string(value: &serde_json::Value) -> &str {
5454
value
5555
.as_str()
56-
.unwrap_or_else(|| panic!("expected string, got {:?}", value))
56+
.unwrap_or_else(|| panic!("expected string, got {value:?}"))
5757
}
5858

5959
#[track_caller]
6060
pub fn expect_uuid(value: &serde_json::Value) -> Uuid {
6161
expect_string(value)
6262
.parse::<Uuid>()
63-
.unwrap_or_else(|e| panic!("failed to parse UUID from {:?}: {}", value, e))
63+
.unwrap_or_else(|e| panic!("failed to parse UUID from {value:?}: {e}"))
6464
}
6565

6666
#[track_caller]
6767
pub fn expect_rfc3339_timestamp(value: &serde_json::Value) -> OffsetDateTime {
6868
let s = expect_string(value);
6969

7070
OffsetDateTime::parse(s, &Rfc3339)
71-
.unwrap_or_else(|e| panic!("failed to parse RFC-3339 timestamp from {:?}: {}", value, e))
71+
.unwrap_or_else(|e| panic!("failed to parse RFC-3339 timestamp from {value:?}: {e}"))
7272
}

examples/postgres/chat/src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ async fn main() -> Result<(), Box<dyn Error>> {
157157
terminal.show_cursor()?;
158158

159159
if let Err(err) = res {
160-
println!("{:?}", err)
160+
println!("{err:?}")
161161
}
162162

163163
Ok(())

examples/postgres/files/src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ async fn main() -> anyhow::Result<()> {
4141
.await?;
4242

4343
for post_with_author in posts_with_authors {
44-
println!("{}", post_with_author);
44+
println!("{post_with_author}");
4545
}
4646

4747
Ok(())

examples/postgres/json/src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ async fn main() -> anyhow::Result<()> {
4747
);
4848

4949
let person_id = add_person(&pool, person).await?;
50-
println!("Added new person with ID {}", person_id);
50+
println!("Added new person with ID {person_id}");
5151
}
5252
None => {
5353
println!("Printing all people");

examples/postgres/listen/src/main.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
3838
let mut counter = 0usize;
3939
loop {
4040
let notification = listener.recv().await?;
41-
println!("[from recv]: {:?}", notification);
41+
println!("[from recv]: {notification:?}");
4242

4343
counter += 1;
4444
if counter >= 3 {
@@ -58,7 +58,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
5858
tokio::select! {
5959
res = stream.try_next() => {
6060
if let Some(notification) = res? {
61-
println!("[from stream]: {:?}", notification);
61+
println!("[from stream]: {notification:?}");
6262
} else {
6363
break;
6464
}
@@ -106,5 +106,5 @@ from (
106106
.execute(pool)
107107
.await;
108108

109-
println!("[from notify]: {:?}", res);
109+
println!("[from notify]: {res:?}");
110110
}

examples/postgres/mockable-todos/src/main.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,14 @@ async fn handle_command(
3939
&description
4040
)?;
4141
let todo_id = todo_repo.add_todo(description).await?;
42-
writeln!(writer, "Added new todo with id {}", todo_id)?;
42+
writeln!(writer, "Added new todo with id {todo_id}")?;
4343
}
4444
Some(Command::Done { id }) => {
45-
writeln!(writer, "Marking todo {} as done", id)?;
45+
writeln!(writer, "Marking todo {id} as done")?;
4646
if todo_repo.complete_todo(id).await? {
47-
writeln!(writer, "Todo {} is marked as done", id)?;
47+
writeln!(writer, "Todo {id} is marked as done")?;
4848
} else {
49-
writeln!(writer, "Invalid id {}", id)?;
49+
writeln!(writer, "Invalid id {id}")?;
5050
}
5151
}
5252
None => {

examples/postgres/todos/src/main.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,16 @@ async fn main() -> anyhow::Result<()> {
2121

2222
match args.cmd {
2323
Some(Command::Add { description }) => {
24-
println!("Adding new todo with description '{}'", &description);
24+
println!("Adding new todo with description '{description}'");
2525
let todo_id = add_todo(&pool, description).await?;
26-
println!("Added new todo with id {}", todo_id);
26+
println!("Added new todo with id {todo_id}");
2727
}
2828
Some(Command::Done { id }) => {
29-
println!("Marking todo {} as done", id);
29+
println!("Marking todo {id} as done");
3030
if complete_todo(&pool, id).await? {
31-
println!("Todo {} is marked as done", id);
31+
println!("Todo {id} is marked as done");
3232
} else {
33-
println!("Invalid id {}", id);
33+
println!("Invalid id {id}");
3434
}
3535
}
3636
None => {

examples/sqlite/todos/src/main.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,16 @@ async fn main() -> anyhow::Result<()> {
2121

2222
match args.cmd {
2323
Some(Command::Add { description }) => {
24-
println!("Adding new todo with description '{}'", &description);
24+
println!("Adding new todo with description '{description}'");
2525
let todo_id = add_todo(&pool, description).await?;
26-
println!("Added new todo with id {}", todo_id);
26+
println!("Added new todo with id {todo_id}");
2727
}
2828
Some(Command::Done { id }) => {
29-
println!("Marking todo {} as done", id);
29+
println!("Marking todo {id} as done");
3030
if complete_todo(&pool, id).await? {
31-
println!("Todo {} is marked as done", id);
31+
println!("Todo {id} is marked as done");
3232
} else {
33-
println!("Invalid id {}", id);
33+
println!("Invalid id {id}");
3434
}
3535
}
3636
None => {

0 commit comments

Comments
 (0)