summaryrefslogtreecommitdiff
path: root/src/verify.rs
diff options
context:
space:
mode:
authormo8it <mo8it@proton.me>2024-03-27 14:18:20 +0100
committermo8it <mo8it@proton.me>2024-03-27 14:18:20 +0100
commit8e0f7e56f7118c90a948634a641b036a28a8d74a (patch)
treed01c434674058804158f82d393b7e5f0fc98e4f3 /src/verify.rs
parent51b4c240ed006a8279bd94e9b7ed5df67086c86e (diff)
parent87ca05b4bb4436826a61bcbfe946a39a00f00be0 (diff)
Merge branch 'main' into which
Diffstat (limited to 'src/verify.rs')
-rw-r--r--src/verify.rs35
1 files changed, 17 insertions, 18 deletions
diff --git a/src/verify.rs b/src/verify.rs
index aee2afa..e2fa98f 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,");
@@ -231,7 +230,7 @@ fn prompt_for_completion(
"{:>2} {} {}",
style(context_line.number).blue().bold(),
style("|").blue(),
- formatted_line
+ formatted_line,
);
}