From 0f629a47a564427fc7348eeb370f3a97040fdea5 Mon Sep 17 00:00:00 2001 From: jbouganim-parallel <150748285+jbouganim-parallel@users.noreply.github.com> Date: Mon, 13 Nov 2023 17:30:38 -0800 Subject: [PATCH 01/52] fix broken link in windows installation instructions https://github.com/rust-lang/rustlings/issues/1759 --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index fdaee283..1011c806 100644 --- a/README.md +++ b/README.md @@ -61,7 +61,7 @@ Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser Then, you can run: ```ps1 -Start-BitsTransfer -Source https://ps1.rustlings.cool -Destination $env:TMP/install_rustlings.ps1; Unblock-File $env:TMP/install_rustlings.ps1; Invoke-Expression $env:TMP/install_rustlings.ps1 +Start-BitsTransfer -Source https://raw.githubusercontent.com/rust-lang/rustlings/main/install.ps1 -Destination $env:TMP/install_rustlings.ps1; Unblock-File $env:TMP/install_rustlings.ps1; Invoke-Expression $env:TMP/install_rustlings.ps1 ``` To install Rustlings. Same as on MacOS/Linux, you will have access to the `rustlings` command after it. Keep in mind that this works best in PowerShell, and any other terminals may give you errors. From f35f63fa5763bde734ca086aa9e3398e8319539d Mon Sep 17 00:00:00 2001 From: NicolasRoelandt Date: Fri, 8 Dec 2023 17:52:21 +0000 Subject: [PATCH 02/52] Remove confusing aside in 23_conversions/from_str.rs The advice tell us how to return as String error message. Unless I missed something, we can't even return a String error message here, so this advice is more confusing than anything and should better be removed. --- exercises/23_conversions/from_str.rs | 4 ---- 1 file changed, 4 deletions(-) diff --git a/exercises/23_conversions/from_str.rs b/exercises/23_conversions/from_str.rs index 34472c32..e2093474 100644 --- a/exercises/23_conversions/from_str.rs +++ b/exercises/23_conversions/from_str.rs @@ -44,10 +44,6 @@ enum ParsePersonError { // 6. If while extracting the name and the age something goes wrong, an error // should be returned // If everything goes well, then return a Result of a Person object -// -// As an aside: `Box` implements `From<&'_ str>`. This means that if -// you want to return a string error message, you can do so via just using -// return `Err("my error message".into())`. impl FromStr for Person { type Err = ParsePersonError; From 5453fad99146905b690f99d76992b840ad8772a2 Mon Sep 17 00:00:00 2001 From: Paul Leydier Date: Mon, 18 Dec 2023 21:16:18 -0500 Subject: [PATCH 03/52] docs: sort exercise to book chapter mapping by exercise --- exercises/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/exercises/README.md b/exercises/README.md index c7effa95..fd0926f1 100644 --- a/exercises/README.md +++ b/exercises/README.md @@ -17,11 +17,11 @@ | error_handling | §9 | | generics | §10 | | traits | §10.2 | -| tests | §11.1 | | lifetimes | §10.3 | +| tests | §11.1 | | iterators | §13.2-4 | -| threads | §16.1-3 | | smart_pointers | §15, §16.3 | +| threads | §16.1-3 | | macros | §19.6 | | clippy | §21.4 | | conversions | n/a | From e276c1219279e14b267a36e99fb3908427bc67ff Mon Sep 17 00:00:00 2001 From: honeywest Date: Thu, 21 Mar 2024 15:18:50 +0800 Subject: [PATCH 04/52] feat: ui format --- src/ui.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ui.rs b/src/ui.rs index 74835e13..d8177b9f 100644 --- a/src/ui.rs +++ b/src/ui.rs @@ -1,5 +1,5 @@ macro_rules! print_emoji { - ($emoji:expr, $sign:expr, $color: ident ,$fmt:literal, $ex:expr) => {{ + ($emoji:expr, $sign:expr, $color: ident, $fmt:literal, $ex:expr) => {{ use console::{style, Emoji}; use std::env; let formatstr = format!($fmt, $ex); From 3dce7e56961a40748f428d10c50540a075839f8d Mon Sep 17 00:00:00 2001 From: mo8it Date: Sat, 23 Mar 2024 18:51:25 +0100 Subject: [PATCH 05/52] Improvements to watch mode --- Cargo.lock | 7 +++++ Cargo.toml | 1 + src/main.rs | 87 ++++++++++++++++++++++++++++++----------------------- 3 files changed, 58 insertions(+), 37 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 3950c476..e86f9fa4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -536,6 +536,7 @@ dependencies = [ "regex", "serde", "serde_json", + "shlex", "toml", ] @@ -594,6 +595,12 @@ dependencies = [ "serde", ] +[[package]] +name = "shlex" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" + [[package]] name = "strsim" version = "0.11.0" diff --git a/Cargo.toml b/Cargo.toml index 218b7990..2cf8bc39 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -18,6 +18,7 @@ notify-debouncer-mini = "0.4.1" regex = "1.10.3" serde_json = "1.0.114" serde = { version = "1.0.197", features = ["derive"] } +shlex = "1.3.0" toml = "0.8.10" [[bin]] diff --git a/src/main.rs b/src/main.rs index a06f0c56..7c469d5c 100644 --- a/src/main.rs +++ b/src/main.rs @@ -6,6 +6,7 @@ use clap::{Parser, Subcommand}; use console::Emoji; use notify_debouncer_mini::notify::{self, RecursiveMode}; use notify_debouncer_mini::{new_debouncer, DebouncedEventKind}; +use shlex::Shlex; use std::ffi::OsStr; use std::fs; use std::io::{self, prelude::*}; @@ -25,6 +26,16 @@ mod project; mod run; mod verify; +const WATCH_MODE_HELP_MESSAGE: &str = "Commands available to you in watch mode: + hint - prints the current exercise's hint + clear - clears the screen + quit - quits watch mode + ! - executes a command, like `!rustc --explain E0381` + help - displays this help message + +Watch mode automatically re-evaluates the current exercise +when you edit a file's contents."; + /// Rustlings is a collection of small exercises to get you used to writing and reading Rust code #[derive(Parser)] #[command(version)] @@ -246,47 +257,49 @@ fn main() { } fn spawn_watch_shell( - failed_exercise_hint: &Arc>>, + failed_exercise_hint: Arc>>, should_quit: Arc, ) { - let failed_exercise_hint = Arc::clone(failed_exercise_hint); println!("Welcome to watch mode! You can type 'help' to get an overview of the commands you can use here."); - thread::spawn(move || loop { + + thread::spawn(move || { let mut input = String::new(); - match io::stdin().read_line(&mut input) { - Ok(_) => { - let input = input.trim(); - if input == "hint" { - if let Some(hint) = &*failed_exercise_hint.lock().unwrap() { - println!("{hint}"); - } - } else if input == "clear" { - println!("\x1B[2J\x1B[1;1H"); - } else if input.eq("quit") { - should_quit.store(true, Ordering::SeqCst); - println!("Bye!"); - } else if input.eq("help") { - println!("Commands available to you in watch mode:"); - println!(" hint - prints the current exercise's hint"); - println!(" clear - clears the screen"); - println!(" quit - quits watch mode"); - println!(" ! - executes a command, like `!rustc --explain E0381`"); - println!(" help - displays this help message"); - println!(); - println!("Watch mode automatically re-evaluates the current exercise"); - println!("when you edit a file's contents.") - } else if let Some(cmd) = input.strip_prefix('!') { - let parts: Vec<&str> = cmd.split_whitespace().collect(); - if parts.is_empty() { - println!("no command provided"); - } else if let Err(e) = Command::new(parts[0]).args(&parts[1..]).status() { - println!("failed to execute command `{}`: {}", cmd, e); - } - } else { - println!("unknown command: {input}"); - } + let mut stdin = io::stdin().lock(); + + loop { + // Recycle input buffer. + input.clear(); + + if let Err(e) = stdin.read_line(&mut input) { + println!("error reading command: {e}"); + } + + let input = input.trim(); + if input == "hint" { + if let Some(hint) = &*failed_exercise_hint.lock().unwrap() { + println!("{hint}"); + } + } else if input == "clear" { + println!("\x1B[2J\x1B[1;1H"); + } else if input == "quit" { + should_quit.store(true, Ordering::SeqCst); + println!("Bye!"); + } else if input == "help" { + println!("{WATCH_MODE_HELP_MESSAGE}"); + } else if let Some(cmd) = input.strip_prefix('!') { + let mut parts = Shlex::new(cmd); + + let Some(program) = parts.next() else { + println!("no command provided"); + continue; + }; + + if let Err(e) = Command::new(program).args(parts).status() { + println!("failed to execute command `{cmd}`: {e}"); + } + } else { + println!("unknown command: {input}\n{WATCH_MODE_HELP_MESSAGE}"); } - Err(error) => println!("error reading command: {error}"), } }); } @@ -348,7 +361,7 @@ fn watch( Ok(_) => return Ok(WatchStatus::Finished), Err(exercise) => Arc::new(Mutex::new(Some(to_owned_hint(exercise)))), }; - spawn_watch_shell(&failed_exercise_hint, Arc::clone(&should_quit)); + spawn_watch_shell(Arc::clone(&failed_exercise_hint), Arc::clone(&should_quit)); loop { match rx.recv_timeout(Duration::from_secs(1)) { Ok(event) => match event { From 0d93266462f56d28501f068a764405a0cd0bf41a Mon Sep 17 00:00:00 2001 From: mo8it Date: Sat, 23 Mar 2024 18:56:30 +0100 Subject: [PATCH 06/52] Initialize the input buffer with some capacity --- src/main.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.rs b/src/main.rs index 7c469d5c..2b6a48cf 100644 --- a/src/main.rs +++ b/src/main.rs @@ -263,7 +263,7 @@ fn spawn_watch_shell( println!("Welcome to watch mode! You can type 'help' to get an overview of the commands you can use here."); thread::spawn(move || { - let mut input = String::new(); + let mut input = String::with_capacity(32); let mut stdin = io::stdin().lock(); loop { From 27fa7c3e4a5bb58b21359e9d6246f66b5f20a978 Mon Sep 17 00:00:00 2001 From: mo8it Date: Sat, 23 Mar 2024 19:00:15 +0100 Subject: [PATCH 07/52] Move the const string to the bottom like others --- src/main.rs | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/main.rs b/src/main.rs index 2b6a48cf..d2614df6 100644 --- a/src/main.rs +++ b/src/main.rs @@ -26,16 +26,6 @@ mod project; mod run; mod verify; -const WATCH_MODE_HELP_MESSAGE: &str = "Commands available to you in watch mode: - hint - prints the current exercise's hint - clear - clears the screen - quit - quits watch mode - ! - executes a command, like `!rustc --explain E0381` - help - displays this help message - -Watch mode automatically re-evaluates the current exercise -when you edit a file's contents."; - /// Rustlings is a collection of small exercises to get you used to writing and reading Rust code #[derive(Parser)] #[command(version)] @@ -490,3 +480,13 @@ const WELCOME: &str = r" welcome to... | | | |_| \__ \ |_| | | | | | (_| \__ \ |_| \__,_|___/\__|_|_|_| |_|\__, |___/ |___/"; + +const WATCH_MODE_HELP_MESSAGE: &str = "Commands available to you in watch mode: + hint - prints the current exercise's hint + clear - clears the screen + quit - quits watch mode + ! - executes a command, like `!rustc --explain E0381` + help - displays this help message + +Watch mode automatically re-evaluates the current exercise +when you edit a file's contents."; From a325df55d1077c8613905bb82709cd8c80341641 Mon Sep 17 00:00:00 2001 From: mo8it Date: Sat, 23 Mar 2024 21:56:40 +0100 Subject: [PATCH 08/52] Cache filters --- src/main.rs | 39 +++++++++++++++++++++++++++------------ 1 file changed, 27 insertions(+), 12 deletions(-) diff --git a/src/main.rs b/src/main.rs index a06f0c56..9bf58668 100644 --- a/src/main.rs +++ b/src/main.rs @@ -128,31 +128,45 @@ fn main() { println!("{:<17}\t{:<46}\t{:<7}", "Name", "Path", "Status"); } let mut exercises_done: u16 = 0; - let filters = filter.clone().unwrap_or_default().to_lowercase(); - exercises.iter().for_each(|e| { - let fname = format!("{}", e.path.display()); + let lowercase_filter = filter + .as_ref() + .map(|s| s.to_lowercase()) + .unwrap_or_default(); + let filters = lowercase_filter + .split(',') + .filter_map(|f| { + let f = f.trim(); + if f.is_empty() { + None + } else { + Some(f) + } + }) + .collect::>(); + + for exercise in &exercises { + let fname = format!("{}", exercise.path.display()); let filter_cond = filters - .split(',') - .filter(|f| !f.trim().is_empty()) - .any(|f| e.name.contains(f) || fname.contains(f)); - let status = if e.looks_done() { + .iter() + .any(|f| exercise.name.contains(f) || fname.contains(f)); + let status = if exercise.looks_done() { exercises_done += 1; "Done" } else { "Pending" }; let solve_cond = { - (e.looks_done() && solved) - || (!e.looks_done() && unsolved) + (exercise.looks_done() && solved) + || (!exercise.looks_done() && unsolved) || (!solved && !unsolved) }; if solve_cond && (filter_cond || filter.is_none()) { let line = if paths { format!("{fname}\n") } else if names { - format!("{}\n", e.name) + format!("{}\n", exercise.name) } else { - format!("{:<17}\t{fname:<46}\t{status:<7}\n", e.name) + format!("{:<17}\t{fname:<46}\t{status:<7}\n", exercise.name) }; // Somehow using println! leads to the binary panicking // when its output is piped. @@ -168,7 +182,8 @@ fn main() { }); } } - }); + } + let percentage_progress = exercises_done as f32 / exercises.len() as f32 * 100.0; println!( "Progress: You completed {} / {} exercises ({:.1} %).", From 01b7d6334c44d55f11d7f09c45e76b2db7fef948 Mon Sep 17 00:00:00 2001 From: mo8it Date: Sat, 23 Mar 2024 22:08:25 +0100 Subject: [PATCH 09/52] Remove unneeded to_string call --- src/verify.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/verify.rs b/src/verify.rs index aee2afa3..e3a8e887 100644 --- a/src/verify.rs +++ b/src/verify.rs @@ -224,7 +224,7 @@ 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!( From 0aeaccc3a50b5b60b6005161847641bade75effa Mon Sep 17 00:00:00 2001 From: mo8it Date: Sun, 24 Mar 2024 18:34:46 +0100 Subject: [PATCH 10/52] Optimize state --- src/exercise.rs | 112 ++++++++++++++++++++++++++++++++---------------- 1 file changed, 75 insertions(+), 37 deletions(-) diff --git a/src/exercise.rs b/src/exercise.rs index 664b362b..b112fe8a 100644 --- a/src/exercise.rs +++ b/src/exercise.rs @@ -1,16 +1,16 @@ use regex::Regex; use serde::Deserialize; -use std::env; use std::fmt::{self, Display, Formatter}; use std::fs::{self, remove_file, File}; -use std::io::Read; +use std::io::{self, BufRead, BufReader}; use std::path::PathBuf; use std::process::{self, Command}; +use std::{array, env, mem}; const RUSTC_COLOR_ARGS: &[&str] = &["--color", "always"]; const RUSTC_EDITION_ARGS: &[&str] = &["--edition", "2021"]; const RUSTC_NO_DEBUG_ARGS: &[&str] = &["-C", "strip=debuginfo"]; -const I_AM_DONE_REGEX: &str = r"(?m)^\s*///?\s*I\s+AM\s+NOT\s+DONE"; +const I_AM_DONE_REGEX: &str = r"^\s*///?\s*I\s+AM\s+NOT\s+DONE"; const CONTEXT: usize = 2; const CLIPPY_CARGO_TOML_PATH: &str = "./exercises/22_clippy/Cargo.toml"; @@ -205,51 +205,89 @@ path = "{}.rs""#, } pub fn state(&self) -> State { - let mut source_file = File::open(&self.path).unwrap_or_else(|e| { + let source_file = File::open(&self.path).unwrap_or_else(|e| { panic!( "We were unable to open the exercise file {}! {e}", self.path.display() ) }); - - let source = { - let mut s = String::new(); - source_file.read_to_string(&mut s).unwrap_or_else(|e| { - panic!( - "We were unable to read the exercise file {}! {e}", - self.path.display() - ) - }); - s + let mut source_reader = BufReader::new(source_file); + let mut read_line = |buf: &mut String| -> io::Result<_> { + let n = source_reader.read_line(buf)?; + if buf.ends_with('\n') { + buf.pop(); + if buf.ends_with('\r') { + buf.pop(); + } + } + Ok(n) }; let re = Regex::new(I_AM_DONE_REGEX).unwrap(); + let mut matched_line_ind: usize = 0; + let mut prev_lines: [_; CONTEXT] = array::from_fn(|_| String::with_capacity(256)); + let mut line = String::with_capacity(256); - if !re.is_match(&source) { - return State::Done; + loop { + match read_line(&mut line) { + Ok(0) => break, + Ok(_) => { + if re.is_match(&line) { + let mut context = Vec::with_capacity(2 * CONTEXT + 1); + for (ind, prev_line) in prev_lines + .into_iter() + .rev() + .take(matched_line_ind) + .enumerate() + { + context.push(ContextLine { + line: prev_line, + // TODO + number: matched_line_ind - CONTEXT + ind + 1, + important: false, + }); + } + + context.push(ContextLine { + line, + number: matched_line_ind + 1, + important: true, + }); + + for ind in 0..CONTEXT { + let mut next_line = String::with_capacity(256); + let Ok(n) = read_line(&mut next_line) else { + break; + }; + + if n == 0 { + break; + } + + context.push(ContextLine { + line: next_line, + number: matched_line_ind + ind + 2, + important: false, + }); + } + + return State::Pending(context); + } + + matched_line_ind += 1; + for prev_line in &mut prev_lines { + mem::swap(&mut line, prev_line); + } + line.clear(); + } + Err(e) => panic!( + "We were unable to read the exercise file {}! {e}", + self.path.display() + ), + } } - let matched_line_index = source - .lines() - .enumerate() - .find_map(|(i, line)| if re.is_match(line) { Some(i) } else { None }) - .expect("This should not happen at all"); - - let min_line = ((matched_line_index as i32) - (CONTEXT as i32)).max(0) as usize; - let max_line = matched_line_index + CONTEXT; - - let context = source - .lines() - .enumerate() - .filter(|&(i, _)| i >= min_line && i <= max_line) - .map(|(i, line)| ContextLine { - line: line.to_string(), - number: i + 1, - important: i == matched_line_index, - }) - .collect(); - - State::Pending(context) + State::Done } // Check that the exercise looks to be solved using self.state() From e1375ef4319641749611124ae495346d32e04e2d Mon Sep 17 00:00:00 2001 From: mo8it Date: Sun, 24 Mar 2024 18:47:27 +0100 Subject: [PATCH 11/52] Use to_string_lossy --- src/main.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.rs b/src/main.rs index 9bf58668..067c810c 100644 --- a/src/main.rs +++ b/src/main.rs @@ -145,7 +145,7 @@ fn main() { .collect::>(); for exercise in &exercises { - let fname = format!("{}", exercise.path.display()); + let fname = exercise.path.to_string_lossy(); let filter_cond = filters .iter() .any(|f| exercise.name.contains(f) || fname.contains(f)); From f205ee3d4c6f259c82e4f1226acc6a5ae5e70031 Mon Sep 17 00:00:00 2001 From: mo8it Date: Sun, 24 Mar 2024 18:50:46 +0100 Subject: [PATCH 12/52] Call looks_done only once --- src/main.rs | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/main.rs b/src/main.rs index 067c810c..f646fdca 100644 --- a/src/main.rs +++ b/src/main.rs @@ -149,17 +149,15 @@ fn main() { let filter_cond = filters .iter() .any(|f| exercise.name.contains(f) || fname.contains(f)); - let status = if exercise.looks_done() { + let looks_done = exercise.looks_done(); + let status = if looks_done { exercises_done += 1; "Done" } else { "Pending" }; - let solve_cond = { - (exercise.looks_done() && solved) - || (!exercise.looks_done() && unsolved) - || (!solved && !unsolved) - }; + let solve_cond = + (looks_done && solved) || (!looks_done && unsolved) || (!solved && !unsolved); if solve_cond && (filter_cond || filter.is_none()) { let line = if paths { format!("{fname}\n") From c0c112985b531bbcf503a2b1a8c2764030a16c99 Mon Sep 17 00:00:00 2001 From: mo8it Date: Sun, 24 Mar 2024 19:18:19 +0100 Subject: [PATCH 13/52] Replace regex with winnow --- Cargo.lock | 2 +- Cargo.toml | 2 +- src/exercise.rs | 44 ++++++++++++++++++++++++++++++++++++++++---- 3 files changed, 42 insertions(+), 6 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 3950c476..e42b8f40 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -533,10 +533,10 @@ dependencies = [ "indicatif", "notify-debouncer-mini", "predicates", - "regex", "serde", "serde_json", "toml", + "winnow", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index 218b7990..dd4c0c30 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -15,10 +15,10 @@ glob = "0.3.0" home = "0.5.9" indicatif = "0.17.8" notify-debouncer-mini = "0.4.1" -regex = "1.10.3" serde_json = "1.0.114" serde = { version = "1.0.197", features = ["derive"] } toml = "0.8.10" +winnow = "0.6.5" [[bin]] name = "rustlings" diff --git a/src/exercise.rs b/src/exercise.rs index b112fe8a..8f580d30 100644 --- a/src/exercise.rs +++ b/src/exercise.rs @@ -1,4 +1,3 @@ -use regex::Regex; use serde::Deserialize; use std::fmt::{self, Display, Formatter}; use std::fs::{self, remove_file, File}; @@ -6,14 +5,34 @@ use std::io::{self, BufRead, BufReader}; use std::path::PathBuf; use std::process::{self, Command}; use std::{array, env, mem}; +use winnow::ascii::{space0, space1}; +use winnow::combinator::opt; +use winnow::Parser; const RUSTC_COLOR_ARGS: &[&str] = &["--color", "always"]; const RUSTC_EDITION_ARGS: &[&str] = &["--edition", "2021"]; const RUSTC_NO_DEBUG_ARGS: &[&str] = &["-C", "strip=debuginfo"]; -const I_AM_DONE_REGEX: &str = r"^\s*///?\s*I\s+AM\s+NOT\s+DONE"; const CONTEXT: usize = 2; const CLIPPY_CARGO_TOML_PATH: &str = "./exercises/22_clippy/Cargo.toml"; +fn not_done(input: &str) -> bool { + ( + space0::<_, ()>, + "//", + opt('/'), + space0, + 'I', + space1, + "AM", + space1, + "NOT", + space1, + "DONE", + ) + .parse_next(&mut &*input) + .is_ok() +} + // Get a temporary file name that is hopefully unique #[inline] fn temp_file() -> String { @@ -223,7 +242,6 @@ path = "{}.rs""#, Ok(n) }; - let re = Regex::new(I_AM_DONE_REGEX).unwrap(); let mut matched_line_ind: usize = 0; let mut prev_lines: [_; CONTEXT] = array::from_fn(|_| String::with_capacity(256)); let mut line = String::with_capacity(256); @@ -232,7 +250,7 @@ path = "{}.rs""#, match read_line(&mut line) { Ok(0) => break, Ok(_) => { - if re.is_match(&line) { + if not_done(&line) { let mut context = Vec::with_capacity(2 * CONTEXT + 1); for (ind, prev_line) in prev_lines .into_iter() @@ -413,4 +431,22 @@ mod test { let out = exercise.compile().unwrap().run().unwrap(); assert!(out.stdout.contains("THIS TEST TOO SHALL PASS")); } + + #[test] + fn test_not_done() { + assert!(not_done("// I AM NOT DONE")); + assert!(not_done("/// I AM NOT DONE")); + assert!(not_done("// I AM NOT DONE")); + assert!(not_done("/// I AM NOT DONE")); + assert!(not_done("// I AM NOT DONE")); + assert!(not_done("// I AM NOT DONE")); + assert!(not_done("// I AM NOT DONE")); + assert!(not_done("// I AM NOT DONE ")); + assert!(not_done("// I AM NOT DONE!")); + + assert!(!not_done("I AM NOT DONE")); + assert!(!not_done("// NOT DONE")); + assert!(!not_done("DONE")); + assert!(!not_done("// i am not done")); + } } From bdf826a026cfe7f89c31433cfd2b9a32cbe66d2c Mon Sep 17 00:00:00 2001 From: mo8it Date: Sun, 24 Mar 2024 22:22:55 +0100 Subject: [PATCH 14/52] Make "I AM NOT DONE" caseless --- src/exercise.rs | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/src/exercise.rs b/src/exercise.rs index 8f580d30..136e9439 100644 --- a/src/exercise.rs +++ b/src/exercise.rs @@ -5,7 +5,7 @@ use std::io::{self, BufRead, BufReader}; use std::path::PathBuf; use std::process::{self, Command}; use std::{array, env, mem}; -use winnow::ascii::{space0, space1}; +use winnow::ascii::{space0, Caseless}; use winnow::combinator::opt; use winnow::Parser; @@ -21,13 +21,7 @@ fn not_done(input: &str) -> bool { "//", opt('/'), space0, - 'I', - space1, - "AM", - space1, - "NOT", - space1, - "DONE", + Caseless("I AM NOT DONE"), ) .parse_next(&mut &*input) .is_ok() @@ -438,15 +432,13 @@ mod test { assert!(not_done("/// I AM NOT DONE")); assert!(not_done("// I AM NOT DONE")); assert!(not_done("/// I AM NOT DONE")); - assert!(not_done("// I AM NOT DONE")); - assert!(not_done("// I AM NOT DONE")); - assert!(not_done("// I AM NOT DONE")); assert!(not_done("// I AM NOT DONE ")); assert!(not_done("// I AM NOT DONE!")); + assert!(not_done("// I am not done")); + assert!(not_done("// i am NOT done")); assert!(!not_done("I AM NOT DONE")); assert!(!not_done("// NOT DONE")); assert!(!not_done("DONE")); - assert!(!not_done("// i am not done")); } } From 51b4c240ed006a8279bd94e9b7ed5df67086c86e Mon Sep 17 00:00:00 2001 From: mo8it Date: Mon, 25 Mar 2024 00:30:01 +0100 Subject: [PATCH 15/52] Use `which` instead of running `rustc --version` --- Cargo.lock | 54 +++++++++++++++++++++++++++++++++++++++++++++++++++++ Cargo.toml | 1 + src/main.rs | 16 ++-------------- 3 files changed, 57 insertions(+), 14 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 3950c476..1bfd301f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -195,6 +195,12 @@ version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fea41bba32d969b513997752735605054bc0dfa92b4c56bf1189f2e174be7a10" +[[package]] +name = "either" +version = "1.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "11157ac094ffbdde99aa67b23417ebdd801842852b500e395a45a9c0aac03e4a" + [[package]] name = "encode_unicode" version = "0.3.6" @@ -207,6 +213,16 @@ version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" +[[package]] +name = "errno" +version = "0.3.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a258e46cdc063eb8519c00b9fc845fc47bcfca4130e2f08e88665ceda8474245" +dependencies = [ + "libc", + "windows-sys 0.52.0", +] + [[package]] name = "filetime" version = "0.2.23" @@ -354,6 +370,12 @@ version = "0.2.153" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9c198f91728a82281a64e1f4f9eeb25d82cb32a5de251c6bd1b5154d63a8e7bd" +[[package]] +name = "linux-raw-sys" +version = "0.4.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "01cda141df6706de531b6c46c3a33ecca755538219bd484262fa09410c13539c" + [[package]] name = "log" version = "0.4.21" @@ -521,6 +543,19 @@ version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c08c74e62047bb2de4ff487b251e4a92e24f48745648451635cec7d591162d9f" +[[package]] +name = "rustix" +version = "0.38.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "65e04861e65f21776e67888bfbea442b3642beaa0138fdb1dd7a84a52dffdb89" +dependencies = [ + "bitflags 2.4.2", + "errno", + "libc", + "linux-raw-sys", + "windows-sys 0.52.0", +] + [[package]] name = "rustlings" version = "5.6.1" @@ -537,6 +572,7 @@ dependencies = [ "serde", "serde_json", "toml", + "which", ] [[package]] @@ -694,6 +730,18 @@ version = "0.11.0+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" +[[package]] +name = "which" +version = "6.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8211e4f58a2b2805adfbefbc07bab82958fc91e3836339b1ab7ae32465dce0d7" +dependencies = [ + "either", + "home", + "rustix", + "winsafe", +] + [[package]] name = "winapi" version = "0.3.9" @@ -865,3 +913,9 @@ checksum = "dffa400e67ed5a4dd237983829e66475f0a4a26938c4b04c21baede6262215b8" dependencies = [ "memchr", ] + +[[package]] +name = "winsafe" +version = "0.0.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d135d17ab770252ad95e9a872d365cf3090e3be864a34ab46f48555993efc904" diff --git a/Cargo.toml b/Cargo.toml index 218b7990..de65fc6e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -19,6 +19,7 @@ regex = "1.10.3" serde_json = "1.0.114" serde = { version = "1.0.197", features = ["derive"] } toml = "0.8.10" +which = "6.0.1" [[bin]] name = "rustlings" diff --git a/src/main.rs b/src/main.rs index a06f0c56..f932631b 100644 --- a/src/main.rs +++ b/src/main.rs @@ -10,7 +10,7 @@ use std::ffi::OsStr; use std::fs; use std::io::{self, prelude::*}; use std::path::Path; -use std::process::{Command, Stdio}; +use std::process::Command; use std::sync::atomic::{AtomicBool, Ordering}; use std::sync::mpsc::{channel, RecvTimeoutError}; use std::sync::{Arc, Mutex}; @@ -100,7 +100,7 @@ fn main() { std::process::exit(1); } - if !rustc_exists() { + if which::which("rustc").is_err() { println!("We cannot find `rustc`."); println!("Try running `rustc --version` to diagnose your problem."); println!("For instructions on how to install Rust, check the README."); @@ -403,18 +403,6 @@ fn watch( } } -fn rustc_exists() -> bool { - Command::new("rustc") - .args(["--version"]) - .stdout(Stdio::null()) - .stderr(Stdio::null()) - .stdin(Stdio::null()) - .spawn() - .and_then(|mut child| child.wait()) - .map(|status| status.success()) - .unwrap_or(false) -} - const DEFAULT_OUT: &str = r#"Thanks for installing Rustlings! Is this your first time? Don't worry, Rustlings was made for beginners! We are From 83cd91ccca22e36ed94e03cc622a88ef45e6da10 Mon Sep 17 00:00:00 2001 From: mo8it Date: Mon, 25 Mar 2024 02:35:51 +0100 Subject: [PATCH 16/52] Replace toml with toml_edit --- Cargo.lock | 18 +++--------------- Cargo.toml | 2 +- src/main.rs | 6 ++++-- 3 files changed, 8 insertions(+), 18 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 3950c476..52b27259 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -536,7 +536,7 @@ dependencies = [ "regex", "serde", "serde_json", - "toml", + "toml_edit", ] [[package]] @@ -617,18 +617,6 @@ version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3369f5ac52d5eb6ab48c6b4ffdc8efbcad6b89c765749064ba298f2c68a16a76" -[[package]] -name = "toml" -version = "0.8.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a9aad4a3066010876e8dcf5a8a06e70a558751117a145c6ce2b82c2e2054290" -dependencies = [ - "serde", - "serde_spanned", - "toml_datetime", - "toml_edit", -] - [[package]] name = "toml_datetime" version = "0.6.5" @@ -640,9 +628,9 @@ dependencies = [ [[package]] name = "toml_edit" -version = "0.22.6" +version = "0.22.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2c1b5fd4128cc8d3e0cb74d4ed9a9cc7c7284becd4df68f5f940e1ad123606f6" +checksum = "8e40bb779c5187258fd7aad0eb68cb8706a0a81fa712fbea808ab43c4b8374c4" dependencies = [ "indexmap", "serde", diff --git a/Cargo.toml b/Cargo.toml index 218b7990..28614595 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -18,7 +18,7 @@ notify-debouncer-mini = "0.4.1" regex = "1.10.3" serde_json = "1.0.114" serde = { version = "1.0.197", features = ["derive"] } -toml = "0.8.10" +toml_edit = { version = "0.22.9", default-features = false, features = ["parse", "serde"] } [[bin]] name = "rustlings" diff --git a/src/main.rs b/src/main.rs index a06f0c56..8e0029dd 100644 --- a/src/main.rs +++ b/src/main.rs @@ -107,8 +107,10 @@ fn main() { std::process::exit(1); } - let toml_str = &fs::read_to_string("info.toml").unwrap(); - let exercises = toml::from_str::(toml_str).unwrap().exercises; + let info_file = fs::read_to_string("info.toml").unwrap(); + let exercises = toml_edit::de::from_str::(&info_file) + .unwrap() + .exercises; let verbose = args.nocapture; let command = args.command.unwrap_or_else(|| { From e4520602f52935ff310534afc65160bcc5796a97 Mon Sep 17 00:00:00 2001 From: mo8it Date: Mon, 25 Mar 2024 02:41:45 +0100 Subject: [PATCH 17/52] Use the NotFound variant of the IO error --- src/main.rs | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/src/main.rs b/src/main.rs index 8e0029dd..d6542aa2 100644 --- a/src/main.rs +++ b/src/main.rs @@ -91,15 +91,6 @@ fn main() { println!("\n{WELCOME}\n"); } - if !Path::new("info.toml").exists() { - println!( - "{} must be run from the rustlings directory", - std::env::current_exe().unwrap().to_str().unwrap() - ); - println!("Try `cd rustlings/`!"); - std::process::exit(1); - } - if !rustc_exists() { println!("We cannot find `rustc`."); println!("Try running `rustc --version` to diagnose your problem."); @@ -107,7 +98,15 @@ fn main() { std::process::exit(1); } - let info_file = fs::read_to_string("info.toml").unwrap(); + let info_file = fs::read_to_string("info.toml").unwrap_or_else(|e| { + match e.kind() { + io::ErrorKind::NotFound => println!( + "The program must be run from the rustlings directory\nTry `cd rustlings/`!", + ), + _ => println!("Failed to read the info.toml file: {e}"), + } + std::process::exit(1); + }); let exercises = toml_edit::de::from_str::(&info_file) .unwrap() .exercises; From b3aef377beacb09d8efff5a59376edc7fae7766c Mon Sep 17 00:00:00 2001 From: mo8it Date: Mon, 25 Mar 2024 03:33:14 +0100 Subject: [PATCH 18/52] Use a custom capacity for the JSON buffer --- src/project.rs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/project.rs b/src/project.rs index 00fc304d..93f941dd 100644 --- a/src/project.rs +++ b/src/project.rs @@ -31,10 +31,12 @@ impl RustAnalyzerProject { /// Write rust-project.json to disk pub fn write_to_disk(&self) -> Result<(), std::io::Error> { - std::fs::write( - "./rust-project.json", - serde_json::to_vec(&self).expect("Failed to serialize to JSON"), - )?; + // Using the capacity 2^14 = 16384 since the file length in bytes is higher than 2^13. + // The final length is not known exactly because it depends on the user's sysroot path, + // the current number of exercises etc. + let mut buf = Vec::with_capacity(16384); + serde_json::to_writer(&mut buf, &self).expect("Failed to serialize to JSON"); + std::fs::write("rust-project.json", buf)?; Ok(()) } From efa9f5704853acda6874725004b480d720683faf Mon Sep 17 00:00:00 2001 From: mo8it Date: Mon, 25 Mar 2024 03:46:56 +0100 Subject: [PATCH 19/52] Add anyhow --- Cargo.lock | 7 +++++++ Cargo.toml | 1 + src/main.rs | 5 ++++- 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/Cargo.lock b/Cargo.lock index 3950c476..270051ee 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -59,6 +59,12 @@ dependencies = [ "windows-sys 0.52.0", ] +[[package]] +name = "anyhow" +version = "1.0.81" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0952808a6c2afd1aa8947271f3a60f1a6763c7b912d210184c5149b5cf147247" + [[package]] name = "assert_cmd" version = "2.0.14" @@ -525,6 +531,7 @@ checksum = "c08c74e62047bb2de4ff487b251e4a92e24f48745648451635cec7d591162d9f" name = "rustlings" version = "5.6.1" dependencies = [ + "anyhow", "assert_cmd", "clap", "console", diff --git a/Cargo.toml b/Cargo.toml index 218b7990..d7b5a096 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -9,6 +9,7 @@ authors = [ edition = "2021" [dependencies] +anyhow = "1.0.81" clap = { version = "4.5.2", features = ["derive"] } console = "0.15.8" glob = "0.3.0" diff --git a/src/main.rs b/src/main.rs index a06f0c56..4a4f2198 100644 --- a/src/main.rs +++ b/src/main.rs @@ -2,6 +2,7 @@ use crate::exercise::{Exercise, ExerciseList}; use crate::project::RustAnalyzerProject; use crate::run::{reset, run}; use crate::verify::verify; +use anyhow::Result; use clap::{Parser, Subcommand}; use console::Emoji; use notify_debouncer_mini::notify::{self, RecursiveMode}; @@ -84,7 +85,7 @@ enum Subcommands { Lsp, } -fn main() { +fn main() -> Result<()> { let args = Args::parse(); if args.command.is_none() { @@ -243,6 +244,8 @@ fn main() { } }, } + + Ok(()) } fn spawn_watch_shell( From 51712cc19f97972f470c4d8791974f8eaba095d1 Mon Sep 17 00:00:00 2001 From: mo8it Date: Mon, 25 Mar 2024 03:49:10 +0100 Subject: [PATCH 20/52] Merge get_sysroot_src into the constructor --- src/main.rs | 5 +--- src/project.rs | 77 +++++++++++++++++++++++++------------------------- 2 files changed, 39 insertions(+), 43 deletions(-) diff --git a/src/main.rs b/src/main.rs index 4a4f2198..4ce0b30d 100644 --- a/src/main.rs +++ b/src/main.rs @@ -204,10 +204,7 @@ fn main() -> Result<()> { } Subcommands::Lsp => { - let mut project = RustAnalyzerProject::new(); - project - .get_sysroot_src() - .expect("Couldn't find toolchain path, do you have `rustc` installed?"); + let mut project = RustAnalyzerProject::build()?; project .exercises_to_json() .expect("Couldn't parse rustlings exercises files"); diff --git a/src/project.rs b/src/project.rs index 93f941dd..a7414d1f 100644 --- a/src/project.rs +++ b/src/project.rs @@ -1,3 +1,4 @@ +use anyhow::{bail, Context, Result}; use glob::glob; use serde::{Deserialize, Serialize}; use std::env; @@ -22,11 +23,44 @@ pub struct Crate { } impl RustAnalyzerProject { - pub fn new() -> RustAnalyzerProject { - RustAnalyzerProject { - sysroot_src: String::new(), - crates: Vec::new(), + pub fn build() -> Result { + // check if RUST_SRC_PATH is set + if let Ok(sysroot_src) = env::var("RUST_SRC_PATH") { + return Ok(Self { + sysroot_src, + crates: Vec::new(), + }); } + + let toolchain = Command::new("rustc") + .arg("--print") + .arg("sysroot") + .output() + .context("Failed to get the sysroot from `rustc`. Do you have `rustc` installed?")? + .stdout; + + let toolchain = + String::from_utf8(toolchain).context("The toolchain path is invalid UTF8")?; + let toolchain = toolchain.trim_end(); + + println!("Determined toolchain: {toolchain}\n"); + + let Ok(sysroot_src) = Path::new(toolchain) + .join("lib") + .join("rustlib") + .join("src") + .join("rust") + .join("library") + .into_os_string() + .into_string() + else { + bail!("The sysroot path is invalid UTF8"); + }; + + Ok(Self { + sysroot_src, + crates: Vec::new(), + }) } /// Write rust-project.json to disk @@ -66,39 +100,4 @@ impl RustAnalyzerProject { } Ok(()) } - - /// Use `rustc` to determine the default toolchain - pub fn get_sysroot_src(&mut self) -> Result<(), Box> { - // check if RUST_SRC_PATH is set - if let Ok(path) = env::var("RUST_SRC_PATH") { - self.sysroot_src = path; - return Ok(()); - } - - let toolchain = Command::new("rustc") - .arg("--print") - .arg("sysroot") - .output()? - .stdout; - - let toolchain = String::from_utf8(toolchain)?; - let toolchain = toolchain.trim_end(); - - println!("Determined toolchain: {toolchain}\n"); - - let Ok(path) = Path::new(toolchain) - .join("lib") - .join("rustlib") - .join("src") - .join("rust") - .join("library") - .into_os_string() - .into_string() - else { - return Err("The sysroot path is invalid UTF8".into()); - }; - self.sysroot_src = path; - - Ok(()) - } } From d095a307ddbdef1f67e89320491c76a1bed1c8eb Mon Sep 17 00:00:00 2001 From: mo8it Date: Mon, 25 Mar 2024 03:59:21 +0100 Subject: [PATCH 21/52] Avoid allocations on every call to Path::join --- src/project.rs | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/src/project.rs b/src/project.rs index a7414d1f..c017aa22 100644 --- a/src/project.rs +++ b/src/project.rs @@ -3,7 +3,7 @@ use glob::glob; use serde::{Deserialize, Serialize}; use std::env; use std::error::Error; -use std::path::{Path, PathBuf}; +use std::path::PathBuf; use std::process::Command; /// Contains the structure of resulting rust-project.json file @@ -45,15 +45,9 @@ impl RustAnalyzerProject { println!("Determined toolchain: {toolchain}\n"); - let Ok(sysroot_src) = Path::new(toolchain) - .join("lib") - .join("rustlib") - .join("src") - .join("rust") - .join("library") - .into_os_string() - .into_string() - else { + let mut sysroot_src = PathBuf::with_capacity(256); + sysroot_src.extend([toolchain, "lib", "rustlib", "src", "rust", "library"]); + let Ok(sysroot_src) = sysroot_src.into_os_string().into_string() else { bail!("The sysroot path is invalid UTF8"); }; From dca3ea355ea1809318ea545f23f396405d86aa0a Mon Sep 17 00:00:00 2001 From: mo8it Date: Mon, 25 Mar 2024 14:10:51 +0100 Subject: [PATCH 22/52] Remove the home dependency since it is not used --- Cargo.lock | 10 ---------- Cargo.toml | 1 - 2 files changed, 11 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 3950c476..9d8606ad 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -255,15 +255,6 @@ version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" -[[package]] -name = "home" -version = "0.5.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e3d1354bf6b7235cb4a0576c2619fd4ed18183f689b12b006a0ee7329eeff9a5" -dependencies = [ - "windows-sys 0.52.0", -] - [[package]] name = "indexmap" version = "2.2.5" @@ -529,7 +520,6 @@ dependencies = [ "clap", "console", "glob", - "home", "indicatif", "notify-debouncer-mini", "predicates", diff --git a/Cargo.toml b/Cargo.toml index 218b7990..2e6ab3bd 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,7 +12,6 @@ edition = "2021" clap = { version = "4.5.2", features = ["derive"] } console = "0.15.8" glob = "0.3.0" -home = "0.5.9" indicatif = "0.17.8" notify-debouncer-mini = "0.4.1" regex = "1.10.3" From b932ed1f672532e7dccf6cd23f6b9895c24a4de7 Mon Sep 17 00:00:00 2001 From: mo8it Date: Mon, 25 Mar 2024 17:14:41 +0100 Subject: [PATCH 23/52] Don't capture stderr --- src/project.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/project.rs b/src/project.rs index c017aa22..1f42d4eb 100644 --- a/src/project.rs +++ b/src/project.rs @@ -4,7 +4,7 @@ use serde::{Deserialize, Serialize}; use std::env; use std::error::Error; use std::path::PathBuf; -use std::process::Command; +use std::process::{Command, Stdio}; /// Contains the structure of resulting rust-project.json file /// and functions to build the data required to create the file @@ -35,6 +35,7 @@ impl RustAnalyzerProject { let toolchain = Command::new("rustc") .arg("--print") .arg("sysroot") + .stderr(Stdio::inherit()) .output() .context("Failed to get the sysroot from `rustc`. Do you have `rustc` installed?")? .stdout; From d911586788ad411be92e43cdc2f7e88fee7e78a4 Mon Sep 17 00:00:00 2001 From: mo8it Date: Mon, 25 Mar 2024 17:21:54 +0100 Subject: [PATCH 24/52] Pipe the output to null instead of capturing and ignoring it --- src/exercise.rs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/exercise.rs b/src/exercise.rs index 664b362b..e6a9222c 100644 --- a/src/exercise.rs +++ b/src/exercise.rs @@ -5,7 +5,7 @@ use std::fmt::{self, Display, Formatter}; use std::fs::{self, remove_file, File}; use std::io::Read; use std::path::PathBuf; -use std::process::{self, Command}; +use std::process::{self, Command, Stdio}; const RUSTC_COLOR_ARGS: &[&str] = &["--color", "always"]; const RUSTC_EDITION_ARGS: &[&str] = &["--edition", "2021"]; @@ -148,7 +148,10 @@ path = "{}.rs""#, .args(RUSTC_COLOR_ARGS) .args(RUSTC_EDITION_ARGS) .args(RUSTC_NO_DEBUG_ARGS) - .output() + .stdin(Stdio::null()) + .stdout(Stdio::null()) + .stderr(Stdio::null()) + .status() .expect("Failed to compile!"); // Due to an issue with Clippy, a cargo clean is required to catch all lints. // See https://github.com/rust-lang/rust-clippy/issues/2604 @@ -157,7 +160,10 @@ path = "{}.rs""#, Command::new("cargo") .args(["clean", "--manifest-path", CLIPPY_CARGO_TOML_PATH]) .args(RUSTC_COLOR_ARGS) - .output() + .stdin(Stdio::null()) + .stdout(Stdio::null()) + .stderr(Stdio::null()) + .status() .expect("Failed to run 'cargo clean'"); Command::new("cargo") .args(["clippy", "--manifest-path", CLIPPY_CARGO_TOML_PATH]) From 87e55ccffde51b08be7d90ab53f1bb2462efa85a Mon Sep 17 00:00:00 2001 From: mo8it Date: Mon, 25 Mar 2024 22:20:00 +0100 Subject: [PATCH 25/52] Use the parsed exercises instead of glob --- Cargo.toml | 1 - src/main.rs | 2 +- src/project.rs | 35 +++++++++++++---------------------- 3 files changed, 14 insertions(+), 24 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index d7b5a096..ef499473 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,7 +12,6 @@ edition = "2021" anyhow = "1.0.81" clap = { version = "4.5.2", features = ["derive"] } console = "0.15.8" -glob = "0.3.0" home = "0.5.9" indicatif = "0.17.8" notify-debouncer-mini = "0.4.1" diff --git a/src/main.rs b/src/main.rs index 4ce0b30d..803e2f8f 100644 --- a/src/main.rs +++ b/src/main.rs @@ -206,7 +206,7 @@ fn main() -> Result<()> { Subcommands::Lsp => { let mut project = RustAnalyzerProject::build()?; project - .exercises_to_json() + .exercises_to_json(exercises) .expect("Couldn't parse rustlings exercises files"); if project.crates.is_empty() { diff --git a/src/project.rs b/src/project.rs index 1f42d4eb..534aab09 100644 --- a/src/project.rs +++ b/src/project.rs @@ -1,11 +1,12 @@ use anyhow::{bail, Context, Result}; -use glob::glob; use serde::{Deserialize, Serialize}; use std::env; use std::error::Error; use std::path::PathBuf; use std::process::{Command, Stdio}; +use crate::exercise::Exercise; + /// Contains the structure of resulting rust-project.json file /// and functions to build the data required to create the file #[derive(Serialize, Deserialize)] @@ -69,30 +70,20 @@ impl RustAnalyzerProject { Ok(()) } - /// If path contains .rs extension, add a crate to `rust-project.json` - fn path_to_json(&mut self, path: PathBuf) -> Result<(), Box> { - if let Some(ext) = path.extension() { - if ext == "rs" { - self.crates.push(Crate { - root_module: path.display().to_string(), - edition: "2021".to_string(), - deps: Vec::new(), - // This allows rust_analyzer to work inside #[test] blocks - cfg: vec!["test".to_string()], - }) - } - } - - Ok(()) - } - /// Parse the exercises folder for .rs files, any matches will create /// a new `crate` in rust-project.json which allows rust-analyzer to /// treat it like a normal binary - pub fn exercises_to_json(&mut self) -> Result<(), Box> { - for path in glob("./exercises/**/*")? { - self.path_to_json(path?)?; - } + pub fn exercises_to_json(&mut self, exercises: Vec) -> Result<(), Box> { + self.crates = exercises + .into_iter() + .map(|exercise| Crate { + root_module: exercise.path.display().to_string(), + edition: "2021".to_string(), + deps: Vec::new(), + // This allows rust_analyzer to work inside #[test] blocks + cfg: vec!["test".to_string()], + }) + .collect(); Ok(()) } } From f5135ae4df96ee018896d667f3dffa187c959193 Mon Sep 17 00:00:00 2001 From: mo8it Date: Mon, 25 Mar 2024 22:29:33 +0100 Subject: [PATCH 26/52] Remove unneeded check if crates is empty --- src/main.rs | 4 +--- src/project.rs | 2 +- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/src/main.rs b/src/main.rs index 803e2f8f..1f260ab7 100644 --- a/src/main.rs +++ b/src/main.rs @@ -209,9 +209,7 @@ fn main() -> Result<()> { .exercises_to_json(exercises) .expect("Couldn't parse rustlings exercises files"); - if project.crates.is_empty() { - println!("Failed find any exercises, make sure you're in the `rustlings` folder"); - } else if project.write_to_disk().is_err() { + if project.write_to_disk().is_err() { println!("Failed to write rust-project.json to disk for rust-analyzer"); } else { println!("Successfully generated rust-project.json"); diff --git a/src/project.rs b/src/project.rs index 534aab09..835a951a 100644 --- a/src/project.rs +++ b/src/project.rs @@ -12,7 +12,7 @@ use crate::exercise::Exercise; #[derive(Serialize, Deserialize)] pub struct RustAnalyzerProject { sysroot_src: String, - pub crates: Vec, + crates: Vec, } #[derive(Serialize, Deserialize)] From a5ba44bd6a939a720cc600e06785bea98baabc37 Mon Sep 17 00:00:00 2001 From: mo8it Date: Mon, 25 Mar 2024 22:30:16 +0100 Subject: [PATCH 27/52] RustAnalyzerProject is not deserialized --- src/project.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/project.rs b/src/project.rs index 835a951a..347ca461 100644 --- a/src/project.rs +++ b/src/project.rs @@ -1,5 +1,5 @@ use anyhow::{bail, Context, Result}; -use serde::{Deserialize, Serialize}; +use serde::Serialize; use std::env; use std::error::Error; use std::path::PathBuf; @@ -9,13 +9,13 @@ use crate::exercise::Exercise; /// Contains the structure of resulting rust-project.json file /// and functions to build the data required to create the file -#[derive(Serialize, Deserialize)] +#[derive(Serialize)] pub struct RustAnalyzerProject { sysroot_src: String, crates: Vec, } -#[derive(Serialize, Deserialize)] +#[derive(Serialize)] pub struct Crate { root_module: String, edition: String, From 8d3ec24c11654d668ef1e1638a7770ec8beadfb7 Mon Sep 17 00:00:00 2001 From: mo8it Date: Mon, 25 Mar 2024 22:41:14 +0100 Subject: [PATCH 28/52] Optimize the serialized data types --- src/project.rs | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/src/project.rs b/src/project.rs index 347ca461..54cffe12 100644 --- a/src/project.rs +++ b/src/project.rs @@ -1,4 +1,4 @@ -use anyhow::{bail, Context, Result}; +use anyhow::{Context, Result}; use serde::Serialize; use std::env; use std::error::Error; @@ -11,24 +11,25 @@ use crate::exercise::Exercise; /// and functions to build the data required to create the file #[derive(Serialize)] pub struct RustAnalyzerProject { - sysroot_src: String, + sysroot_src: PathBuf, crates: Vec, } #[derive(Serialize)] -pub struct Crate { - root_module: String, - edition: String, - deps: Vec, - cfg: Vec, +struct Crate { + root_module: PathBuf, + edition: &'static str, + // Not used, but required in the JSON file. + deps: Vec<()>, + cfg: [&'static str; 1], } impl RustAnalyzerProject { pub fn build() -> Result { // check if RUST_SRC_PATH is set - if let Ok(sysroot_src) = env::var("RUST_SRC_PATH") { + if let Some(path) = env::var_os("RUST_SRC_PATH") { return Ok(Self { - sysroot_src, + sysroot_src: PathBuf::from(path), crates: Vec::new(), }); } @@ -49,9 +50,6 @@ impl RustAnalyzerProject { let mut sysroot_src = PathBuf::with_capacity(256); sysroot_src.extend([toolchain, "lib", "rustlib", "src", "rust", "library"]); - let Ok(sysroot_src) = sysroot_src.into_os_string().into_string() else { - bail!("The sysroot path is invalid UTF8"); - }; Ok(Self { sysroot_src, @@ -77,11 +75,11 @@ impl RustAnalyzerProject { self.crates = exercises .into_iter() .map(|exercise| Crate { - root_module: exercise.path.display().to_string(), - edition: "2021".to_string(), + root_module: exercise.path, + edition: "2021", deps: Vec::new(), // This allows rust_analyzer to work inside #[test] blocks - cfg: vec!["test".to_string()], + cfg: ["test"], }) .collect(); Ok(()) From 8ddbf9635d21a4c0306bd31cca5c4077693ca917 Mon Sep 17 00:00:00 2001 From: mo8it Date: Mon, 25 Mar 2024 23:01:56 +0100 Subject: [PATCH 29/52] Add write_project_json --- src/main.rs | 11 +++------ src/project.rs | 63 +++++++++++++++++++++++--------------------------- 2 files changed, 32 insertions(+), 42 deletions(-) diff --git a/src/main.rs b/src/main.rs index 1f260ab7..46aaf1f3 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,5 +1,5 @@ use crate::exercise::{Exercise, ExerciseList}; -use crate::project::RustAnalyzerProject; +use crate::project::write_project_json; use crate::run::{reset, run}; use crate::verify::verify; use anyhow::Result; @@ -204,13 +204,8 @@ fn main() -> Result<()> { } Subcommands::Lsp => { - let mut project = RustAnalyzerProject::build()?; - project - .exercises_to_json(exercises) - .expect("Couldn't parse rustlings exercises files"); - - if project.write_to_disk().is_err() { - println!("Failed to write rust-project.json to disk for rust-analyzer"); + if let Err(e) = write_project_json(exercises) { + println!("Failed to write rust-project.json to disk for rust-analyzer: {e}"); } else { println!("Successfully generated rust-project.json"); println!("rust-analyzer will now parse exercises, restart your language server or editor") diff --git a/src/project.rs b/src/project.rs index 54cffe12..acf011d3 100644 --- a/src/project.rs +++ b/src/project.rs @@ -1,7 +1,6 @@ use anyhow::{Context, Result}; use serde::Serialize; use std::env; -use std::error::Error; use std::path::PathBuf; use std::process::{Command, Stdio}; @@ -10,7 +9,7 @@ use crate::exercise::Exercise; /// Contains the structure of resulting rust-project.json file /// and functions to build the data required to create the file #[derive(Serialize)] -pub struct RustAnalyzerProject { +struct RustAnalyzerProject { sysroot_src: PathBuf, crates: Vec, } @@ -25,12 +24,22 @@ struct Crate { } impl RustAnalyzerProject { - pub fn build() -> Result { - // check if RUST_SRC_PATH is set + fn build(exercises: Vec) -> Result { + let crates = exercises + .into_iter() + .map(|exercise| Crate { + root_module: exercise.path, + edition: "2021", + deps: Vec::new(), + // This allows rust_analyzer to work inside #[test] blocks + cfg: ["test"], + }) + .collect(); + if let Some(path) = env::var_os("RUST_SRC_PATH") { return Ok(Self { sysroot_src: PathBuf::from(path), - crates: Vec::new(), + crates, }); } @@ -53,35 +62,21 @@ impl RustAnalyzerProject { Ok(Self { sysroot_src, - crates: Vec::new(), + crates, }) } - - /// Write rust-project.json to disk - pub fn write_to_disk(&self) -> Result<(), std::io::Error> { - // Using the capacity 2^14 = 16384 since the file length in bytes is higher than 2^13. - // The final length is not known exactly because it depends on the user's sysroot path, - // the current number of exercises etc. - let mut buf = Vec::with_capacity(16384); - serde_json::to_writer(&mut buf, &self).expect("Failed to serialize to JSON"); - std::fs::write("rust-project.json", buf)?; - Ok(()) - } - - /// Parse the exercises folder for .rs files, any matches will create - /// a new `crate` in rust-project.json which allows rust-analyzer to - /// treat it like a normal binary - pub fn exercises_to_json(&mut self, exercises: Vec) -> Result<(), Box> { - self.crates = exercises - .into_iter() - .map(|exercise| Crate { - root_module: exercise.path, - edition: "2021", - deps: Vec::new(), - // This allows rust_analyzer to work inside #[test] blocks - cfg: ["test"], - }) - .collect(); - Ok(()) - } +} + +/// Write `rust-project.json` to disk. +pub fn write_project_json(exercises: Vec) -> Result<()> { + let content = RustAnalyzerProject::build(exercises)?; + + // Using the capacity 2^14 since the file length in bytes is higher than 2^13. + // The final length is not known exactly because it depends on the user's sysroot path, + // the current number of exercises etc. + let mut buf = Vec::with_capacity(1 << 14); + serde_json::to_writer(&mut buf, &content)?; + std::fs::write("rust-project.json", buf)?; + + Ok(()) } From a158c77d81f2b2870385f70b63511588ed6912ff Mon Sep 17 00:00:00 2001 From: mo8it Date: Mon, 25 Mar 2024 23:21:14 +0100 Subject: [PATCH 30/52] Add comment --- src/project.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/project.rs b/src/project.rs index acf011d3..0f56de96 100644 --- a/src/project.rs +++ b/src/project.rs @@ -20,6 +20,8 @@ struct Crate { edition: &'static str, // Not used, but required in the JSON file. deps: Vec<()>, + // Only `test` is used for all crates. + // Therefore, an array is used instead of a `Vec`. cfg: [&'static str; 1], } @@ -31,7 +33,7 @@ impl RustAnalyzerProject { root_module: exercise.path, edition: "2021", deps: Vec::new(), - // This allows rust_analyzer to work inside #[test] blocks + // This allows rust_analyzer to work inside `#[test]` blocks cfg: ["test"], }) .collect(); @@ -54,7 +56,6 @@ impl RustAnalyzerProject { let toolchain = String::from_utf8(toolchain).context("The toolchain path is invalid UTF8")?; let toolchain = toolchain.trim_end(); - println!("Determined toolchain: {toolchain}\n"); let mut sysroot_src = PathBuf::with_capacity(256); From 7a6f71f09092e8a521d53456491e7d9d8a159602 Mon Sep 17 00:00:00 2001 From: mo8it Date: Tue, 26 Mar 2024 02:14:25 +0100 Subject: [PATCH 31/52] Fix context of previous lines and improve readability --- src/exercise.rs | 154 +++++++++++++++++++++++++----------------------- 1 file changed, 80 insertions(+), 74 deletions(-) diff --git a/src/exercise.rs b/src/exercise.rs index 136e9439..e841aed2 100644 --- a/src/exercise.rs +++ b/src/exercise.rs @@ -3,7 +3,7 @@ use std::fmt::{self, Display, Formatter}; use std::fs::{self, remove_file, File}; use std::io::{self, BufRead, BufReader}; use std::path::PathBuf; -use std::process::{self, Command}; +use std::process::{self, exit, Command}; use std::{array, env, mem}; use winnow::ascii::{space0, Caseless}; use winnow::combinator::opt; @@ -15,7 +15,8 @@ const RUSTC_NO_DEBUG_ARGS: &[&str] = &["-C", "strip=debuginfo"]; const CONTEXT: usize = 2; const CLIPPY_CARGO_TOML_PATH: &str = "./exercises/22_clippy/Cargo.toml"; -fn not_done(input: &str) -> bool { +// Checks if the line contains the "I AM NOT DONE" comment. +fn contains_not_done_comment(input: &str) -> bool { ( space0::<_, ()>, "//", @@ -219,12 +220,15 @@ path = "{}.rs""#, pub fn state(&self) -> State { let source_file = File::open(&self.path).unwrap_or_else(|e| { - panic!( - "We were unable to open the exercise file {}! {e}", - self.path.display() - ) + println!( + "Failed to open the exercise file {}: {e}", + self.path.display(), + ); + exit(1); }); let mut source_reader = BufReader::new(source_file); + + // Read the next line into `buf` without the newline at the end. let mut read_line = |buf: &mut String| -> io::Result<_> { let n = source_reader.read_line(buf)?; if buf.ends_with('\n') { @@ -236,70 +240,72 @@ path = "{}.rs""#, Ok(n) }; - let mut matched_line_ind: usize = 0; + let mut current_line_number: usize = 1; let mut prev_lines: [_; CONTEXT] = array::from_fn(|_| String::with_capacity(256)); let mut line = String::with_capacity(256); loop { - match read_line(&mut line) { - Ok(0) => break, - Ok(_) => { - if not_done(&line) { - let mut context = Vec::with_capacity(2 * CONTEXT + 1); - for (ind, prev_line) in prev_lines - .into_iter() - .rev() - .take(matched_line_ind) - .enumerate() - { - context.push(ContextLine { - line: prev_line, - // TODO - number: matched_line_ind - CONTEXT + ind + 1, - important: false, - }); - } + let n = read_line(&mut line).unwrap_or_else(|e| { + println!( + "Failed to read the exercise file {}: {e}", + self.path.display(), + ); + exit(1); + }); - context.push(ContextLine { - line, - number: matched_line_ind + 1, - important: true, - }); - - for ind in 0..CONTEXT { - let mut next_line = String::with_capacity(256); - let Ok(n) = read_line(&mut next_line) else { - break; - }; - - if n == 0 { - break; - } - - context.push(ContextLine { - line: next_line, - number: matched_line_ind + ind + 2, - important: false, - }); - } - - return State::Pending(context); - } - - matched_line_ind += 1; - for prev_line in &mut prev_lines { - mem::swap(&mut line, prev_line); - } - line.clear(); - } - Err(e) => panic!( - "We were unable to read the exercise file {}! {e}", - self.path.display() - ), + // Reached the end of the file and didn't find the comment. + if n == 0 { + return State::Done; } - } - State::Done + if contains_not_done_comment(&line) { + let mut context = Vec::with_capacity(2 * CONTEXT + 1); + for (ind, prev_line) in prev_lines + .into_iter() + .take(current_line_number - 1) + .enumerate() + .rev() + { + context.push(ContextLine { + line: prev_line, + number: current_line_number - 1 - ind, + important: false, + }); + } + + context.push(ContextLine { + line, + number: current_line_number, + important: true, + }); + + for ind in 0..CONTEXT { + let mut next_line = String::with_capacity(256); + let Ok(n) = read_line(&mut next_line) else { + break; + }; + + if n == 0 { + break; + } + + context.push(ContextLine { + line: next_line, + number: current_line_number + 1 + ind, + important: false, + }); + } + + return State::Pending(context); + } + + current_line_number += 1; + // Recycle the buffers. + for prev_line in &mut prev_lines { + mem::swap(&mut line, prev_line); + } + line.clear(); + } } // Check that the exercise looks to be solved using self.state() @@ -428,17 +434,17 @@ mod test { #[test] fn test_not_done() { - assert!(not_done("// I AM NOT DONE")); - assert!(not_done("/// I AM NOT DONE")); - assert!(not_done("// I AM NOT DONE")); - assert!(not_done("/// I AM NOT DONE")); - assert!(not_done("// I AM NOT DONE ")); - assert!(not_done("// I AM NOT DONE!")); - assert!(not_done("// I am not done")); - assert!(not_done("// i am NOT done")); + assert!(contains_not_done_comment("// I AM NOT DONE")); + assert!(contains_not_done_comment("/// I AM NOT DONE")); + assert!(contains_not_done_comment("// I AM NOT DONE")); + assert!(contains_not_done_comment("/// I AM NOT DONE")); + assert!(contains_not_done_comment("// I AM NOT DONE ")); + assert!(contains_not_done_comment("// I AM NOT DONE!")); + assert!(contains_not_done_comment("// I am not done")); + assert!(contains_not_done_comment("// i am NOT done")); - assert!(!not_done("I AM NOT DONE")); - assert!(!not_done("// NOT DONE")); - assert!(!not_done("DONE")); + assert!(!contains_not_done_comment("I AM NOT DONE")); + assert!(!contains_not_done_comment("// NOT DONE")); + assert!(!contains_not_done_comment("DONE")); } } From 078f6ffc1cf18546079d03bee99f0903c9e14703 Mon Sep 17 00:00:00 2001 From: mo8it Date: Tue, 26 Mar 2024 02:26:26 +0100 Subject: [PATCH 32/52] Add comments --- src/exercise.rs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/exercise.rs b/src/exercise.rs index e841aed2..cdf8d205 100644 --- a/src/exercise.rs +++ b/src/exercise.rs @@ -241,6 +241,7 @@ path = "{}.rs""#, }; let mut current_line_number: usize = 1; + // Keep the last `CONTEXT` lines while iterating over the file lines. let mut prev_lines: [_; CONTEXT] = array::from_fn(|_| String::with_capacity(256)); let mut line = String::with_capacity(256); @@ -260,6 +261,7 @@ path = "{}.rs""#, if contains_not_done_comment(&line) { let mut context = Vec::with_capacity(2 * CONTEXT + 1); + // Previous lines. for (ind, prev_line) in prev_lines .into_iter() .take(current_line_number - 1) @@ -273,18 +275,22 @@ path = "{}.rs""#, }); } + // Current line. context.push(ContextLine { line, number: current_line_number, important: true, }); + // Next lines. for ind in 0..CONTEXT { let mut next_line = String::with_capacity(256); let Ok(n) = read_line(&mut next_line) else { + // If an error occurs, just ignore the next lines. break; }; + // Reached the end of the file. if n == 0 { break; } @@ -300,10 +306,12 @@ path = "{}.rs""#, } current_line_number += 1; - // Recycle the buffers. + // Add the current line as a previous line and shift the older lines by one. for prev_line in &mut prev_lines { mem::swap(&mut line, prev_line); } + // The current line now contains the oldest previous line. + // Recycle it for reading the next line. line.clear(); } } From 853d0593d061119b042a45b602ff52af229dad83 Mon Sep 17 00:00:00 2001 From: mo8it Date: Tue, 26 Mar 2024 17:47:33 +0100 Subject: [PATCH 33/52] Derive Eq when PartialEq is derived --- src/exercise.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/exercise.rs b/src/exercise.rs index 664b362b..a13ed2ce 100644 --- a/src/exercise.rs +++ b/src/exercise.rs @@ -58,7 +58,7 @@ pub struct Exercise { // An enum to track of the state of an Exercise. // An Exercise can be either Done or Pending -#[derive(PartialEq, Debug)] +#[derive(PartialEq, Eq, Debug)] pub enum State { // The state of the exercise once it's been completed Done, @@ -67,7 +67,7 @@ pub enum State { } // The context information of a pending exercise -#[derive(PartialEq, Debug)] +#[derive(PartialEq, Eq, Debug)] pub struct ContextLine { // The source code that is still pending completion pub line: String, From f36efae25deee03cb6f98ce7fc1e59efb7e72985 Mon Sep 17 00:00:00 2001 From: mo8it Date: Tue, 26 Mar 2024 17:48:06 +0100 Subject: [PATCH 34/52] Only use arg instead of args AND arg --- src/run.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/run.rs b/src/run.rs index e0ada4c5..6dd0388f 100644 --- a/src/run.rs +++ b/src/run.rs @@ -21,7 +21,8 @@ pub fn run(exercise: &Exercise, verbose: bool) -> Result<(), ()> { // Resets the exercise by stashing the changes. pub fn reset(exercise: &Exercise) -> Result<(), ()> { let command = Command::new("git") - .args(["stash", "--"]) + .arg("stash") + .arg("--") .arg(&exercise.path) .spawn(); From ed0fcf8e3d05f5420b55370d4ff4ad8e0ded127b Mon Sep 17 00:00:00 2001 From: mo8it Date: Tue, 26 Mar 2024 17:49:05 +0100 Subject: [PATCH 35/52] Formatting --- src/main.rs | 7 ++----- src/verify.rs | 32 +++++++++++++++----------------- 2 files changed, 17 insertions(+), 22 deletions(-) diff --git a/src/main.rs b/src/main.rs index a06f0c56..a0b3af29 100644 --- a/src/main.rs +++ b/src/main.rs @@ -223,10 +223,7 @@ fn main() { Subcommands::Watch { success_hints } => match watch(&exercises, verbose, success_hints) { Err(e) => { - println!( - "Error: Could not watch your progress. Error message was {:?}.", - e - ); + println!("Error: Could not watch your progress. Error message was {e:?}."); println!("Most likely you've run out of disk space or your 'inotify limit' has been reached."); std::process::exit(1); } @@ -280,7 +277,7 @@ fn spawn_watch_shell( if parts.is_empty() { println!("no command provided"); } else if let Err(e) = Command::new(parts[0]).args(&parts[1..]).status() { - println!("failed to execute command `{}`: {}", cmd, e); + println!("failed to execute command `{cmd}`: {e}"); } } else { println!("unknown command: {input}"); diff --git a/src/verify.rs b/src/verify.rs index aee2afa3..3123e455 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} %).", @@ -191,27 +191,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 +229,7 @@ fn prompt_for_completion( "{:>2} {} {}", style(context_line.number).blue().bold(), style("|").blue(), - formatted_line + formatted_line, ); } From 1f2029ae5503024f71203893fe1eab7b90aa80af Mon Sep 17 00:00:00 2001 From: mo8it Date: Tue, 26 Mar 2024 17:49:25 +0100 Subject: [PATCH 36/52] Add missing semicolon --- src/main.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.rs b/src/main.rs index a0b3af29..6884a0e5 100644 --- a/src/main.rs +++ b/src/main.rs @@ -217,7 +217,7 @@ fn main() { println!("Failed to write rust-project.json to disk for rust-analyzer"); } else { println!("Successfully generated rust-project.json"); - println!("rust-analyzer will now parse exercises, restart your language server or editor") + println!("rust-analyzer will now parse exercises, restart your language server or editor"); } } From 980ffa2a2bb791992ef05ca9b05aadba62ec6abc Mon Sep 17 00:00:00 2001 From: mo8it Date: Tue, 26 Mar 2024 17:49:48 +0100 Subject: [PATCH 37/52] Use == on simple enums --- src/verify.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/verify.rs b/src/verify.rs index 3123e455..e2fa98f2 100644 --- a/src/verify.rs +++ b/src/verify.rs @@ -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) From e89028581cd03c02cb0971a2772fa382667019a3 Mon Sep 17 00:00:00 2001 From: mo8it Date: Tue, 26 Mar 2024 17:49:55 +0100 Subject: [PATCH 38/52] Use == instead of eq --- src/main.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.rs b/src/main.rs index 6884a0e5..559be698 100644 --- a/src/main.rs +++ b/src/main.rs @@ -289,7 +289,7 @@ fn spawn_watch_shell( } fn find_exercise<'a>(name: &str, exercises: &'a [Exercise]) -> &'a Exercise { - if name.eq("next") { + if name == "next" { exercises .iter() .find(|e| !e.looks_done()) From a610fc1bc21a04017542208ef70a8010ee00c04c Mon Sep 17 00:00:00 2001 From: mo8it Date: Tue, 26 Mar 2024 17:50:10 +0100 Subject: [PATCH 39/52] Remove unneeded closure --- src/main.rs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/main.rs b/src/main.rs index 559be698..eca73fa0 100644 --- a/src/main.rs +++ b/src/main.rs @@ -335,7 +335,6 @@ fn watch( clear_screen(); - let to_owned_hint = |t: &Exercise| t.hint.to_owned(); let failed_exercise_hint = match verify( exercises.iter(), (0, exercises.len()), @@ -343,7 +342,7 @@ fn watch( success_hints, ) { Ok(_) => return Ok(WatchStatus::Finished), - Err(exercise) => Arc::new(Mutex::new(Some(to_owned_hint(exercise)))), + Err(exercise) => Arc::new(Mutex::new(Some(exercise.hint.clone()))), }; spawn_watch_shell(&failed_exercise_hint, Arc::clone(&should_quit)); loop { @@ -380,7 +379,7 @@ fn watch( Err(exercise) => { let mut failed_exercise_hint = failed_exercise_hint.lock().unwrap(); - *failed_exercise_hint = Some(to_owned_hint(exercise)); + *failed_exercise_hint = Some(exercise.hint.clone()); } } } From 87001a68c0cc6b3498a253d0923e9c609355c4ee Mon Sep 17 00:00:00 2001 From: mo8it Date: Tue, 26 Mar 2024 17:50:29 +0100 Subject: [PATCH 40/52] The string doesn't have to be a raw string --- src/main.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main.rs b/src/main.rs index eca73fa0..141549c6 100644 --- a/src/main.rs +++ b/src/main.rs @@ -411,7 +411,7 @@ fn rustc_exists() -> bool { .unwrap_or(false) } -const DEFAULT_OUT: &str = r#"Thanks for installing Rustlings! +const DEFAULT_OUT: &str = "Thanks for installing Rustlings! Is this your first time? Don't worry, Rustlings was made for beginners! We are going to teach you a lot of things about Rust, but before we can get @@ -437,7 +437,7 @@ started, here's a couple of notes about how Rustlings operates: autocompletion, run the command `rustlings lsp`. Got all that? Great! To get started, run `rustlings watch` in order to get the first -exercise. Make sure to have your editor open!"#; +exercise. Make sure to have your editor open!"; const FENISH_LINE: &str = "+----------------------------------------------------+ | You made it to the Fe-nish line! | From 76764633b46ee570e2b7d2b8564d37b7292fa337 Mon Sep 17 00:00:00 2001 From: mo8it Date: Wed, 27 Mar 2024 15:16:42 +0100 Subject: [PATCH 41/52] Update deps --- Cargo.lock | 56 +++++++++++++++++++++++++++--------------------------- Cargo.toml | 4 ++-- 2 files changed, 30 insertions(+), 30 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 11880b7f..f4853d0c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4,9 +4,9 @@ version = 3 [[package]] name = "aho-corasick" -version = "1.1.2" +version = "1.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b2969dcb958b36655471fc61f7e416fa76033bdd4bfed0678d8fee1e2d07a1f0" +checksum = "8e60d3430d3a69478ad0993f19238d2df97c507009a52b3c10addcd7f6bcb916" dependencies = [ "memchr", ] @@ -82,9 +82,9 @@ dependencies = [ [[package]] name = "autocfg" -version = "1.1.0" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" +checksum = "f1fdabc7756949593fe60f30ec81974b613357de856987752631dea1e3394c80" [[package]] name = "bitflags" @@ -94,9 +94,9 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] name = "bitflags" -version = "2.4.2" +version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed570934406eb16438a4e976b1b4500774099c13b8cb96eec99f620f05090ddf" +checksum = "cf4b9d6a944f767f8e5e0db018570623c85f3d925ac718db4e06d0187adb21c1" [[package]] name = "bstr" @@ -117,9 +117,9 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "clap" -version = "4.5.2" +version = "4.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b230ab84b0ffdf890d5a10abdbc8b83ae1c4918275daea1ab8801f71536b2651" +checksum = "90bc066a67923782aa8515dbaea16946c5bcc5addbd668bb80af688e53e548a0" dependencies = [ "clap_builder", "clap_derive", @@ -139,9 +139,9 @@ dependencies = [ [[package]] name = "clap_derive" -version = "4.5.0" +version = "4.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "307bc0538d5f0f83b8248db3087aa92fe504e4691294d0c96c0eabc33f47ba47" +checksum = "528131438037fd55894f62d6e9f068b8f45ac57ffa77517819645d10aed04f64" dependencies = [ "heck", "proc-macro2", @@ -273,9 +273,9 @@ checksum = "290f1a1d9242c78d09ce40a5e87e7554ee637af1351968159f4952f028f75604" [[package]] name = "heck" -version = "0.4.1" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" +checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" [[package]] name = "home" @@ -288,9 +288,9 @@ dependencies = [ [[package]] name = "indexmap" -version = "2.2.5" +version = "2.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b0b929d511467233429c45a44ac1dcaa21ba0f5ba11e4879e6ed28ddb4f9df4" +checksum = "168fb715dda47215e360912c096649d23d58bf392ac62f73919e831745e40f26" dependencies = [ "equivalent", "hashbrown", @@ -340,9 +340,9 @@ dependencies = [ [[package]] name = "itoa" -version = "1.0.10" +version = "1.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1a46d1a171d865aa5f83f92695765caa047a9b4cbae2cbf37dbd613a793fd4c" +checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b" [[package]] name = "kqueue" @@ -418,7 +418,7 @@ version = "6.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6205bd8bb1e454ad2e27422015fb5e4f2bcc7e08fa8f27058670d208324a4d2d" dependencies = [ - "bitflags 2.4.2", + "bitflags 2.5.0", "crossbeam-channel", "filetime", "fsevent-sys", @@ -495,9 +495,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.78" +version = "1.0.79" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2422ad645d89c99f8f3e6b88a9fdeca7fabeac836b1002371c4367c8f984aae" +checksum = "e835ff2298f5721608eb1a980ecaee1aef2c132bf95ecc026a11b7bf3c01c02e" dependencies = [ "unicode-ident", ] @@ -522,9 +522,9 @@ dependencies = [ [[package]] name = "regex" -version = "1.10.3" +version = "1.10.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b62dbe01f0b06f9d8dc7d49e05a0785f153b00b2c227856282f671e0318c9b15" +checksum = "c117dbdfde9c8308975b6a18d71f3f385c89461f7b3fb054288ecf2a2058ba4c" dependencies = [ "aho-corasick", "memchr", @@ -545,9 +545,9 @@ dependencies = [ [[package]] name = "regex-syntax" -version = "0.8.2" +version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c08c74e62047bb2de4ff487b251e4a92e24f48745648451635cec7d591162d9f" +checksum = "adad44e29e4c806119491a7f06f03de4d1af22c3a680dd47f1e6e179439d1f56" [[package]] name = "rustix" @@ -555,7 +555,7 @@ version = "0.38.32" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "65e04861e65f21776e67888bfbea442b3642beaa0138fdb1dd7a84a52dffdb89" dependencies = [ - "bitflags 2.4.2", + "bitflags 2.5.0", "errno", "libc", "linux-raw-sys", @@ -619,9 +619,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.114" +version = "1.0.115" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c5f09b1bd632ef549eaa9f60a1f8de742bdbc698e6cee2095fc84dde5f549ae0" +checksum = "12dc5c46daa8e9fdf4f5e71b6cf9a53f2487da0e86e55808e2d35539666497dd" dependencies = [ "itoa", "ryu", @@ -651,9 +651,9 @@ checksum = "5ee073c9e4cd00e28217186dbe12796d692868f432bf2e97ee73bed0c56dfa01" [[package]] name = "syn" -version = "2.0.52" +version = "2.0.55" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b699d15b36d1f02c3e7c69f8ffef53de37aefae075d8488d4ba1a7788d574a07" +checksum = "002a1b3dbf967edfafc32655d0f377ab0bb7b994aa1d32c8cc7e9b8bf3ebb8f0" dependencies = [ "proc-macro2", "quote", diff --git a/Cargo.toml b/Cargo.toml index 36e11235..2d152cfc 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -10,11 +10,11 @@ edition = "2021" [dependencies] anyhow = "1.0.81" -clap = { version = "4.5.2", features = ["derive"] } +clap = { version = "4.5.4", features = ["derive"] } console = "0.15.8" indicatif = "0.17.8" notify-debouncer-mini = "0.4.1" -serde_json = "1.0.114" +serde_json = "1.0.115" serde = { version = "1.0.197", features = ["derive"] } shlex = "1.3.0" toml_edit = { version = "0.22.9", default-features = false, features = ["parse", "serde"] } From e7bb832bf3e651f88fa3318df7e6b04b56fb9dee Mon Sep 17 00:00:00 2001 From: mo8it Date: Wed, 27 Mar 2024 17:03:53 +0100 Subject: [PATCH 42/52] Remove outdated info about the command line parser --- CONTRIBUTING.md | 1 - 1 file changed, 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index cc8ac923..d66e3de5 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -21,7 +21,6 @@ _implement a new feature! ➡️ [open an Issue to discuss it first, then a Pull `rustlings` is basically a glorified `rustc` wrapper. Therefore the source code isn't really that complicated since the bulk of the work is done by `rustc`. -`src/main.rs` contains a simple `argh` CLI that connects to most of the other source files. ### Adding an exercise From 92183a74c4c7b91459c1371bb7a68b5e4c1c23bd Mon Sep 17 00:00:00 2001 From: wznmickey Date: Thu, 28 Mar 2024 00:06:16 +0800 Subject: [PATCH 43/52] chore: update the chapter of macros --- exercises/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exercises/README.md b/exercises/README.md index c7effa95..4cb966e5 100644 --- a/exercises/README.md +++ b/exercises/README.md @@ -22,6 +22,6 @@ | iterators | §13.2-4 | | threads | §16.1-3 | | smart_pointers | §15, §16.3 | -| macros | §19.6 | +| macros | §19.5 | | clippy | §21.4 | | conversions | n/a | From 971e7f94dc58b6846e3b4e7f3d5df5b4ea72790b Mon Sep 17 00:00:00 2001 From: mo8it Date: Wed, 27 Mar 2024 17:08:38 +0100 Subject: [PATCH 44/52] Update the link to conventionalcommits.org --- CONTRIBUTING.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index d66e3de5..4fc7fb79 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -65,7 +65,7 @@ changes. There's a couple of things to watch out for: #### Write correct commit messages -We follow the [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0-beta.4/) +We follow the [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/) specification. This means that you have to format your commit messages in a specific way. Say you're working on adding a new exercise called `foobar1.rs`. You could write From 669adbeb604b66631040f9322549f3e6afaeef3d Mon Sep 17 00:00:00 2001 From: "allcontributors[bot]" <46447321+allcontributors[bot]@users.noreply.github.com> Date: Wed, 27 Mar 2024 16:21:13 +0000 Subject: [PATCH 45/52] docs: update AUTHORS.md [skip ci] --- AUTHORS.md | 1 + 1 file changed, 1 insertion(+) diff --git a/AUTHORS.md b/AUTHORS.md index 00122e07..0f229dbb 100644 --- a/AUTHORS.md +++ b/AUTHORS.md @@ -378,6 +378,7 @@ authors. 0Ahmed-0
0Ahmed-0

🖋 guizo792
guizo792

🖋 Kazuki Matsuo
Kazuki Matsuo

💻 + Paul Leydier
Paul Leydier

📖 From fb8dd57d1f2aa1e3865266f08d91e128f6207c64 Mon Sep 17 00:00:00 2001 From: "allcontributors[bot]" <46447321+allcontributors[bot]@users.noreply.github.com> Date: Wed, 27 Mar 2024 16:21:14 +0000 Subject: [PATCH 46/52] docs: update .all-contributorsrc [skip ci] --- .all-contributorsrc | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/.all-contributorsrc b/.all-contributorsrc index f2446f1f..e5b319cc 100644 --- a/.all-contributorsrc +++ b/.all-contributorsrc @@ -2685,6 +2685,15 @@ "contributions": [ "code" ] + }, + { + "login": "paul-leydier", + "name": "Paul Leydier", + "avatar_url": "https://avatars.githubusercontent.com/u/75126792?v=4", + "profile": "https://github.com/paul-leydier", + "contributions": [ + "doc" + ] } ], "contributorsPerLine": 8, From 7b20ca9d0415ef94902c897242e3c6fbd154b6a6 Mon Sep 17 00:00:00 2001 From: "allcontributors[bot]" <46447321+allcontributors[bot]@users.noreply.github.com> Date: Wed, 27 Mar 2024 16:23:45 +0000 Subject: [PATCH 47/52] docs: update AUTHORS.md [skip ci] --- AUTHORS.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/AUTHORS.md b/AUTHORS.md index 0f229dbb..f229173a 100644 --- a/AUTHORS.md +++ b/AUTHORS.md @@ -380,6 +380,9 @@ authors. Kazuki Matsuo
Kazuki Matsuo

💻 Paul Leydier
Paul Leydier

📖 + + wznmickey
wznmickey

📖 + From 4937cb5b7c38dbecf232641c0864d5d9b261aebd Mon Sep 17 00:00:00 2001 From: "allcontributors[bot]" <46447321+allcontributors[bot]@users.noreply.github.com> Date: Wed, 27 Mar 2024 16:23:46 +0000 Subject: [PATCH 48/52] docs: update .all-contributorsrc [skip ci] --- .all-contributorsrc | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/.all-contributorsrc b/.all-contributorsrc index e5b319cc..2eae5878 100644 --- a/.all-contributorsrc +++ b/.all-contributorsrc @@ -2694,6 +2694,15 @@ "contributions": [ "doc" ] + }, + { + "login": "wznmickey", + "name": "wznmickey", + "avatar_url": "https://avatars.githubusercontent.com/u/44784663?v=4", + "profile": "http://wznmickey.com", + "contributions": [ + "doc" + ] } ], "contributorsPerLine": 8, From 4e7f9ca1b3741fccc28b1f71118b0ffb5cf39aa4 Mon Sep 17 00:00:00 2001 From: "allcontributors[bot]" <46447321+allcontributors[bot]@users.noreply.github.com> Date: Wed, 27 Mar 2024 16:29:03 +0000 Subject: [PATCH 49/52] docs: update AUTHORS.md [skip ci] --- AUTHORS.md | 1 + 1 file changed, 1 insertion(+) diff --git a/AUTHORS.md b/AUTHORS.md index f229173a..4a98bb9b 100644 --- a/AUTHORS.md +++ b/AUTHORS.md @@ -382,6 +382,7 @@ authors. wznmickey
wznmickey

📖 + NicolasRoelandt
NicolasRoelandt

📖 From 9895c1f9bda4d9bf85c4a10157ff4714f57c52fc Mon Sep 17 00:00:00 2001 From: "allcontributors[bot]" <46447321+allcontributors[bot]@users.noreply.github.com> Date: Wed, 27 Mar 2024 16:29:04 +0000 Subject: [PATCH 50/52] docs: update .all-contributorsrc [skip ci] --- .all-contributorsrc | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/.all-contributorsrc b/.all-contributorsrc index 2eae5878..3095896d 100644 --- a/.all-contributorsrc +++ b/.all-contributorsrc @@ -2703,6 +2703,15 @@ "contributions": [ "doc" ] + }, + { + "login": "NicolasRoelandt", + "name": "NicolasRoelandt", + "avatar_url": "https://avatars.githubusercontent.com/u/8594193?v=4", + "profile": "https://github.com/NicolasRoelandt", + "contributions": [ + "doc" + ] } ], "contributorsPerLine": 8, From 0888952cb95946885f364a6218346200fb8f0bb4 Mon Sep 17 00:00:00 2001 From: "allcontributors[bot]" <46447321+allcontributors[bot]@users.noreply.github.com> Date: Thu, 28 Mar 2024 01:10:05 +0000 Subject: [PATCH 51/52] docs: update AUTHORS.md [skip ci] --- AUTHORS.md | 1 + 1 file changed, 1 insertion(+) diff --git a/AUTHORS.md b/AUTHORS.md index 4a98bb9b..42c7dbfe 100644 --- a/AUTHORS.md +++ b/AUTHORS.md @@ -383,6 +383,7 @@ authors. wznmickey
wznmickey

📖 NicolasRoelandt
NicolasRoelandt

📖 + Josh Bouganim
Josh Bouganim

💻 From 24cb4a3bc973fa97fb40cda2e46a2a73d1aeda48 Mon Sep 17 00:00:00 2001 From: "allcontributors[bot]" <46447321+allcontributors[bot]@users.noreply.github.com> Date: Thu, 28 Mar 2024 01:10:06 +0000 Subject: [PATCH 52/52] docs: update .all-contributorsrc [skip ci] --- .all-contributorsrc | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/.all-contributorsrc b/.all-contributorsrc index 3095896d..be95fe9f 100644 --- a/.all-contributorsrc +++ b/.all-contributorsrc @@ -2712,6 +2712,15 @@ "contributions": [ "doc" ] + }, + { + "login": "jbouganim-parallel", + "name": "Josh Bouganim", + "avatar_url": "https://avatars.githubusercontent.com/u/150748285?v=4", + "profile": "https://github.com/jbouganim-parallel", + "contributions": [ + "code" + ] } ], "contributorsPerLine": 8,