diff options
| author | mo8it <mo8it@proton.me> | 2025-07-04 23:17:25 +0200 |
|---|---|---|
| committer | mo8it <mo8it@proton.me> | 2025-07-04 23:22:05 +0200 |
| commit | 1a633e275761604c8225839e79c139c90d59bfea (patch) | |
| tree | b6d117f09e7f9d8c4d972684c192a77d441d3748 | |
| parent | 9fecdba101a60dafecd0754cb1276dacf489a539 (diff) | |
Split lines after newline
| -rw-r--r-- | src/cargo_toml.rs | 9 | ||||
| -rw-r--r-- | src/dev/check.rs | 17 | ||||
| -rw-r--r-- | src/init.rs | 12 | ||||
| -rw-r--r-- | src/main.rs | 6 |
4 files changed, 33 insertions, 11 deletions
diff --git a/src/cargo_toml.rs b/src/cargo_toml.rs index e966809..ce0dfd0 100644 --- a/src/cargo_toml.rs +++ b/src/cargo_toml.rs @@ -134,7 +134,14 @@ mod tests { ); assert_eq!( - updated_cargo_toml(&exercise_infos, "abc\nbin = [xxx]\n123", b"../").unwrap(), + updated_cargo_toml( + &exercise_infos, + "abc\n\ + bin = [xxx]\n\ + 123", + b"../" + ) + .unwrap(), br#"abc bin = [ { name = "1", path = "../exercises/1.rs" }, diff --git a/src/dev/check.rs b/src/dev/check.rs index 67f5493..f711106 100644 --- a/src/dev/check.rs +++ b/src/dev/check.rs @@ -106,13 +106,15 @@ fn check_info_file_exercises(info_file: &InfoFile) -> Result<HashSet<PathBuf>> { if !file_buf.contains("fn main()") { bail!( - "The `main` function is missing in the file `{path}`.\nCreate at least an empty `main` function to avoid language server errors" + "The `main` function is missing in the file `{path}`.\n\ + Create at least an empty `main` function to avoid language server errors" ); } if !file_buf.contains("// TODO") { bail!( - "Didn't find any `// TODO` comment in the file `{path}`.\nYou need to have at least one such comment to guide the user." + "Didn't find any `// TODO` comment in the file `{path}`.\n\ + You need to have at least one such comment to guide the user." ); } @@ -227,7 +229,10 @@ fn check_exercises_unsolved( match result { Ok(true) => { - bail!("The exercise {exercise_name} is already solved.\n{SKIP_CHECK_UNSOLVED_HINT}",) + bail!( + "The exercise {exercise_name} is already solved.\n\ + {SKIP_CHECK_UNSOLVED_HINT}", + ) } Ok(false) => (), Err(e) => return Err(e), @@ -242,10 +247,12 @@ fn check_exercises_unsolved( fn check_exercises(info_file: &'static InfoFile, cmd_runner: &'static CmdRunner) -> Result<()> { match info_file.format_version.cmp(&CURRENT_FORMAT_VERSION) { Ordering::Less => bail!( - "`format_version` < {CURRENT_FORMAT_VERSION} (supported version)\nPlease migrate to the latest format version" + "`format_version` < {CURRENT_FORMAT_VERSION} (supported version)\n\ + Please migrate to the latest format version" ), Ordering::Greater => bail!( - "`format_version` > {CURRENT_FORMAT_VERSION} (supported version)\nTry updating the Rustlings program" + "`format_version` > {CURRENT_FORMAT_VERSION} (supported version)\n\ + Try updating the Rustlings program" ), Ordering::Equal => (), } diff --git a/src/init.rs b/src/init.rs index a60fba7..8cb6ac5 100644 --- a/src/init.rs +++ b/src/init.rs @@ -58,11 +58,13 @@ pub fn init() -> Result<()> { && !workspace_manifest_content.contains("workspace.") { bail!( - "The current directory is already part of a Cargo project.\nPlease initialize Rustlings in a different directory" + "The current directory is already part of a Cargo project.\n\ + Please initialize Rustlings in a different directory" ); } - stdout.write_all(b"This command will create the directory `rustlings/` as a member of this Cargo workspace.\nPress ENTER to continue ")?; + stdout.write_all(b"This command will create the directory `rustlings/` as a member of this Cargo workspace.\n\ + Press ENTER to continue ")?; press_enter_prompt(&mut stdout)?; // Make sure "rustlings" is added to `workspace.members` by making @@ -78,7 +80,8 @@ pub fn init() -> Result<()> { .status()?; if !status.success() { bail!( - "Failed to initialize a new Cargo workspace member.\nPlease initialize Rustlings in a different directory" + "Failed to initialize a new Cargo workspace member.\n\ + Please initialize Rustlings in a different directory" ); } @@ -87,7 +90,8 @@ pub fn init() -> Result<()> { .context("Failed to remove the temporary directory `rustlings/`")?; init_git = false; } else { - stdout.write_all(b"This command will create the directory `rustlings/` which will contain the exercises.\nPress ENTER to continue ")?; + stdout.write_all(b"This command will create the directory `rustlings/` which will contain the exercises.\n\ + Press ENTER to continue ")?; press_enter_prompt(&mut stdout)?; } diff --git a/src/main.rs b/src/main.rs index bce2593..29de56b 100644 --- a/src/main.rs +++ b/src/main.rs @@ -104,7 +104,11 @@ fn main() -> Result<ExitCode> { clear_terminal(&mut stdout)?; let welcome_message = welcome_message.trim_ascii(); - write!(stdout, "{welcome_message}\n\nPress ENTER to continue ")?; + write!( + stdout, + "{welcome_message}\n\n\ + Press ENTER to continue " + )?; press_enter_prompt(&mut stdout)?; clear_terminal(&mut stdout)?; // Flush to be able to show errors occurring before printing a newline to stdout. |
