summaryrefslogtreecommitdiff
path: root/src/verify.rs
diff options
context:
space:
mode:
authorDan <danbond@protonmail.com>2024-03-29 18:29:38 +0000
committerGitHub <noreply@github.com>2024-03-29 18:29:38 +0000
commit30273a6ee5a8666c236c47340d54dabbab604f9b (patch)
tree2a2d57987fbe6e11ac1cbe08aa5edf32051c7d18 /src/verify.rs
parenteb952a480d2dabcafa8b55e1a89872c9b5e4194b (diff)
parent9691c3cb55484ce9676c85ad4673b38e06100303 (diff)
Merge branch 'main' into main
Diffstat (limited to 'src/verify.rs')
-rw-r--r--src/verify.rs37
1 files changed, 18 insertions, 19 deletions
diff --git a/src/verify.rs b/src/verify.rs
index cafecab..dac2562 100644
--- a/src/verify.rs
+++ b/src/verify.rs
@@ -24,7 +24,7 @@ pub fn verify<'a>(
.progress_chars("#>-"),
);
bar.set_position(num_done as u64);
- bar.set_message(format!("({:.1} %)", percentage));
+ bar.set_message(format!("({percentage:.1} %)"));
for exercise in exercises {
let compile_result = match exercise.mode {
@@ -37,7 +37,7 @@ pub fn verify<'a>(
}
percentage += 100.0 / total as f32;
bar.inc(1);
- bar.set_message(format!("({:.1} %)", percentage));
+ bar.set_message(format!("({percentage:.1} %)"));
if bar.position() == total as u64 {
println!(
"Progress: You completed {} / {} exercises ({:.1} %).",
@@ -51,6 +51,7 @@ pub fn verify<'a>(
Ok(())
}
+#[derive(PartialEq, Eq)]
enum RunMode {
Interactive,
NonInteractive,
@@ -124,7 +125,7 @@ fn compile_and_test(
if verbose {
println!("{}", output.stdout);
}
- if let RunMode::Interactive = run_mode {
+ if run_mode == RunMode::Interactive {
Ok(prompt_for_completion(exercise, None, success_hints))
} else {
Ok(true)
@@ -191,27 +192,25 @@ fn prompt_for_completion(
Mode::Test => "The code is compiling, and the tests pass!",
Mode::Clippy => clippy_success_msg,
};
- println!();
+
if no_emoji {
- println!("~*~ {success_msg} ~*~")
+ println!("\n~*~ {success_msg} ~*~\n");
} else {
- println!("šŸŽ‰ šŸŽ‰ {success_msg} šŸŽ‰ šŸŽ‰")
+ println!("\nšŸŽ‰ šŸŽ‰ {success_msg} šŸŽ‰ šŸŽ‰\n");
}
- println!();
if let Some(output) = prompt_output {
- println!("Output:");
- println!("{}", separator());
- println!("{output}");
- println!("{}", separator());
- println!();
+ println!(
+ "Output:\n{separator}\n{output}\n{separator}\n",
+ separator = separator(),
+ );
}
if success_hints {
- println!("Hints:");
- println!("{}", separator());
- println!("{}", exercise.hint);
- println!("{}", separator());
- println!();
+ println!(
+ "Hints:\n{separator}\n{}\n{separator}\n",
+ exercise.hint,
+ separator = separator(),
+ );
}
println!("You can keep working on this exercise,");
@@ -224,14 +223,14 @@ fn prompt_for_completion(
let formatted_line = if context_line.important {
format!("{}", style(context_line.line).bold())
} else {
- context_line.line.to_string()
+ context_line.line
};
println!(
"{:>2} {} {}",
style(context_line.number).blue().bold(),
style("|").blue(),
- formatted_line
+ formatted_line,
);
}