Skip to content

Commit 22467b4

Browse files
authored
Merge pull request #1231 from nyurik/inline-format-args
Apply uninlined-format-args clippy lint
2 parents 56a4f16 + 2940ad0 commit 22467b4

File tree

4 files changed

+21
-21
lines changed

4 files changed

+21
-21
lines changed

src/exercise.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ fn temp_file() -> String {
2020
.filter(|c| c.is_alphanumeric())
2121
.collect();
2222

23-
format!("./temp_{}_{}", process::id(), thread_id)
23+
format!("./temp_{}_{thread_id}", process::id())
2424
}
2525

2626
// The mode of the exercise.

src/main.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -121,12 +121,12 @@ fn main() {
121121
let args: Args = argh::from_env();
122122

123123
if args.version {
124-
println!("v{}", VERSION);
124+
println!("v{VERSION}");
125125
std::process::exit(0);
126126
}
127127

128128
if args.nested.is_none() {
129-
println!("\n{}\n", WELCOME);
129+
println!("\n{WELCOME}\n");
130130
}
131131

132132
if !Path::new("info.toml").exists() {
@@ -150,7 +150,7 @@ fn main() {
150150
let verbose = args.nocapture;
151151

152152
let command = args.nested.unwrap_or_else(|| {
153-
println!("{}\n", DEFAULT_OUT);
153+
println!("{DEFAULT_OUT}\n");
154154
std::process::exit(0);
155155
});
156156
match command {
@@ -179,11 +179,11 @@ fn main() {
179179
};
180180
if solve_cond && (filter_cond || subargs.filter.is_none()) {
181181
let line = if subargs.paths {
182-
format!("{}\n", fname)
182+
format!("{fname}\n")
183183
} else if subargs.names {
184184
format!("{}\n", e.name)
185185
} else {
186-
format!("{:<17}\t{:<46}\t{:<7}\n", e.name, fname, status)
186+
format!("{:<17}\t{fname:<46}\t{status:<7}\n", e.name)
187187
};
188188
// Somehow using println! leads to the binary panicking
189189
// when its output is piped.
@@ -266,7 +266,7 @@ fn main() {
266266
"{emoji} All exercises completed! {emoji}",
267267
emoji = Emoji("🎉", "★")
268268
);
269-
println!("\n{}\n", FENISH_LINE);
269+
println!("\n{FENISH_LINE}\n");
270270
}
271271
Ok(WatchStatus::Unfinished) => {
272272
println!("We hope you're enjoying learning about Rust!");
@@ -289,7 +289,7 @@ fn spawn_watch_shell(
289289
let input = input.trim();
290290
if input == "hint" {
291291
if let Some(hint) = &*failed_exercise_hint.lock().unwrap() {
292-
println!("{}", hint);
292+
println!("{hint}");
293293
}
294294
} else if input == "clear" {
295295
println!("\x1B[2J\x1B[1;1H");
@@ -306,10 +306,10 @@ fn spawn_watch_shell(
306306
println!("Watch mode automatically re-evaluates the current exercise");
307307
println!("when you edit a file's contents.")
308308
} else {
309-
println!("unknown command: {}", input);
309+
println!("unknown command: {input}");
310310
}
311311
}
312-
Err(error) => println!("error reading command: {}", error),
312+
Err(error) => println!("error reading command: {error}"),
313313
}
314314
});
315315
}
@@ -329,7 +329,7 @@ fn find_exercise<'a>(name: &str, exercises: &'a [Exercise]) -> &'a Exercise {
329329
.iter()
330330
.find(|e| e.name == name)
331331
.unwrap_or_else(|| {
332-
println!("No exercise found for '{}'!", name);
332+
println!("No exercise found for '{name}'!");
333333
std::process::exit(1)
334334
})
335335
}
@@ -392,7 +392,7 @@ fn watch(exercises: &[Exercise], verbose: bool) -> notify::Result<WatchStatus> {
392392
Err(RecvTimeoutError::Timeout) => {
393393
// the timeout expired, just check the `should_quit` variable below then loop again
394394
}
395-
Err(e) => println!("watch error: {:?}", e),
395+
Err(e) => println!("watch error: {e:?}"),
396396
}
397397
// Check if we need to exit
398398
if should_quit.load(Ordering::SeqCst) {

src/run.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ pub fn reset(exercise: &Exercise) -> Result<(), ()> {
3535
// This is strictly for non-test binaries, so output is displayed
3636
fn compile_and_run(exercise: &Exercise) -> Result<(), ()> {
3737
let progress_bar = ProgressBar::new_spinner();
38-
progress_bar.set_message(format!("Compiling {}...", exercise));
38+
progress_bar.set_message(format!("Compiling {exercise}..."));
3939
progress_bar.enable_steady_tick(100);
4040

4141
let compilation_result = exercise.compile();
@@ -52,7 +52,7 @@ fn compile_and_run(exercise: &Exercise) -> Result<(), ()> {
5252
}
5353
};
5454

55-
progress_bar.set_message(format!("Running {}...", exercise));
55+
progress_bar.set_message(format!("Running {exercise}..."));
5656
let result = compilation.run();
5757
progress_bar.finish_and_clear();
5858

src/verify.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ pub fn test(exercise: &Exercise, verbose: bool) -> Result<(), ()> {
4848
// Invoke the rust compiler without running the resulting binary
4949
fn compile_only(exercise: &Exercise) -> Result<bool, ()> {
5050
let progress_bar = ProgressBar::new_spinner();
51-
progress_bar.set_message(format!("Compiling {}...", exercise));
51+
progress_bar.set_message(format!("Compiling {exercise}..."));
5252
progress_bar.enable_steady_tick(100);
5353

5454
let _ = compile(exercise, &progress_bar)?;
@@ -60,12 +60,12 @@ fn compile_only(exercise: &Exercise) -> Result<bool, ()> {
6060
// Compile the given Exercise and run the resulting binary in an interactive mode
6161
fn compile_and_run_interactively(exercise: &Exercise) -> Result<bool, ()> {
6262
let progress_bar = ProgressBar::new_spinner();
63-
progress_bar.set_message(format!("Compiling {}...", exercise));
63+
progress_bar.set_message(format!("Compiling {exercise}..."));
6464
progress_bar.enable_steady_tick(100);
6565

6666
let compilation = compile(exercise, &progress_bar)?;
6767

68-
progress_bar.set_message(format!("Running {}...", exercise));
68+
progress_bar.set_message(format!("Running {exercise}..."));
6969
let result = compilation.run();
7070
progress_bar.finish_and_clear();
7171

@@ -86,7 +86,7 @@ fn compile_and_run_interactively(exercise: &Exercise) -> Result<bool, ()> {
8686
// the output if verbose is set to true
8787
fn compile_and_test(exercise: &Exercise, run_mode: RunMode, verbose: bool) -> Result<bool, ()> {
8888
let progress_bar = ProgressBar::new_spinner();
89-
progress_bar.set_message(format!("Testing {}...", exercise));
89+
progress_bar.set_message(format!("Testing {exercise}..."));
9090
progress_bar.enable_steady_tick(100);
9191

9292
let compilation = compile(exercise, &progress_bar)?;
@@ -165,16 +165,16 @@ fn prompt_for_completion(exercise: &Exercise, prompt_output: Option<String>) ->
165165

166166
println!();
167167
if no_emoji {
168-
println!("~*~ {} ~*~", success_msg)
168+
println!("~*~ {success_msg} ~*~")
169169
} else {
170-
println!("🎉 🎉 {} 🎉 🎉", success_msg)
170+
println!("🎉 🎉 {success_msg} 🎉 🎉")
171171
}
172172
println!();
173173

174174
if let Some(output) = prompt_output {
175175
println!("Output:");
176176
println!("{}", separator());
177-
println!("{}", output);
177+
println!("{output}");
178178
println!("{}", separator());
179179
println!();
180180
}

0 commit comments

Comments
 (0)