Merge pull request #1231 from nyurik/inline-format-args
Apply uninlined-format-args clippy lint
This commit is contained in:
commit
22467b483b
@ -20,7 +20,7 @@ fn temp_file() -> String {
|
|||||||
.filter(|c| c.is_alphanumeric())
|
.filter(|c| c.is_alphanumeric())
|
||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
format!("./temp_{}_{}", process::id(), thread_id)
|
format!("./temp_{}_{thread_id}", process::id())
|
||||||
}
|
}
|
||||||
|
|
||||||
// The mode of the exercise.
|
// The mode of the exercise.
|
||||||
|
22
src/main.rs
22
src/main.rs
@ -121,12 +121,12 @@ fn main() {
|
|||||||
let args: Args = argh::from_env();
|
let args: Args = argh::from_env();
|
||||||
|
|
||||||
if args.version {
|
if args.version {
|
||||||
println!("v{}", VERSION);
|
println!("v{VERSION}");
|
||||||
std::process::exit(0);
|
std::process::exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if args.nested.is_none() {
|
if args.nested.is_none() {
|
||||||
println!("\n{}\n", WELCOME);
|
println!("\n{WELCOME}\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
if !Path::new("info.toml").exists() {
|
if !Path::new("info.toml").exists() {
|
||||||
@ -150,7 +150,7 @@ fn main() {
|
|||||||
let verbose = args.nocapture;
|
let verbose = args.nocapture;
|
||||||
|
|
||||||
let command = args.nested.unwrap_or_else(|| {
|
let command = args.nested.unwrap_or_else(|| {
|
||||||
println!("{}\n", DEFAULT_OUT);
|
println!("{DEFAULT_OUT}\n");
|
||||||
std::process::exit(0);
|
std::process::exit(0);
|
||||||
});
|
});
|
||||||
match command {
|
match command {
|
||||||
@ -179,11 +179,11 @@ fn main() {
|
|||||||
};
|
};
|
||||||
if solve_cond && (filter_cond || subargs.filter.is_none()) {
|
if solve_cond && (filter_cond || subargs.filter.is_none()) {
|
||||||
let line = if subargs.paths {
|
let line = if subargs.paths {
|
||||||
format!("{}\n", fname)
|
format!("{fname}\n")
|
||||||
} else if subargs.names {
|
} else if subargs.names {
|
||||||
format!("{}\n", e.name)
|
format!("{}\n", e.name)
|
||||||
} else {
|
} else {
|
||||||
format!("{:<17}\t{:<46}\t{:<7}\n", e.name, fname, status)
|
format!("{:<17}\t{fname:<46}\t{status:<7}\n", e.name)
|
||||||
};
|
};
|
||||||
// Somehow using println! leads to the binary panicking
|
// Somehow using println! leads to the binary panicking
|
||||||
// when its output is piped.
|
// when its output is piped.
|
||||||
@ -266,7 +266,7 @@ fn main() {
|
|||||||
"{emoji} All exercises completed! {emoji}",
|
"{emoji} All exercises completed! {emoji}",
|
||||||
emoji = Emoji("🎉", "★")
|
emoji = Emoji("🎉", "★")
|
||||||
);
|
);
|
||||||
println!("\n{}\n", FENISH_LINE);
|
println!("\n{FENISH_LINE}\n");
|
||||||
}
|
}
|
||||||
Ok(WatchStatus::Unfinished) => {
|
Ok(WatchStatus::Unfinished) => {
|
||||||
println!("We hope you're enjoying learning about Rust!");
|
println!("We hope you're enjoying learning about Rust!");
|
||||||
@ -289,7 +289,7 @@ fn spawn_watch_shell(
|
|||||||
let input = input.trim();
|
let input = input.trim();
|
||||||
if input == "hint" {
|
if input == "hint" {
|
||||||
if let Some(hint) = &*failed_exercise_hint.lock().unwrap() {
|
if let Some(hint) = &*failed_exercise_hint.lock().unwrap() {
|
||||||
println!("{}", hint);
|
println!("{hint}");
|
||||||
}
|
}
|
||||||
} else if input == "clear" {
|
} else if input == "clear" {
|
||||||
println!("\x1B[2J\x1B[1;1H");
|
println!("\x1B[2J\x1B[1;1H");
|
||||||
@ -306,10 +306,10 @@ fn spawn_watch_shell(
|
|||||||
println!("Watch mode automatically re-evaluates the current exercise");
|
println!("Watch mode automatically re-evaluates the current exercise");
|
||||||
println!("when you edit a file's contents.")
|
println!("when you edit a file's contents.")
|
||||||
} else {
|
} else {
|
||||||
println!("unknown command: {}", input);
|
println!("unknown command: {input}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Err(error) => println!("error reading command: {}", error),
|
Err(error) => println!("error reading command: {error}"),
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -329,7 +329,7 @@ fn find_exercise<'a>(name: &str, exercises: &'a [Exercise]) -> &'a Exercise {
|
|||||||
.iter()
|
.iter()
|
||||||
.find(|e| e.name == name)
|
.find(|e| e.name == name)
|
||||||
.unwrap_or_else(|| {
|
.unwrap_or_else(|| {
|
||||||
println!("No exercise found for '{}'!", name);
|
println!("No exercise found for '{name}'!");
|
||||||
std::process::exit(1)
|
std::process::exit(1)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -392,7 +392,7 @@ fn watch(exercises: &[Exercise], verbose: bool) -> notify::Result<WatchStatus> {
|
|||||||
Err(RecvTimeoutError::Timeout) => {
|
Err(RecvTimeoutError::Timeout) => {
|
||||||
// the timeout expired, just check the `should_quit` variable below then loop again
|
// the timeout expired, just check the `should_quit` variable below then loop again
|
||||||
}
|
}
|
||||||
Err(e) => println!("watch error: {:?}", e),
|
Err(e) => println!("watch error: {e:?}"),
|
||||||
}
|
}
|
||||||
// Check if we need to exit
|
// Check if we need to exit
|
||||||
if should_quit.load(Ordering::SeqCst) {
|
if should_quit.load(Ordering::SeqCst) {
|
||||||
|
@ -35,7 +35,7 @@ pub fn reset(exercise: &Exercise) -> Result<(), ()> {
|
|||||||
// This is strictly for non-test binaries, so output is displayed
|
// This is strictly for non-test binaries, so output is displayed
|
||||||
fn compile_and_run(exercise: &Exercise) -> Result<(), ()> {
|
fn compile_and_run(exercise: &Exercise) -> Result<(), ()> {
|
||||||
let progress_bar = ProgressBar::new_spinner();
|
let progress_bar = ProgressBar::new_spinner();
|
||||||
progress_bar.set_message(format!("Compiling {}...", exercise));
|
progress_bar.set_message(format!("Compiling {exercise}..."));
|
||||||
progress_bar.enable_steady_tick(100);
|
progress_bar.enable_steady_tick(100);
|
||||||
|
|
||||||
let compilation_result = exercise.compile();
|
let compilation_result = exercise.compile();
|
||||||
@ -52,7 +52,7 @@ fn compile_and_run(exercise: &Exercise) -> Result<(), ()> {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
progress_bar.set_message(format!("Running {}...", exercise));
|
progress_bar.set_message(format!("Running {exercise}..."));
|
||||||
let result = compilation.run();
|
let result = compilation.run();
|
||||||
progress_bar.finish_and_clear();
|
progress_bar.finish_and_clear();
|
||||||
|
|
||||||
|
@ -48,7 +48,7 @@ pub fn test(exercise: &Exercise, verbose: bool) -> Result<(), ()> {
|
|||||||
// Invoke the rust compiler without running the resulting binary
|
// Invoke the rust compiler without running the resulting binary
|
||||||
fn compile_only(exercise: &Exercise) -> Result<bool, ()> {
|
fn compile_only(exercise: &Exercise) -> Result<bool, ()> {
|
||||||
let progress_bar = ProgressBar::new_spinner();
|
let progress_bar = ProgressBar::new_spinner();
|
||||||
progress_bar.set_message(format!("Compiling {}...", exercise));
|
progress_bar.set_message(format!("Compiling {exercise}..."));
|
||||||
progress_bar.enable_steady_tick(100);
|
progress_bar.enable_steady_tick(100);
|
||||||
|
|
||||||
let _ = compile(exercise, &progress_bar)?;
|
let _ = compile(exercise, &progress_bar)?;
|
||||||
@ -60,12 +60,12 @@ fn compile_only(exercise: &Exercise) -> Result<bool, ()> {
|
|||||||
// Compile the given Exercise and run the resulting binary in an interactive mode
|
// Compile the given Exercise and run the resulting binary in an interactive mode
|
||||||
fn compile_and_run_interactively(exercise: &Exercise) -> Result<bool, ()> {
|
fn compile_and_run_interactively(exercise: &Exercise) -> Result<bool, ()> {
|
||||||
let progress_bar = ProgressBar::new_spinner();
|
let progress_bar = ProgressBar::new_spinner();
|
||||||
progress_bar.set_message(format!("Compiling {}...", exercise));
|
progress_bar.set_message(format!("Compiling {exercise}..."));
|
||||||
progress_bar.enable_steady_tick(100);
|
progress_bar.enable_steady_tick(100);
|
||||||
|
|
||||||
let compilation = compile(exercise, &progress_bar)?;
|
let compilation = compile(exercise, &progress_bar)?;
|
||||||
|
|
||||||
progress_bar.set_message(format!("Running {}...", exercise));
|
progress_bar.set_message(format!("Running {exercise}..."));
|
||||||
let result = compilation.run();
|
let result = compilation.run();
|
||||||
progress_bar.finish_and_clear();
|
progress_bar.finish_and_clear();
|
||||||
|
|
||||||
@ -86,7 +86,7 @@ fn compile_and_run_interactively(exercise: &Exercise) -> Result<bool, ()> {
|
|||||||
// the output if verbose is set to true
|
// the output if verbose is set to true
|
||||||
fn compile_and_test(exercise: &Exercise, run_mode: RunMode, verbose: bool) -> Result<bool, ()> {
|
fn compile_and_test(exercise: &Exercise, run_mode: RunMode, verbose: bool) -> Result<bool, ()> {
|
||||||
let progress_bar = ProgressBar::new_spinner();
|
let progress_bar = ProgressBar::new_spinner();
|
||||||
progress_bar.set_message(format!("Testing {}...", exercise));
|
progress_bar.set_message(format!("Testing {exercise}..."));
|
||||||
progress_bar.enable_steady_tick(100);
|
progress_bar.enable_steady_tick(100);
|
||||||
|
|
||||||
let compilation = compile(exercise, &progress_bar)?;
|
let compilation = compile(exercise, &progress_bar)?;
|
||||||
@ -165,16 +165,16 @@ fn prompt_for_completion(exercise: &Exercise, prompt_output: Option<String>) ->
|
|||||||
|
|
||||||
println!();
|
println!();
|
||||||
if no_emoji {
|
if no_emoji {
|
||||||
println!("~*~ {} ~*~", success_msg)
|
println!("~*~ {success_msg} ~*~")
|
||||||
} else {
|
} else {
|
||||||
println!("🎉 🎉 {} 🎉 🎉", success_msg)
|
println!("🎉 🎉 {success_msg} 🎉 🎉")
|
||||||
}
|
}
|
||||||
println!();
|
println!();
|
||||||
|
|
||||||
if let Some(output) = prompt_output {
|
if let Some(output) = prompt_output {
|
||||||
println!("Output:");
|
println!("Output:");
|
||||||
println!("{}", separator());
|
println!("{}", separator());
|
||||||
println!("{}", output);
|
println!("{output}");
|
||||||
println!("{}", separator());
|
println!("{}", separator());
|
||||||
println!();
|
println!();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user