From f146553dead78357cd44736dfca97b1349418fa2 Mon Sep 17 00:00:00 2001 From: mo8it Date: Thu, 17 Oct 2024 14:37:47 +0200 Subject: [PATCH 001/120] hashmap3: Use `or_default` --- rustlings-macros/info.toml | 8 ++------ solutions/11_hashmaps/hashmaps3.rs | 8 ++------ 2 files changed, 4 insertions(+), 12 deletions(-) diff --git a/rustlings-macros/info.toml b/rustlings-macros/info.toml index c1342d68..e7055981 100644 --- a/rustlings-macros/info.toml +++ b/rustlings-macros/info.toml @@ -575,12 +575,8 @@ https://doc.rust-lang.org/book/ch08-03-hash-maps.html#only-inserting-a-value-if- name = "hashmaps3" dir = "11_hashmaps" hint = """ -Hint 1: Use the `entry()` and `or_insert()` (or `or_insert_with()`) methods of - `HashMap` to insert the default value of `TeamScores` if a team doesn't - exist in the table yet. - -Learn more in The Book: -https://doc.rust-lang.org/book/ch08-03-hash-maps.html#only-inserting-a-value-if-the-key-has-no-value +Hint 1: Use the `entry()` and `or_default()` methods of `HashMap` to insert the + default value of `TeamScores` if a team doesn't exist in the table yet. Hint 2: If there is already an entry for a given key, the value returned by `entry()` can be updated based on the existing value. diff --git a/solutions/11_hashmaps/hashmaps3.rs b/solutions/11_hashmaps/hashmaps3.rs index 8a5d30b6..41da784b 100644 --- a/solutions/11_hashmaps/hashmaps3.rs +++ b/solutions/11_hashmaps/hashmaps3.rs @@ -28,17 +28,13 @@ fn build_scores_table(results: &str) -> HashMap<&str, TeamScores> { let team_2_score: u8 = split_iterator.next().unwrap().parse().unwrap(); // Insert the default with zeros if a team doesn't exist yet. - let team_1 = scores - .entry(team_1_name) - .or_insert_with(TeamScores::default); + let team_1 = scores.entry(team_1_name).or_default(); // Update the values. team_1.goals_scored += team_1_score; team_1.goals_conceded += team_2_score; // Similarly for the second team. - let team_2 = scores - .entry(team_2_name) - .or_insert_with(TeamScores::default); + let team_2 = scores.entry(team_2_name).or_default(); team_2.goals_scored += team_2_score; team_2.goals_conceded += team_1_score; } From 99496706c5041affdc252649bfc74d50a2187271 Mon Sep 17 00:00:00 2001 From: mo8it Date: Thu, 17 Oct 2024 14:44:48 +0200 Subject: [PATCH 002/120] Apply new Clippy lints --- src/cmd.rs | 2 +- src/term.rs | 24 ++++++++++++------------ 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/cmd.rs b/src/cmd.rs index 4a93312a..30f988a6 100644 --- a/src/cmd.rs +++ b/src/cmd.rs @@ -125,7 +125,7 @@ pub struct CargoSubcommand<'out> { output: Option<&'out mut Vec>, } -impl<'out> CargoSubcommand<'out> { +impl CargoSubcommand<'_> { #[inline] pub fn args<'arg, I>(&mut self, args: I) -> &mut Self where diff --git a/src/term.rs b/src/term.rs index e3bfd7bb..cb0a07ce 100644 --- a/src/term.rs +++ b/src/term.rs @@ -11,15 +11,15 @@ use std::{ use crate::app_state::CheckProgress; -pub struct MaxLenWriter<'a, 'b> { - pub stdout: &'a mut StdoutLock<'b>, +pub struct MaxLenWriter<'a, 'lock> { + pub stdout: &'a mut StdoutLock<'lock>, len: usize, max_len: usize, } -impl<'a, 'b> MaxLenWriter<'a, 'b> { +impl<'a, 'lock> MaxLenWriter<'a, 'lock> { #[inline] - pub fn new(stdout: &'a mut StdoutLock<'b>, max_len: usize) -> Self { + pub fn new(stdout: &'a mut StdoutLock<'lock>, max_len: usize) -> Self { Self { stdout, len: 0, @@ -34,13 +34,13 @@ impl<'a, 'b> MaxLenWriter<'a, 'b> { } } -pub trait CountedWrite<'a> { +pub trait CountedWrite<'lock> { fn write_ascii(&mut self, ascii: &[u8]) -> io::Result<()>; fn write_str(&mut self, unicode: &str) -> io::Result<()>; - fn stdout(&mut self) -> &mut StdoutLock<'a>; + fn stdout(&mut self) -> &mut StdoutLock<'lock>; } -impl<'a, 'b> CountedWrite<'b> for MaxLenWriter<'a, 'b> { +impl<'lock> CountedWrite<'lock> for MaxLenWriter<'_, 'lock> { fn write_ascii(&mut self, ascii: &[u8]) -> io::Result<()> { let n = ascii.len().min(self.max_len.saturating_sub(self.len)); if n > 0 { @@ -65,7 +65,7 @@ impl<'a, 'b> CountedWrite<'b> for MaxLenWriter<'a, 'b> { } #[inline] - fn stdout(&mut self) -> &mut StdoutLock<'b> { + fn stdout(&mut self) -> &mut StdoutLock<'lock> { self.stdout } } @@ -87,17 +87,17 @@ impl<'a> CountedWrite<'a> for StdoutLock<'a> { } } -pub struct CheckProgressVisualizer<'a, 'b> { - stdout: &'a mut StdoutLock<'b>, +pub struct CheckProgressVisualizer<'a, 'lock> { + stdout: &'a mut StdoutLock<'lock>, n_cols: usize, } -impl<'a, 'b> CheckProgressVisualizer<'a, 'b> { +impl<'a, 'lock> CheckProgressVisualizer<'a, 'lock> { const CHECKING_COLOR: Color = Color::Blue; const DONE_COLOR: Color = Color::Green; const PENDING_COLOR: Color = Color::Red; - pub fn build(stdout: &'a mut StdoutLock<'b>, term_width: u16) -> io::Result { + pub fn build(stdout: &'a mut StdoutLock<'lock>, term_width: u16) -> io::Result { clear_terminal(stdout)?; stdout.write_all("Checking all exercises…\n".as_bytes())?; From 0e090ae11244ee8e0cdb50501b34c36a7112fd0c Mon Sep 17 00:00:00 2001 From: mo8it Date: Thu, 17 Oct 2024 14:48:56 +0200 Subject: [PATCH 003/120] Add required type annotation --- exercises/11_hashmaps/hashmaps3.rs | 2 +- solutions/11_hashmaps/hashmaps3.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/exercises/11_hashmaps/hashmaps3.rs b/exercises/11_hashmaps/hashmaps3.rs index 7e9584d1..5b390ab9 100644 --- a/exercises/11_hashmaps/hashmaps3.rs +++ b/exercises/11_hashmaps/hashmaps3.rs @@ -17,7 +17,7 @@ struct TeamScores { fn build_scores_table(results: &str) -> HashMap<&str, TeamScores> { // The name of the team is the key and its associated struct is the value. - let mut scores = HashMap::new(); + let mut scores = HashMap::<&str, TeamScores>::new(); for line in results.lines() { let mut split_iterator = line.split(','); diff --git a/solutions/11_hashmaps/hashmaps3.rs b/solutions/11_hashmaps/hashmaps3.rs index 41da784b..433b16c3 100644 --- a/solutions/11_hashmaps/hashmaps3.rs +++ b/solutions/11_hashmaps/hashmaps3.rs @@ -17,7 +17,7 @@ struct TeamScores { fn build_scores_table(results: &str) -> HashMap<&str, TeamScores> { // The name of the team is the key and its associated struct is the value. - let mut scores = HashMap::new(); + let mut scores = HashMap::<&str, TeamScores>::new(); for line in results.lines() { let mut split_iterator = line.split(','); From e90f5f03f3da639bf3157aec12ebf0cec62ac7ae Mon Sep 17 00:00:00 2001 From: mo8it Date: Thu, 17 Oct 2024 14:59:37 +0200 Subject: [PATCH 004/120] Mention the Q&A category --- README.md | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index b65920f2..9a223670 100644 --- a/README.md +++ b/README.md @@ -124,14 +124,13 @@ The list allows you to… - See the status of all exercises (done or pending) - `c`: Continue at another exercise (temporarily skip some exercises or go back to a previous one) -- `r`: Reset status and file of an exercise (you need to _reload/reopen_ its file in your editor afterwards) +- `r`: Reset status and file of the selected exercise (you need to _reload/reopen_ its file in your editor afterwards) See the footer of the list for all possible keys. -## Continuing On +## Questions? -Once you've completed Rustlings, put your new knowledge to good use! -Continue practicing your Rust skills by building your own projects, contributing to Rustlings, or finding other open-source projects to contribute to. +If you need any help while doing the exercises and the builtin-hints aren't helpful, feel free to ask in the [_Q&A_ category of the discussions](https://github.com/rust-lang/rustlings/discussions/categories/q-a?discussions_q=) if your question wasn't asked yet 💡 ## Third-Party Exercises @@ -144,6 +143,11 @@ Do you want to create your own set of Rustlings exercises to focus on some speci Or do you want to translate the original Rustlings exercises? Then follow the the guide about [third-party exercises](https://github.com/rust-lang/rustlings/blob/main/THIRD_PARTY_EXERCISES.md)! +## Continuing On + +Once you've completed Rustlings, put your new knowledge to good use! +Continue practicing your Rust skills by building your own projects, contributing to Rustlings, or finding other open-source projects to contribute to. + ## Uninstalling Rustlings If you want to remove Rustlings from your system, run the following command: From 7e2f56f41a89213d3ae60a069402a25b570f0cca Mon Sep 17 00:00:00 2001 From: mo8it Date: Thu, 17 Oct 2024 15:03:43 +0200 Subject: [PATCH 005/120] Use the default hasher --- Cargo.lock | 15 ++++----------- Cargo.toml | 1 - clippy.toml | 3 --- src/app_state.rs | 4 ++-- src/collections.rs | 9 --------- src/dev/check.rs | 8 ++++---- src/main.rs | 1 - 7 files changed, 10 insertions(+), 31 deletions(-) delete mode 100644 src/collections.rs diff --git a/Cargo.lock b/Cargo.lock index f89c139f..1ac56b40 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -186,12 +186,6 @@ dependencies = [ "windows-sys 0.59.0", ] -[[package]] -name = "foldhash" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f81ec6369c545a7d40e4589b5597581fa1c441fe1cce96dd1de43159910a36a2" - [[package]] name = "fsevent-sys" version = "4.1.0" @@ -283,9 +277,9 @@ dependencies = [ [[package]] name = "libc" -version = "0.2.159" +version = "0.2.160" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "561d97a539a36e26a9a5fad1ea11a3039a67714694aaa379433e580854bc3dc5" +checksum = "f0b21006cd1874ae9e650973c565615676dc4a274c965bb0a73796dac838ce4f" [[package]] name = "libredox" @@ -410,9 +404,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.87" +version = "1.0.88" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b3e4daa0dcf6feba26f985457cdf104d4b4256fc5a09547140f3631bb076b19a" +checksum = "7c3a7fc5db1e57d5a779a352c8cdb57b29aa4c40cc69c3a68a7fedc815fbf2f9" dependencies = [ "unicode-ident", ] @@ -455,7 +449,6 @@ dependencies = [ "anyhow", "clap", "crossterm", - "foldhash", "notify", "os_pipe", "rustix", diff --git a/Cargo.toml b/Cargo.toml index eb22cfee..4dbcb5fb 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -49,7 +49,6 @@ include = [ anyhow = "1.0.89" clap = { version = "4.5.20", features = ["derive"] } crossterm = { version = "0.28.1", default-features = false, features = ["windows", "events"] } -foldhash = "0.1.3" notify = { version = "6.1.1", default-features = false, features = ["macos_fsevent"] } os_pipe = "1.2.1" rustlings-macros = { path = "rustlings-macros", version = "=6.3.0" } diff --git a/clippy.toml b/clippy.toml index 2a981849..afc9253a 100644 --- a/clippy.toml +++ b/clippy.toml @@ -5,9 +5,6 @@ disallowed-types = [ ] disallowed-methods = [ - # We use `foldhash` instead of the default hasher. - "std::collections::HashSet::new", - "std::collections::HashSet::with_capacity", # Inefficient. Use `.queue(…)` instead. "crossterm::style::style", # Use `thread::Builder::spawn` instead and handle the error. diff --git a/src/app_state.rs b/src/app_state.rs index 4007fbc3..5979150f 100644 --- a/src/app_state.rs +++ b/src/app_state.rs @@ -1,6 +1,7 @@ use anyhow::{bail, Context, Error, Result}; use crossterm::{cursor, terminal, QueueableCommand}; use std::{ + collections::HashSet, env, fs::{File, OpenOptions}, io::{Read, Seek, StdoutLock, Write}, @@ -16,7 +17,6 @@ use std::{ use crate::{ clear_terminal, cmd::CmdRunner, - collections::hash_set_with_capacity, embedded::EMBEDDED_FILES, exercise::{Exercise, RunnableExercise}, info_file::ExerciseInfo, @@ -146,7 +146,7 @@ impl AppState { break 'block StateFileStatus::NotRead; } - let mut done_exercises = hash_set_with_capacity(exercises.len()); + let mut done_exercises = HashSet::with_capacity(exercises.len()); for done_exercise_name in lines { if done_exercise_name.is_empty() { diff --git a/src/collections.rs b/src/collections.rs deleted file mode 100644 index 3f2841e0..00000000 --- a/src/collections.rs +++ /dev/null @@ -1,9 +0,0 @@ -use foldhash::fast::FixedState; - -/// DOS attacks aren't a concern for Rustlings. Therefore, we use `foldhash` with a fixed state. -pub type HashSet = std::collections::HashSet; - -#[inline] -pub fn hash_set_with_capacity(capacity: usize) -> HashSet { - HashSet::with_capacity_and_hasher(capacity, FixedState::default()) -} diff --git a/src/dev/check.rs b/src/dev/check.rs index 119fed5f..956c2be2 100644 --- a/src/dev/check.rs +++ b/src/dev/check.rs @@ -1,6 +1,7 @@ use anyhow::{anyhow, bail, Context, Error, Result}; use std::{ cmp::Ordering, + collections::HashSet, fs::{self, read_dir, OpenOptions}, io::{self, Read, Write}, path::{Path, PathBuf}, @@ -11,7 +12,6 @@ use std::{ use crate::{ cargo_toml::{append_bins, bins_start_end_ind, BINS_BUFFER_CAPACITY}, cmd::CmdRunner, - collections::{hash_set_with_capacity, HashSet}, exercise::{RunnableExercise, OUTPUT_CAPACITY}, info_file::{ExerciseInfo, InfoFile}, CURRENT_FORMAT_VERSION, @@ -53,8 +53,8 @@ fn check_cargo_toml( // Check the info of all exercises and return their paths in a set. fn check_info_file_exercises(info_file: &InfoFile) -> Result> { - let mut names = hash_set_with_capacity(info_file.exercises.len()); - let mut paths = hash_set_with_capacity(info_file.exercises.len()); + let mut names = HashSet::with_capacity(info_file.exercises.len()); + let mut paths = HashSet::with_capacity(info_file.exercises.len()); let mut file_buf = String::with_capacity(1 << 14); for exercise_info in &info_file.exercises { @@ -282,7 +282,7 @@ fn check_solutions( .collect::, _>>() .context("Failed to spawn a thread to check a solution")?; - let mut sol_paths = hash_set_with_capacity(info_file.exercises.len()); + let mut sol_paths = HashSet::with_capacity(info_file.exercises.len()); let mut fmt_cmd = Command::new("rustfmt"); fmt_cmd .arg("--check") diff --git a/src/main.rs b/src/main.rs index c8bcd2e5..eeb1883e 100644 --- a/src/main.rs +++ b/src/main.rs @@ -13,7 +13,6 @@ use self::{app_state::AppState, dev::DevCommands, info_file::InfoFile}; mod app_state; mod cargo_toml; mod cmd; -mod collections; mod dev; mod embedded; mod exercise; From 930a0ea73b74921d687f3389f8dfb99f8fda8cea Mon Sep 17 00:00:00 2001 From: mo8it Date: Thu, 17 Oct 2024 16:00:10 +0200 Subject: [PATCH 006/120] list: Highlight search match in exercise names --- src/list/state.rs | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/src/list/state.rs b/src/list/state.rs index 5bdbca77..53fe07c4 100644 --- a/src/list/state.rs +++ b/src/list/state.rs @@ -105,6 +105,28 @@ impl<'a> ListState<'a> { ); } + fn draw_exericse_name(&self, writer: &mut MaxLenWriter, exercise: &Exercise) -> io::Result<()> { + if !self.search_query.is_empty() { + if let Some((pre_highlight, highlight, post_highlight)) = exercise + .name + .find(&self.search_query) + .and_then(|ind| exercise.name.split_at_checked(ind)) + .and_then(|(pre_highlight, rest)| { + rest.split_at_checked(self.search_query.len()) + .map(|x| (pre_highlight, x.0, x.1)) + }) + { + writer.write_str(pre_highlight)?; + writer.stdout.queue(SetForegroundColor(Color::Magenta))?; + writer.write_str(highlight)?; + writer.stdout.queue(ResetColor)?; + return writer.write_str(post_highlight); + } + } + + writer.write_str(exercise.name) + } + fn draw_rows( &self, stdout: &mut StdoutLock, @@ -147,10 +169,10 @@ impl<'a> ListState<'a> { writer.stdout.queue(SetForegroundColor(Color::Yellow))?; writer.write_ascii(b"PENDING ")?; } - writer.stdout.queue(SetForegroundColor(Color::Reset))?; - writer.write_str(exercise.name)?; + self.draw_exericse_name(&mut writer, exercise)?; + writer.write_ascii(&self.name_col_padding[exercise.name.len()..])?; // The list links aren't shown correctly in VS Code on Windows. From 6bec6f92c4f0fe14ed56ad646514e89f6d0ee7cc Mon Sep 17 00:00:00 2001 From: Vincent Ging Ho Yim Date: Tue, 22 Oct 2024 16:49:44 +1100 Subject: [PATCH 007/120] threads1: Fix typos in description --- exercises/20_threads/threads1.rs | 4 ++-- solutions/20_threads/threads1.rs | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/exercises/20_threads/threads1.rs b/exercises/20_threads/threads1.rs index 01f9ff44..dbc64b16 100644 --- a/exercises/20_threads/threads1.rs +++ b/exercises/20_threads/threads1.rs @@ -1,5 +1,5 @@ -// This program spawns multiple threads that each run for at least 250ms, and -// each thread returns how much time they took to complete. The program should +// This program spawns multiple threads that each runs for at least 250ms, and +// each thread returns how much time it took to complete. The program should // wait until all the spawned threads have finished and should collect their // return values into a vector. diff --git a/solutions/20_threads/threads1.rs b/solutions/20_threads/threads1.rs index 7f3dd29a..1fc5bc9c 100644 --- a/solutions/20_threads/threads1.rs +++ b/solutions/20_threads/threads1.rs @@ -1,5 +1,5 @@ -// This program spawns multiple threads that each run for at least 250ms, and -// each thread returns how much time they took to complete. The program should +// This program spawns multiple threads that each runs for at least 250ms, and +// each thread returns how much time it took to complete. The program should // wait until all the spawned threads have finished and should collect their // return values into a vector. From e8c2a79516192761283f41acc68744e91a34d6b4 Mon Sep 17 00:00:00 2001 From: mo8it Date: Sat, 26 Oct 2024 16:53:07 +0200 Subject: [PATCH 008/120] Deduplicate code for printing keys --- src/watch/state.rs | 38 ++++++++++++-------------------------- 1 file changed, 12 insertions(+), 26 deletions(-) diff --git a/src/watch/state.rs b/src/watch/state.rs index 0ac758ce..47978aba 100644 --- a/src/watch/state.rs +++ b/src/watch/state.rs @@ -177,39 +177,25 @@ impl<'a> WatchState<'a> { stdout.write_all(b" / ")?; } - if self.manual_run { + let mut show_key = |key, postfix| { stdout.queue(SetAttribute(Attribute::Bold))?; - stdout.write_all(b"r")?; + stdout.write_all(&[key])?; stdout.queue(ResetColor)?; - stdout.write_all(b":run / ")?; + stdout.write_all(postfix) + }; + + if self.manual_run { + show_key(b'r', b":run / ")?; } if !self.show_hint { - stdout.queue(SetAttribute(Attribute::Bold))?; - stdout.write_all(b"h")?; - stdout.queue(ResetColor)?; - stdout.write_all(b":hint / ")?; + show_key(b'h', b":hint / ")?; } - stdout.queue(SetAttribute(Attribute::Bold))?; - stdout.write_all(b"l")?; - stdout.queue(ResetColor)?; - stdout.write_all(b":list / ")?; - - stdout.queue(SetAttribute(Attribute::Bold))?; - stdout.write_all(b"c")?; - stdout.queue(ResetColor)?; - stdout.write_all(b":check all / ")?; - - stdout.queue(SetAttribute(Attribute::Bold))?; - stdout.write_all(b"x")?; - stdout.queue(ResetColor)?; - stdout.write_all(b":reset / ")?; - - stdout.queue(SetAttribute(Attribute::Bold))?; - stdout.write_all(b"q")?; - stdout.queue(ResetColor)?; - stdout.write_all(b":quit ? ")?; + show_key(b'l', b":list / ")?; + show_key(b'c', b":check all / ")?; + show_key(b'x', b":reset / ")?; + show_key(b'q', b":quit ? ")?; stdout.flush() } From 449858655d5302efda18288a3d0f138b6e83c463 Mon Sep 17 00:00:00 2001 From: mo8it Date: Sat, 26 Oct 2024 16:54:54 +0200 Subject: [PATCH 009/120] Update deps --- Cargo.lock | 56 +++++++++++++++++++++++++++--------------------------- Cargo.toml | 6 +++--- 2 files changed, 31 insertions(+), 31 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 1ac56b40..a44f2717 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4,9 +4,9 @@ version = 3 [[package]] name = "anstream" -version = "0.6.15" +version = "0.6.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "64e15c1ab1f89faffbf04a634d5e1962e9074f2741eef6d97f3c4e322426d526" +checksum = "23a1e53f0f5d86382dafe1cf314783b2044280f406e7e1506368220ad11b1338" dependencies = [ "anstyle", "anstyle-parse", @@ -19,43 +19,43 @@ dependencies = [ [[package]] name = "anstyle" -version = "1.0.8" +version = "1.0.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1bec1de6f59aedf83baf9ff929c98f2ad654b97c9510f4e70cf6f661d49fd5b1" +checksum = "8365de52b16c035ff4fcafe0092ba9390540e3e352870ac09933bebcaa2c8c56" [[package]] name = "anstyle-parse" -version = "0.2.5" +version = "0.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eb47de1e80c2b463c735db5b217a0ddc39d612e7ac9e2e96a5aed1f57616c1cb" +checksum = "3b2d16507662817a6a20a9ea92df6652ee4f94f914589377d69f3b21bc5798a9" dependencies = [ "utf8parse", ] [[package]] name = "anstyle-query" -version = "1.1.1" +version = "1.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6d36fc52c7f6c869915e99412912f22093507da8d9e942ceaf66fe4b7c14422a" +checksum = "79947af37f4177cfead1110013d678905c37501914fba0efea834c3fe9a8d60c" dependencies = [ - "windows-sys 0.52.0", + "windows-sys 0.59.0", ] [[package]] name = "anstyle-wincon" -version = "3.0.4" +version = "3.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5bf74e1b6e971609db8ca7a9ce79fd5768ab6ae46441c572e46cf596f59e57f8" +checksum = "2109dbce0e72be3ec00bed26e6a7479ca384ad226efdd66db8fa2e3a38c83125" dependencies = [ "anstyle", - "windows-sys 0.52.0", + "windows-sys 0.59.0", ] [[package]] name = "anyhow" -version = "1.0.89" +version = "1.0.91" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "86fdf8605db99b54d3cd748a44c6d04df638eb5dafb219b135d0149bd0db01f6" +checksum = "c042108f3ed77fd83760a5fd79b53be043192bb3b9dba91d8c574c0ada7850c8" [[package]] name = "autocfg" @@ -123,9 +123,9 @@ checksum = "1462739cb27611015575c0c11df5df7601141071f07518d56fcc1be504cbec97" [[package]] name = "colorchoice" -version = "1.0.2" +version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d3fd119d74b830634cea2a0f58bbd0d54540518a14397557951e79340abc28c0" +checksum = "5b63caa9aa9397e2d9480a9b13673856c78d8ac123288526c37d7839f2a86990" [[package]] name = "crossterm" @@ -277,9 +277,9 @@ dependencies = [ [[package]] name = "libc" -version = "0.2.160" +version = "0.2.161" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0b21006cd1874ae9e650973c565615676dc4a274c965bb0a73796dac838ce4f" +checksum = "8e9489c2807c139ffd9c1794f4af0ebe86a828db53ecdc7fea2111d0fed085d1" [[package]] name = "libredox" @@ -404,9 +404,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.88" +version = "1.0.89" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7c3a7fc5db1e57d5a779a352c8cdb57b29aa4c40cc69c3a68a7fedc815fbf2f9" +checksum = "f139b0662de085916d1fb67d2b4169d1addddda1919e696f3252b740b629986e" dependencies = [ "unicode-ident", ] @@ -491,18 +491,18 @@ checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" [[package]] name = "serde" -version = "1.0.210" +version = "1.0.213" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c8e3592472072e6e22e0a54d5904d9febf8508f65fb8552499a1abc7d1078c3a" +checksum = "3ea7893ff5e2466df8d720bb615088341b295f849602c6956047f8f80f0e9bc1" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.210" +version = "1.0.213" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "243902eda00fad750862fc144cea25caca5e20d615af0a81bee94ca738f1df1f" +checksum = "7e85ad2009c50b58e87caa8cd6dac16bdf511bbfb7af6c33df902396aa480fa5" dependencies = [ "proc-macro2", "quote", @@ -511,9 +511,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.128" +version = "1.0.132" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ff5456707a1de34e7e37f2a6fd3d3f808c318259cbd01ab6377795054b483d8" +checksum = "d726bfaff4b320266d395898905d0eba0345aae23b54aee3a737e260fd46db03" dependencies = [ "itoa", "memchr", @@ -574,9 +574,9 @@ checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" [[package]] name = "syn" -version = "2.0.79" +version = "2.0.85" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "89132cd0bf050864e1d38dc3bbc07a0eb8e7530af26344d3d2bbbef83499f590" +checksum = "5023162dfcd14ef8f32034d8bcd4cc5ddc61ef7a247c024a33e24e1f24d21b56" dependencies = [ "proc-macro2", "quote", diff --git a/Cargo.toml b/Cargo.toml index 4dbcb5fb..f05e5250 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -19,7 +19,7 @@ edition = "2021" # On Update: Update the edition of the `rustfmt` command that c rust-version = "1.80" [workspace.dependencies] -serde = { version = "1.0.210", features = ["derive"] } +serde = { version = "1.0.213", features = ["derive"] } toml_edit = { version = "0.22.22", default-features = false, features = ["parse", "serde"] } [package] @@ -46,13 +46,13 @@ include = [ ] [dependencies] -anyhow = "1.0.89" +anyhow = "1.0.91" clap = { version = "4.5.20", features = ["derive"] } crossterm = { version = "0.28.1", default-features = false, features = ["windows", "events"] } notify = { version = "6.1.1", default-features = false, features = ["macos_fsevent"] } os_pipe = "1.2.1" rustlings-macros = { path = "rustlings-macros", version = "=6.3.0" } -serde_json = "1.0.128" +serde_json = "1.0.132" serde.workspace = true toml_edit.workspace = true From 2a725fb13719de0597a34c633cb59da7c7244534 Mon Sep 17 00:00:00 2001 From: mo8it Date: Tue, 29 Oct 2024 14:25:44 +0100 Subject: [PATCH 010/120] Upgrade notify --- Cargo.lock | 145 ++++++++++++++++------------------------------------- Cargo.toml | 6 +-- 2 files changed, 46 insertions(+), 105 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index a44f2717..beb01df3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -135,7 +135,7 @@ checksum = "829d955a0bb380ef178a640b91779e3987da38c9aea133b20614cfed8cdea9c6" dependencies = [ "bitflags 2.6.0", "crossterm_winapi", - "mio 1.0.2", + "mio", "parking_lot", "rustix", "signal-hook", @@ -225,9 +225,9 @@ dependencies = [ [[package]] name = "inotify" -version = "0.9.6" +version = "0.10.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f8069d3ec154eb856955c1c0fbffefbf5f3c40a104ec912d4797314c1801abff" +checksum = "fdd168d97690d0b8c412d6b6c10360277f4d7ee495c5d0d5d5fe0854923255cc" dependencies = [ "bitflags 1.3.2", "inotify-sys", @@ -243,6 +243,15 @@ dependencies = [ "libc", ] +[[package]] +name = "instant" +version = "0.1.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e0242819d153cba4b4b05a5a8f2a7e9bbf97b6055b2a002b395c96b5ff3c0222" +dependencies = [ + "cfg-if", +] + [[package]] name = "is_terminal_polyfill" version = "1.70.1" @@ -320,18 +329,6 @@ version = "2.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" -[[package]] -name = "mio" -version = "0.8.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4a650543ca06a924e8b371db273b2756685faae30f8487da1b56505a8f78b0c" -dependencies = [ - "libc", - "log", - "wasi", - "windows-sys 0.48.0", -] - [[package]] name = "mio" version = "1.0.2" @@ -347,9 +344,9 @@ dependencies = [ [[package]] name = "notify" -version = "6.1.1" +version = "7.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6205bd8bb1e454ad2e27422015fb5e4f2bcc7e08fa8f27058670d208324a4d2d" +checksum = "c533b4c39709f9ba5005d8002048266593c1cfaf3c5f0739d5b8ab0c6c504009" dependencies = [ "bitflags 2.6.0", "filetime", @@ -358,9 +355,19 @@ dependencies = [ "kqueue", "libc", "log", - "mio 0.8.11", + "mio", + "notify-types", "walkdir", - "windows-sys 0.48.0", + "windows-sys 0.52.0", +] + +[[package]] +name = "notify-types" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7393c226621f817964ffb3dc5704f9509e107a8b024b489cc2c1b217378785df" +dependencies = [ + "instant", ] [[package]] @@ -399,7 +406,7 @@ dependencies = [ "libc", "redox_syscall", "smallvec", - "windows-targets 0.52.6", + "windows-targets", ] [[package]] @@ -431,9 +438,9 @@ dependencies = [ [[package]] name = "rustix" -version = "0.38.37" +version = "0.38.38" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8acb788b847c24f28525660c4d7758620a7210875711f79e7f663cc152726811" +checksum = "aa260229e6538e52293eeb577aabd09945a09d6d9cc0fc550ed7529056c2e32a" dependencies = [ "bitflags 2.6.0", "errno", @@ -491,18 +498,18 @@ checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" [[package]] name = "serde" -version = "1.0.213" +version = "1.0.214" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3ea7893ff5e2466df8d720bb615088341b295f849602c6956047f8f80f0e9bc1" +checksum = "f55c3193aca71c12ad7890f1785d2b73e1b9f63a0bbc353c08ef26fe03fc56b5" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.213" +version = "1.0.214" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7e85ad2009c50b58e87caa8cd6dac16bdf511bbfb7af6c33df902396aa480fa5" +checksum = "de523f781f095e28fa605cdce0f8307e451cc0fd14e2eb4cd2e98a355b147766" dependencies = [ "proc-macro2", "quote", @@ -547,7 +554,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "34db1a06d485c9142248b7a054f034b349b212551f3dfd19c94d45a754a217cd" dependencies = [ "libc", - "mio 1.0.2", + "mio", "signal-hook", ] @@ -677,22 +684,13 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" -[[package]] -name = "windows-sys" -version = "0.48.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" -dependencies = [ - "windows-targets 0.48.5", -] - [[package]] name = "windows-sys" version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" dependencies = [ - "windows-targets 0.52.6", + "windows-targets", ] [[package]] @@ -701,22 +699,7 @@ version = "0.59.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b" dependencies = [ - "windows-targets 0.52.6", -] - -[[package]] -name = "windows-targets" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c" -dependencies = [ - "windows_aarch64_gnullvm 0.48.5", - "windows_aarch64_msvc 0.48.5", - "windows_i686_gnu 0.48.5", - "windows_i686_msvc 0.48.5", - "windows_x86_64_gnu 0.48.5", - "windows_x86_64_gnullvm 0.48.5", - "windows_x86_64_msvc 0.48.5", + "windows-targets", ] [[package]] @@ -725,46 +708,28 @@ version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" dependencies = [ - "windows_aarch64_gnullvm 0.52.6", - "windows_aarch64_msvc 0.52.6", - "windows_i686_gnu 0.52.6", + "windows_aarch64_gnullvm", + "windows_aarch64_msvc", + "windows_i686_gnu", "windows_i686_gnullvm", - "windows_i686_msvc 0.52.6", - "windows_x86_64_gnu 0.52.6", - "windows_x86_64_gnullvm 0.52.6", - "windows_x86_64_msvc 0.52.6", + "windows_i686_msvc", + "windows_x86_64_gnu", + "windows_x86_64_gnullvm", + "windows_x86_64_msvc", ] -[[package]] -name = "windows_aarch64_gnullvm" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" - [[package]] name = "windows_aarch64_gnullvm" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" -[[package]] -name = "windows_aarch64_msvc" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" - [[package]] name = "windows_aarch64_msvc" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" -[[package]] -name = "windows_i686_gnu" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" - [[package]] name = "windows_i686_gnu" version = "0.52.6" @@ -777,48 +742,24 @@ version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" -[[package]] -name = "windows_i686_msvc" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" - [[package]] name = "windows_i686_msvc" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" -[[package]] -name = "windows_x86_64_gnu" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" - [[package]] name = "windows_x86_64_gnu" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" -[[package]] -name = "windows_x86_64_gnullvm" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" - [[package]] name = "windows_x86_64_gnullvm" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" -[[package]] -name = "windows_x86_64_msvc" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" - [[package]] name = "windows_x86_64_msvc" version = "0.52.6" diff --git a/Cargo.toml b/Cargo.toml index f05e5250..e9fe0790 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -19,7 +19,7 @@ edition = "2021" # On Update: Update the edition of the `rustfmt` command that c rust-version = "1.80" [workspace.dependencies] -serde = { version = "1.0.213", features = ["derive"] } +serde = { version = "1.0.214", features = ["derive"] } toml_edit = { version = "0.22.22", default-features = false, features = ["parse", "serde"] } [package] @@ -49,7 +49,7 @@ include = [ anyhow = "1.0.91" clap = { version = "4.5.20", features = ["derive"] } crossterm = { version = "0.28.1", default-features = false, features = ["windows", "events"] } -notify = { version = "6.1.1", default-features = false, features = ["macos_fsevent"] } +notify = "7.0.0" os_pipe = "1.2.1" rustlings-macros = { path = "rustlings-macros", version = "=6.3.0" } serde_json = "1.0.132" @@ -57,7 +57,7 @@ serde.workspace = true toml_edit.workspace = true [target.'cfg(not(windows))'.dependencies] -rustix = { version = "0.38.37", default-features = false, features = ["std", "stdio", "termios"] } +rustix = { version = "0.38.38", default-features = false, features = ["std", "stdio", "termios"] } [dev-dependencies] tempfile = "3.13.0" From 46ad25f9257836d4d1303874f0a618b6c319b263 Mon Sep 17 00:00:00 2001 From: mo8it Date: Mon, 11 Nov 2024 14:34:33 +0100 Subject: [PATCH 011/120] Fix contrast in terminals with a light theme --- src/list/state.rs | 43 ++++++++++++++++++++++++++++--------------- src/watch/state.rs | 8 +++++--- 2 files changed, 33 insertions(+), 18 deletions(-) diff --git a/src/list/state.rs b/src/list/state.rs index 53fe07c4..76392d1c 100644 --- a/src/list/state.rs +++ b/src/list/state.rs @@ -1,7 +1,9 @@ use anyhow::{Context, Result}; use crossterm::{ cursor::{MoveTo, MoveToNextLine}, - style::{Attribute, Color, ResetColor, SetAttribute, SetBackgroundColor, SetForegroundColor}, + style::{ + Attribute, Attributes, Color, ResetColor, SetAttribute, SetAttributes, SetForegroundColor, + }, terminal::{self, BeginSynchronizedUpdate, Clear, ClearType, EndSynchronizedUpdate}, QueueableCommand, }; @@ -19,6 +21,9 @@ use crate::{ use super::scroll_state::ScrollState; const COL_SPACING: usize = 2; +const SELECTED_ROW_ATTRIBUTES: Attributes = Attributes::none() + .with(Attribute::Reverse) + .with(Attribute::Bold); fn next_ln(stdout: &mut StdoutLock) -> io::Result<()> { stdout @@ -41,6 +46,7 @@ pub struct ListState<'a> { app_state: &'a mut AppState, scroll_state: ScrollState, name_col_padding: Vec, + path_col_padding: Vec, filter: Filter, term_width: u16, term_height: u16, @@ -52,13 +58,18 @@ impl<'a> ListState<'a> { stdout.queue(Clear(ClearType::All))?; let name_col_title_len = 4; - let name_col_width = app_state - .exercises() - .iter() - .map(|exercise| exercise.name.len()) - .max() - .map_or(name_col_title_len, |max| max.max(name_col_title_len)); + let path_col_title_len = 4; + let (name_col_width, path_col_width) = app_state.exercises().iter().fold( + (name_col_title_len, path_col_title_len), + |(name_col_width, path_col_width), exercise| { + ( + name_col_width.max(exercise.name.len()), + path_col_width.max(exercise.path.len()), + ) + }, + ); let name_col_padding = vec![b' '; name_col_width + COL_SPACING]; + let path_col_padding = vec![b' '; path_col_width]; let filter = Filter::None; let n_rows_with_filter = app_state.exercises().len(); @@ -73,6 +84,7 @@ impl<'a> ListState<'a> { app_state, scroll_state, name_col_padding, + path_col_padding, filter, // Set by `set_term_size` term_width: 0, @@ -119,7 +131,7 @@ impl<'a> ListState<'a> { writer.write_str(pre_highlight)?; writer.stdout.queue(SetForegroundColor(Color::Magenta))?; writer.write_str(highlight)?; - writer.stdout.queue(ResetColor)?; + writer.stdout.queue(SetForegroundColor(Color::Reset))?; return writer.write_str(post_highlight); } } @@ -143,14 +155,12 @@ impl<'a> ListState<'a> { let mut writer = MaxLenWriter::new(stdout, self.term_width as usize); if self.scroll_state.selected() == Some(row_offset + n_displayed_rows) { - writer.stdout.queue(SetBackgroundColor(Color::Rgb { - r: 40, - g: 40, - b: 40, - }))?; // The crab emoji has the width of two ascii chars. writer.add_to_len(2); writer.stdout.write_all("🦀".as_bytes())?; + writer + .stdout + .queue(SetAttributes(SELECTED_ROW_ATTRIBUTES))?; } else { writer.write_ascii(b" ")?; } @@ -164,12 +174,13 @@ impl<'a> ListState<'a> { if exercise.done { writer.stdout.queue(SetForegroundColor(Color::Green))?; - writer.write_ascii(b"DONE ")?; + writer.write_ascii(b"DONE ")?; } else { writer.stdout.queue(SetForegroundColor(Color::Yellow))?; - writer.write_ascii(b"PENDING ")?; + writer.write_ascii(b"PENDING")?; } writer.stdout.queue(SetForegroundColor(Color::Reset))?; + writer.write_ascii(b" ")?; self.draw_exericse_name(&mut writer, exercise)?; @@ -183,6 +194,8 @@ impl<'a> ListState<'a> { exercise.terminal_file_link(&mut writer)?; } + writer.write_ascii(&self.path_col_padding[exercise.path.len()..])?; + next_ln(stdout)?; stdout.queue(ResetColor)?; n_displayed_rows += 1; diff --git a/src/watch/state.rs b/src/watch/state.rs index 47978aba..c27dedf3 100644 --- a/src/watch/state.rs +++ b/src/watch/state.rs @@ -20,6 +20,10 @@ use crate::{ use super::{terminal_event::terminal_event_handler, InputPauseGuard, WatchEvent}; +const HEADING_ATTRIBUTES: Attributes = Attributes::none() + .with(Attribute::Bold) + .with(Attribute::Underlined); + #[derive(PartialEq, Eq)] enum DoneStatus { DoneWithSolution(String), @@ -209,9 +213,7 @@ impl<'a> WatchState<'a> { if self.show_hint { stdout - .queue(SetAttributes( - Attributes::from(Attribute::Bold).with(Attribute::Underlined), - ))? + .queue(SetAttributes(HEADING_ATTRIBUTES))? .queue(SetForegroundColor(Color::Cyan))?; stdout.write_all(b"Hint")?; stdout.queue(ResetColor)?; From 9bc7bbe4b43d26d3646f249eda11562f90e54cee Mon Sep 17 00:00:00 2001 From: mo8it Date: Mon, 11 Nov 2024 14:35:22 +0100 Subject: [PATCH 012/120] Update deps --- Cargo.lock | 36 ++++++++++++++++++------------------ Cargo.toml | 4 ++-- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index beb01df3..23c416ff 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4,9 +4,9 @@ version = 3 [[package]] name = "anstream" -version = "0.6.17" +version = "0.6.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23a1e53f0f5d86382dafe1cf314783b2044280f406e7e1506368220ad11b1338" +checksum = "8acc5369981196006228e28809f761875c0327210a891e941f4c683b3a99529b" dependencies = [ "anstyle", "anstyle-parse", @@ -19,9 +19,9 @@ dependencies = [ [[package]] name = "anstyle" -version = "1.0.9" +version = "1.0.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8365de52b16c035ff4fcafe0092ba9390540e3e352870ac09933bebcaa2c8c56" +checksum = "55cc3b69f167a1ef2e161439aa98aed94e6028e5f9a59be9a6ffb47aef1651f9" [[package]] name = "anstyle-parse" @@ -53,9 +53,9 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.91" +version = "1.0.93" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c042108f3ed77fd83760a5fd79b53be043192bb3b9dba91d8c574c0ada7850c8" +checksum = "4c95c10ba0b00a02636238b814946408b1322d5ac4760326e6fb8ec956d85775" [[package]] name = "autocfg" @@ -170,9 +170,9 @@ dependencies = [ [[package]] name = "fastrand" -version = "2.1.1" +version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e8c02a5121d4ea3eb16a80748c74f5549a5665e4c21333c6098f283870fbdea6" +checksum = "486f806e73c5707928240ddc295403b1b93c96a02038563881c4a2fd84b81ac4" [[package]] name = "filetime" @@ -197,9 +197,9 @@ dependencies = [ [[package]] name = "hashbrown" -version = "0.15.0" +version = "0.15.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e087f84d4f86bf4b218b927129862374b72199ae7d8657835f1e89000eea4fb" +checksum = "3a9bfc1af68b1726ea47d3d5109de126281def866b33970e10fbab11b5dafab3" [[package]] name = "heck" @@ -286,9 +286,9 @@ dependencies = [ [[package]] name = "libc" -version = "0.2.161" +version = "0.2.162" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e9489c2807c139ffd9c1794f4af0ebe86a828db53ecdc7fea2111d0fed085d1" +checksum = "18d287de67fe55fd7e1581fe933d965a5a9477b38e949cfa9f8574ef01506398" [[package]] name = "libredox" @@ -438,9 +438,9 @@ dependencies = [ [[package]] name = "rustix" -version = "0.38.38" +version = "0.38.40" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aa260229e6538e52293eeb577aabd09945a09d6d9cc0fc550ed7529056c2e32a" +checksum = "99e4ea3e1cdc4b559b8e5650f9c8e5998e3e5c1343b4eaf034565f32318d63c0" dependencies = [ "bitflags 2.6.0", "errno", @@ -581,9 +581,9 @@ checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" [[package]] name = "syn" -version = "2.0.85" +version = "2.0.87" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5023162dfcd14ef8f32034d8bcd4cc5ddc61ef7a247c024a33e24e1f24d21b56" +checksum = "25aa4ce346d03a6dcd68dd8b4010bcb74e54e62c90c573f394c46eae99aba32d" dependencies = [ "proc-macro2", "quote", @@ -592,9 +592,9 @@ dependencies = [ [[package]] name = "tempfile" -version = "3.13.0" +version = "3.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0f2c9fc62d0beef6951ccffd757e241266a2c833136efbe35af6cd2567dca5b" +checksum = "28cce251fcbc87fac86a866eeb0d6c2d536fc16d06f184bb61aeae11aa4cee0c" dependencies = [ "cfg-if", "fastrand", diff --git a/Cargo.toml b/Cargo.toml index e9fe0790..5be6d706 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -46,7 +46,7 @@ include = [ ] [dependencies] -anyhow = "1.0.91" +anyhow = "1.0.93" clap = { version = "4.5.20", features = ["derive"] } crossterm = { version = "0.28.1", default-features = false, features = ["windows", "events"] } notify = "7.0.0" @@ -60,7 +60,7 @@ toml_edit.workspace = true rustix = { version = "0.38.38", default-features = false, features = ["std", "stdio", "termios"] } [dev-dependencies] -tempfile = "3.13.0" +tempfile = "3.14.0" [profile.release] panic = "abort" From f49164e69b3be368b51aa71e2f2d40f5a7c6a319 Mon Sep 17 00:00:00 2001 From: mo8it Date: Mon, 11 Nov 2024 14:43:38 +0100 Subject: [PATCH 013/120] Fix typo --- src/list/state.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/list/state.rs b/src/list/state.rs index 76392d1c..0670fa46 100644 --- a/src/list/state.rs +++ b/src/list/state.rs @@ -117,7 +117,7 @@ impl<'a> ListState<'a> { ); } - fn draw_exericse_name(&self, writer: &mut MaxLenWriter, exercise: &Exercise) -> io::Result<()> { + fn draw_exercise_name(&self, writer: &mut MaxLenWriter, exercise: &Exercise) -> io::Result<()> { if !self.search_query.is_empty() { if let Some((pre_highlight, highlight, post_highlight)) = exercise .name @@ -182,7 +182,7 @@ impl<'a> ListState<'a> { writer.stdout.queue(SetForegroundColor(Color::Reset))?; writer.write_ascii(b" ")?; - self.draw_exericse_name(&mut writer, exercise)?; + self.draw_exercise_name(&mut writer, exercise)?; writer.write_ascii(&self.name_col_padding[exercise.name.len()..])?; From fd33c29b262e249de720dc8b04e878cd92a83d13 Mon Sep 17 00:00:00 2001 From: mo8it Date: Mon, 11 Nov 2024 14:43:51 +0100 Subject: [PATCH 014/120] Test with MSRV before release --- release-hook.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/release-hook.sh b/release-hook.sh index d5954ca8..8da5636d 100755 --- a/release-hook.sh +++ b/release-hook.sh @@ -11,3 +11,6 @@ cargo clippy -- --deny warnings cargo fmt --all --check cargo test --workspace --all-targets cargo run -- dev check --require-solutions + +# MSRV +cargo +1.80 run -- dev check --require-solutions From eff2ce8a23bcd8f979dff917bcdb83dccbaa4170 Mon Sep 17 00:00:00 2001 From: mo8it Date: Mon, 11 Nov 2024 14:55:58 +0100 Subject: [PATCH 015/120] Ignore input while checking all exercises in watch mode --- src/watch/state.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/watch/state.rs b/src/watch/state.rs index c27dedf3..5263bc57 100644 --- a/src/watch/state.rs +++ b/src/watch/state.rs @@ -269,6 +269,9 @@ impl<'a> WatchState<'a> { } pub fn check_all_exercises(&mut self, stdout: &mut StdoutLock) -> Result { + // Ignore any input until checking all exercises is done. + let _input_pause_guard = InputPauseGuard::scoped_pause(); + if let Some(first_pending_exercise_ind) = self.app_state.check_all_exercises(stdout)? { // Only change exercise if the current one is done. if self.app_state.current_exercise().done { From 243cf5f2610c64183331d77e3d8c803c551dabeb Mon Sep 17 00:00:00 2001 From: mo8it Date: Mon, 11 Nov 2024 15:49:24 +0100 Subject: [PATCH 016/120] Update CHANGELOG --- CHANGELOG.md | 35 +++++++++++++++++++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 19bb8fc3..a2085b91 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,34 @@ + + +## 6.4.0 (2024-11-11) + +### Added + +- The list of exercises is now searchable by pressing `s` or `/` 🔍️ (thanks to [@frroossst](https://github.com/frroossst)) +- New option `c` in the prompt to manually check all exercises ✅ (thanks to [@Nahor](https://github.com/Nahor)) +- New command `check-all` to manually check all exercises ✅ (thanks to [@Nahor](https://github.com/Nahor)) +- Addictive animation for showing the progress of checking all exercises. A nice showcase of parallelism in Rust ✨ +- New option `x` in the prompt to reset the file of the current exercise 🔄 +- Allow `dead_code` for all exercises and solutions ⚰️ (thanks to [@huss4in](https://github.com/huss4in)) +- Pause input while running an exercise to avoid unexpected prompt interactions ⏸️ +- Limit the maximum number of exercises to 999. Any third-party exercises willing to reach that limit? 🔝 + +### Changed + +- `enums3`: Remove redundant enum definition task (thanks to [@senekor](https://github.com/senekor)) +- `if2`: Make the exercise less confusing by avoiding "fizz", "fuzz", "foo", "bar" and "baz" (thanks to [@senekor](https://github.com/senekor)) +- `hashmap3`: Use the method `Entry::or_default`. +- Update the state of all exercises when checking all of them (thanks to [@Nahor](https://github.com/Nahor)) +- The main prompt doesn't need a confirmation with ENTER on Unix-like systems anymore. +- No more jumping back to a previous exercise when its file is changed. Use the list to jump between exercises. +- Dump the solution file after an exercise is done even if the solution's directory doesn't exist. +- Rework the footer in the list. +- Optimize the file watcher. + +### Fixed + +- Fix bad contrast in the list on terminals with a light theme. + ## 6.3.0 (2024-08-29) @@ -113,7 +144,7 @@ You can read about the motivations of this change in [this issue](https://github ### List mode -A list mode was added using [Ratatui](https://ratatui.rs). +A new list mode was added! You can enter it by entering `l` in the watch mode. It offers the following features: @@ -814,7 +845,7 @@ Then follow the link to the guide about [third-party exercises](THIRD_PARTY_EXER #### Bug Fixes -- Update deps to version compatable with aarch64-pc-windows (#263) ([19a93428](https://github.com/rust-lang/rustlings/commit/19a93428b3c73d994292671f829bdc8e5b7b3401)) +- Update deps to version compatible with aarch64-pc-windows (#263) ([19a93428](https://github.com/rust-lang/rustlings/commit/19a93428b3c73d994292671f829bdc8e5b7b3401)) - **docs:** - Added a necessary step to Windows installation process (#242) ([3906efcd](https://github.com/rust-lang/rustlings/commit/3906efcd52a004047b460ed548037093de3f523f)) - Fixed mangled sentence from book; edited for clarity (#266) ([ade52ff](https://github.com/rust-lang/rustlings/commit/ade52ffb739987287ddd5705944c8777705faed9)) From 410eb69d250a2c856e9d23b60a4e77e5558b8134 Mon Sep 17 00:00:00 2001 From: mo8it Date: Mon, 11 Nov 2024 15:49:50 +0100 Subject: [PATCH 017/120] Remove "chore: " from the commit message of releases --- Cargo.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/Cargo.toml b/Cargo.toml index 5be6d706..2397ad3d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -70,6 +70,7 @@ panic = "abort" [package.metadata.release] pre-release-hook = ["./release-hook.sh"] +pre-release-commit-message = "Release 🎉" [workspace.lints.rust] unsafe_code = "forbid" From e6cb1042946816a6ac835cf1f15a71898bdf4ed6 Mon Sep 17 00:00:00 2001 From: mo8it Date: Mon, 11 Nov 2024 15:51:27 +0100 Subject: [PATCH 018/120] chore: Release --- Cargo.lock | 4 ++-- Cargo.toml | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 23c416ff..a61cf39a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -451,7 +451,7 @@ dependencies = [ [[package]] name = "rustlings" -version = "6.3.0" +version = "6.4.0" dependencies = [ "anyhow", "clap", @@ -468,7 +468,7 @@ dependencies = [ [[package]] name = "rustlings-macros" -version = "6.3.0" +version = "6.4.0" dependencies = [ "quote", "serde", diff --git a/Cargo.toml b/Cargo.toml index 2397ad3d..ff88de2d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -6,7 +6,7 @@ exclude = [ ] [workspace.package] -version = "6.3.0" +version = "6.4.0" authors = [ "Mo Bitar ", # https://github.com/mo8it "Liv ", # https://github.com/shadows-withal @@ -51,7 +51,7 @@ clap = { version = "4.5.20", features = ["derive"] } crossterm = { version = "0.28.1", default-features = false, features = ["windows", "events"] } notify = "7.0.0" os_pipe = "1.2.1" -rustlings-macros = { path = "rustlings-macros", version = "=6.3.0" } +rustlings-macros = { path = "rustlings-macros", version = "=6.4.0" } serde_json = "1.0.132" serde.workspace = true toml_edit.workspace = true From 38016cb2d6053c7d4f18c7ca98880a3ac7d392fa Mon Sep 17 00:00:00 2001 From: mo8it Date: Wed, 13 Nov 2024 16:06:41 +0100 Subject: [PATCH 019/120] clippy3: Make the intent more clear --- exercises/22_clippy/clippy3.rs | 6 ++++-- solutions/22_clippy/clippy3.rs | 4 ++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/exercises/22_clippy/clippy3.rs b/exercises/22_clippy/clippy3.rs index 4f788349..7a3cb390 100644 --- a/exercises/22_clippy/clippy3.rs +++ b/exercises/22_clippy/clippy3.rs @@ -4,9 +4,11 @@ #[rustfmt::skip] #[allow(unused_variables, unused_assignments)] fn main() { - let my_option: Option<()> = None; + let my_option: Option<&str> = None; + // Assume that you don't know the value of `my_option`. + // In the case of `Some`, we want to print its value. if my_option.is_none() { - println!("{:?}", my_option.unwrap()); + println!("{}", my_option.unwrap()); } let my_arr = &[ diff --git a/solutions/22_clippy/clippy3.rs b/solutions/22_clippy/clippy3.rs index 811d1847..b7eaa570 100644 --- a/solutions/22_clippy/clippy3.rs +++ b/solutions/22_clippy/clippy3.rs @@ -3,11 +3,11 @@ use std::mem; #[rustfmt::skip] #[allow(unused_variables, unused_assignments)] fn main() { - let my_option: Option<()> = None; + let my_option: Option<&str> = None; // `unwrap` of an `Option` after checking if it is `None` will panic. // Use `if-let` instead. if let Some(value) = my_option { - println!("{value:?}"); + println!("{value}"); } // A comma was missing. From d5cae8ff597ab85d817d3abb6f30159f1823a0f2 Mon Sep 17 00:00:00 2001 From: Antoine Dupuis Date: Wed, 13 Nov 2024 23:51:09 +0100 Subject: [PATCH 020/120] Add alternative solution using From trait --- solutions/13_error_handling/errors6.rs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/solutions/13_error_handling/errors6.rs b/solutions/13_error_handling/errors6.rs index 86793619..7bad200b 100644 --- a/solutions/13_error_handling/errors6.rs +++ b/solutions/13_error_handling/errors6.rs @@ -29,6 +29,21 @@ impl ParsePosNonzeroError { } } +/// As an alternative solution, implementing the `From` trait allows for the +/// automatic conversion from a `ParseIntError` into a `ParsePosNonzeroError` +/// using the `?` operator, without the need to call `map_err`. +/// +/// ``` +/// let x: i64 = s.parse()?; +/// ``` +/// +/// Traits like `From` will be dealt with in later exercises. +impl From for ParsePosNonzeroError { + fn from(err: ParseIntError) -> Self { + ParsePosNonzeroError::ParseInt(err) + } +} + #[derive(PartialEq, Debug)] struct PositiveNonzeroInteger(u64); From fc0cd8f0f88a03b7fdb69a6ba668b8479bd3eddd Mon Sep 17 00:00:00 2001 From: Antoine Dupuis Date: Thu, 14 Nov 2024 09:14:40 +0100 Subject: [PATCH 021/120] Switch comment style to // --- solutions/13_error_handling/errors6.rs | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/solutions/13_error_handling/errors6.rs b/solutions/13_error_handling/errors6.rs index 7bad200b..ce18073a 100644 --- a/solutions/13_error_handling/errors6.rs +++ b/solutions/13_error_handling/errors6.rs @@ -29,15 +29,15 @@ impl ParsePosNonzeroError { } } -/// As an alternative solution, implementing the `From` trait allows for the -/// automatic conversion from a `ParseIntError` into a `ParsePosNonzeroError` -/// using the `?` operator, without the need to call `map_err`. -/// -/// ``` -/// let x: i64 = s.parse()?; -/// ``` -/// -/// Traits like `From` will be dealt with in later exercises. +// As an alternative solution, implementing the `From` trait allows for the +// automatic conversion from a `ParseIntError` into a `ParsePosNonzeroError` +// using the `?` operator, without the need to call `map_err`. +// +// ``` +// let x: i64 = s.parse()?; +// ``` +// +// Traits like `From` will be dealt with in later exercises. impl From for ParsePosNonzeroError { fn from(err: ParseIntError) -> Self { ParsePosNonzeroError::ParseInt(err) From d07de879a7dcfd5645bb8a658d0b20eff37250dc Mon Sep 17 00:00:00 2001 From: mo8it Date: Wed, 11 Dec 2024 00:12:22 +0100 Subject: [PATCH 022/120] Update deps --- Cargo.lock | 83 +++++++++++++++++++++++++----------------------------- Cargo.toml | 10 +++---- 2 files changed, 43 insertions(+), 50 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index a61cf39a..f3c4af75 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -53,9 +53,9 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.93" +version = "1.0.94" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c95c10ba0b00a02636238b814946408b1322d5ac4760326e6fb8ec956d85775" +checksum = "c1fd03a028ef38ba2276dce7e33fcd6369c158a1bca17946c4b1b701891c1ff7" [[package]] name = "autocfg" @@ -83,9 +83,9 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "clap" -version = "4.5.20" +version = "4.5.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b97f376d85a664d5837dbae44bf546e6477a679ff6610010f17276f686d867e8" +checksum = "3135e7ec2ef7b10c6ed8950f0f792ed96ee093fa088608f1c76e569722700c84" dependencies = [ "clap_builder", "clap_derive", @@ -93,9 +93,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.5.20" +version = "4.5.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "19bc80abd44e4bed93ca373a0704ccbd1b710dc5749406201bb018272808dc54" +checksum = "30582fc632330df2bd26877bde0c1f4470d57c582bbc070376afcd04d8cb4838" dependencies = [ "anstream", "anstyle", @@ -117,9 +117,9 @@ dependencies = [ [[package]] name = "clap_lex" -version = "0.7.2" +version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1462739cb27611015575c0c11df5df7601141071f07518d56fcc1be504cbec97" +checksum = "f46ad14479a25103f283c0f10005961cf086d8dc42205bb44c46ac563475dca6" [[package]] name = "colorchoice" @@ -160,19 +160,19 @@ checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" [[package]] name = "errno" -version = "0.3.9" +version = "0.3.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "534c5cf6194dfab3db3242765c03bbe257cf92f22b38f6bc0c58d59108a820ba" +checksum = "33d852cb9b869c2a9b3df2f71a3074817f01e1844f839a144f5fcef059a4eb5d" dependencies = [ "libc", - "windows-sys 0.52.0", + "windows-sys 0.59.0", ] [[package]] name = "fastrand" -version = "2.2.0" +version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "486f806e73c5707928240ddc295403b1b93c96a02038563881c4a2fd84b81ac4" +checksum = "37909eebbb50d72f9059c3b6d82c0463f2ff062c9e95845c43a6c9c0355411be" [[package]] name = "filetime" @@ -197,9 +197,9 @@ dependencies = [ [[package]] name = "hashbrown" -version = "0.15.1" +version = "0.15.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3a9bfc1af68b1726ea47d3d5109de126281def866b33970e10fbab11b5dafab3" +checksum = "bf151400ff0baff5465007dd2f3e717f3fe502074ca563069ce3a6629d07b289" [[package]] name = "heck" @@ -207,17 +207,11 @@ version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" -[[package]] -name = "hermit-abi" -version = "0.3.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d231dfb89cfffdbc30e7fc41579ed6066ad03abda9e567ccafae602b97ec5024" - [[package]] name = "indexmap" -version = "2.6.0" +version = "2.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "707907fe3c25f5424cce2cb7e1cbcafee6bdbe735ca90ef77c29e84591e5b9da" +checksum = "62f822373a4fe84d4bb149bf54e584a7f4abec90e072ed49cda0edea5b95471f" dependencies = [ "equivalent", "hashbrown", @@ -260,9 +254,9 @@ checksum = "7943c866cc5cd64cbc25b2e01621d07fa8eb2a1a23160ee81ce38704e97b8ecf" [[package]] name = "itoa" -version = "1.0.11" +version = "1.0.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b" +checksum = "d75a2a4b1b190afb6f5425f10f6a8f959d2ea0b9c2b1d79553551850539e4674" [[package]] name = "kqueue" @@ -286,9 +280,9 @@ dependencies = [ [[package]] name = "libc" -version = "0.2.162" +version = "0.2.168" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "18d287de67fe55fd7e1581fe933d965a5a9477b38e949cfa9f8574ef01506398" +checksum = "5aaeb2981e0606ca11d79718f8bb01164f1d6ed75080182d3abf017e6d244b6d" [[package]] name = "libredox" @@ -331,11 +325,10 @@ checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" [[package]] name = "mio" -version = "1.0.2" +version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "80e04d1dcff3aae0704555fe5fee3bcfaf3d1fdf8a7e521d5b9d2b42acb52cec" +checksum = "2886843bf800fba2e3377cff24abf6379b4c4d5c6681eaf9ea5b0d15090450bd" dependencies = [ - "hermit-abi", "libc", "log", "wasi", @@ -411,9 +404,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.89" +version = "1.0.92" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f139b0662de085916d1fb67d2b4169d1addddda1919e696f3252b740b629986e" +checksum = "37d3544b3f2748c54e147655edb5025752e2303145b5aefb3c3ea2c78b973bb0" dependencies = [ "unicode-ident", ] @@ -438,15 +431,15 @@ dependencies = [ [[package]] name = "rustix" -version = "0.38.40" +version = "0.38.42" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "99e4ea3e1cdc4b559b8e5650f9c8e5998e3e5c1343b4eaf034565f32318d63c0" +checksum = "f93dc38ecbab2eb790ff964bb77fa94faf256fd3e73285fd7ba0903b76bedb85" dependencies = [ "bitflags 2.6.0", "errno", "libc", "linux-raw-sys", - "windows-sys 0.52.0", + "windows-sys 0.59.0", ] [[package]] @@ -498,18 +491,18 @@ checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" [[package]] name = "serde" -version = "1.0.214" +version = "1.0.215" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f55c3193aca71c12ad7890f1785d2b73e1b9f63a0bbc353c08ef26fe03fc56b5" +checksum = "6513c1ad0b11a9376da888e3e0baa0077f1aed55c17f50e7b2397136129fb88f" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.214" +version = "1.0.215" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "de523f781f095e28fa605cdce0f8307e451cc0fd14e2eb4cd2e98a355b147766" +checksum = "ad1e866f866923f252f05c889987993144fb74e722403468a4ebd70c3cd756c0" dependencies = [ "proc-macro2", "quote", @@ -518,9 +511,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.132" +version = "1.0.133" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d726bfaff4b320266d395898905d0eba0345aae23b54aee3a737e260fd46db03" +checksum = "c7fceb2473b9166b2294ef05efcb65a3db80803f0b03ef86a5fc88a2b85ee377" dependencies = [ "itoa", "memchr", @@ -581,9 +574,9 @@ checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" [[package]] name = "syn" -version = "2.0.87" +version = "2.0.90" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "25aa4ce346d03a6dcd68dd8b4010bcb74e54e62c90c573f394c46eae99aba32d" +checksum = "919d3b74a5dd0ccd15aeb8f93e7006bd9e14c295087c9896a110f490752bcf31" dependencies = [ "proc-macro2", "quote", @@ -627,9 +620,9 @@ dependencies = [ [[package]] name = "unicode-ident" -version = "1.0.13" +version = "1.0.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e91b56cd4cadaeb79bbf1a5645f6b4f8dc5bde8834ad5894a8db35fda9efa1fe" +checksum = "adb9e6ca4f869e1180728b7950e35922a7fc6397f7b641499e8f3ef06e50dc83" [[package]] name = "utf8parse" diff --git a/Cargo.toml b/Cargo.toml index ff88de2d..102bd6c5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -19,7 +19,7 @@ edition = "2021" # On Update: Update the edition of the `rustfmt` command that c rust-version = "1.80" [workspace.dependencies] -serde = { version = "1.0.214", features = ["derive"] } +serde = { version = "1.0.215", features = ["derive"] } toml_edit = { version = "0.22.22", default-features = false, features = ["parse", "serde"] } [package] @@ -46,18 +46,18 @@ include = [ ] [dependencies] -anyhow = "1.0.93" -clap = { version = "4.5.20", features = ["derive"] } +anyhow = "1.0.94" +clap = { version = "4.5.23", features = ["derive"] } crossterm = { version = "0.28.1", default-features = false, features = ["windows", "events"] } notify = "7.0.0" os_pipe = "1.2.1" rustlings-macros = { path = "rustlings-macros", version = "=6.4.0" } -serde_json = "1.0.132" +serde_json = "1.0.133" serde.workspace = true toml_edit.workspace = true [target.'cfg(not(windows))'.dependencies] -rustix = { version = "0.38.38", default-features = false, features = ["std", "stdio", "termios"] } +rustix = { version = "0.38.42", default-features = false, features = ["std", "stdio", "termios"] } [dev-dependencies] tempfile = "3.14.0" From 6e60f441e9e93e7ebc3dc0072de7eaef8052931d Mon Sep 17 00:00:00 2001 From: Joel Marcey Date: Fri, 13 Dec 2024 10:44:21 -0800 Subject: [PATCH 023/120] Fix argument comment in test of if2.rs --- exercises/03_if/if2.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exercises/03_if/if2.rs b/exercises/03_if/if2.rs index 10037f26..ca8493cc 100644 --- a/exercises/03_if/if2.rs +++ b/exercises/03_if/if2.rs @@ -19,7 +19,7 @@ mod tests { #[test] fn yummy_food() { - // This means that calling `picky_eater` with the argument "food" should return "Yummy!". + // This means that calling `picky_eater` with the argument "strawberry" should return "Yummy!". assert_eq!(picky_eater("strawberry"), "Yummy!"); } From ed1ee38923adb39c37453721060a8843c98605e7 Mon Sep 17 00:00:00 2001 From: mo8it Date: Sat, 28 Dec 2024 16:40:07 +0100 Subject: [PATCH 024/120] Link to simplified Chinese translation --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 9a223670..e0f65923 100644 --- a/README.md +++ b/README.md @@ -137,7 +137,8 @@ If you need any help while doing the exercises and the builtin-hints aren't help Third-party exercises are a set of exercises maintained by the community. You can use the same `rustlings` program that you installed with `cargo install rustlings` to run them: -- [日本語版 Rustlings](https://github.com/sotanengel/rustlings-jp):A Japanese translation of the Rustlings exercises. +- 🇯🇵 [Japanese Translation](https://github.com/sotanengel/rustlings-jp):A Japanese translation of the Rustlings exercises. +- 🇨🇳 [Simplified Chinese Translation](https://github.com/SandmeyerX/rustlings-zh-cn): A simplified Chinese translation of the Rustlings exercises. Do you want to create your own set of Rustlings exercises to focus on some specific topic? Or do you want to translate the original Rustlings exercises? From 53ec59ed95bfddf17ade467c6bceb702b7d04d51 Mon Sep 17 00:00:00 2001 From: mo8it Date: Sat, 28 Dec 2024 16:41:43 +0100 Subject: [PATCH 025/120] Rename translations --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index e0f65923..3118451f 100644 --- a/README.md +++ b/README.md @@ -137,8 +137,8 @@ If you need any help while doing the exercises and the builtin-hints aren't help Third-party exercises are a set of exercises maintained by the community. You can use the same `rustlings` program that you installed with `cargo install rustlings` to run them: -- 🇯🇵 [Japanese Translation](https://github.com/sotanengel/rustlings-jp):A Japanese translation of the Rustlings exercises. -- 🇨🇳 [Simplified Chinese Translation](https://github.com/SandmeyerX/rustlings-zh-cn): A simplified Chinese translation of the Rustlings exercises. +- 🇯🇵 [Japanese Rustlings](https://github.com/sotanengel/rustlings-jp):A Japanese translation of the Rustlings exercises. +- 🇨🇳 [Simplified Chinese Rustlings](https://github.com/SandmeyerX/rustlings-zh-cn): A simplified Chinese translation of the Rustlings exercises. Do you want to create your own set of Rustlings exercises to focus on some specific topic? Or do you want to translate the original Rustlings exercises? From bde6f7470c651c1d608eda6a18940b092a982184 Mon Sep 17 00:00:00 2001 From: mo8it Date: Sat, 28 Dec 2024 16:46:24 +0100 Subject: [PATCH 026/120] Co-ordinates -> Coordinates --- exercises/12_options/options3.rs | 2 +- solutions/12_options/options3.rs | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/exercises/12_options/options3.rs b/exercises/12_options/options3.rs index 4cedb512..c97b1d3c 100644 --- a/exercises/12_options/options3.rs +++ b/exercises/12_options/options3.rs @@ -9,7 +9,7 @@ fn main() { // TODO: Fix the compiler error by adding something to this match statement. match optional_point { - Some(p) => println!("Co-ordinates are {},{}", p.x, p.y), + Some(p) => println!("Coordinates are {},{}", p.x, p.y), _ => panic!("No match!"), } diff --git a/solutions/12_options/options3.rs b/solutions/12_options/options3.rs index 0081eeb2..c918f711 100644 --- a/solutions/12_options/options3.rs +++ b/solutions/12_options/options3.rs @@ -10,7 +10,7 @@ fn main() { // Solution 1: Matching over the `Option` (not `&Option`) but without moving // out of the `Some` variant. match optional_point { - Some(ref p) => println!("Co-ordinates are {},{}", p.x, p.y), + Some(ref p) => println!("Coordinates are {},{}", p.x, p.y), // ^^^ added _ => panic!("No match!"), } @@ -18,7 +18,8 @@ fn main() { // Solution 2: Matching over a reference (`&Option`) by added `&` before // `optional_point`. match &optional_point { - Some(p) => println!("Co-ordinates are {},{}", p.x, p.y), + //^ added + Some(p) => println!("Coordinates are {},{}", p.x, p.y), _ => panic!("No match!"), } From 0b55809bb9c75ecdb5018e214a5ee3aa0363348f Mon Sep 17 00:00:00 2001 From: mo8it Date: Wed, 1 Jan 2025 22:01:39 +0100 Subject: [PATCH 027/120] Fix building from source on Windows --- build.rs | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 build.rs diff --git a/build.rs b/build.rs new file mode 100644 index 00000000..79a1fadd --- /dev/null +++ b/build.rs @@ -0,0 +1,6 @@ +fn main() { + // Fix building from source on Windows because it can't handle file links. + #[cfg(windows)] + std::fs::copy("dev/Cargo.toml", "dev-Cargo.toml") + .expect("Failed to copy the file `dev/Cargo.toml` to `dev-Cargo.toml`"); +} From 1aec7c1152e9b57142d5efaee4a9d95072b760bf Mon Sep 17 00:00:00 2001 From: mo8it Date: Wed, 1 Jan 2025 22:07:41 +0100 Subject: [PATCH 028/120] Fix Windows CI --- build.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/build.rs b/build.rs index 79a1fadd..56878641 100644 --- a/build.rs +++ b/build.rs @@ -1,6 +1,5 @@ fn main() { // Fix building from source on Windows because it can't handle file links. #[cfg(windows)] - std::fs::copy("dev/Cargo.toml", "dev-Cargo.toml") - .expect("Failed to copy the file `dev/Cargo.toml` to `dev-Cargo.toml`"); + let _ = std::fs::copy("dev/Cargo.toml", "dev-Cargo.toml"); } From d12735a57336c8bbad2c26ea0328d88c117918b5 Mon Sep 17 00:00:00 2001 From: mo8it Date: Thu, 16 Jan 2025 10:41:17 +0100 Subject: [PATCH 029/120] Update deps --- Cargo.lock | 127 +++++++++++++++++++++++++++-------------------------- Cargo.toml | 14 +++--- 2 files changed, 71 insertions(+), 70 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index f3c4af75..32750f03 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -43,19 +43,20 @@ dependencies = [ [[package]] name = "anstyle-wincon" -version = "3.0.6" +version = "3.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2109dbce0e72be3ec00bed26e6a7479ca384ad226efdd66db8fa2e3a38c83125" +checksum = "ca3534e77181a9cc07539ad51f2141fe32f6c3ffd4df76db8ad92346b003ae4e" dependencies = [ "anstyle", + "once_cell", "windows-sys 0.59.0", ] [[package]] name = "anyhow" -version = "1.0.94" +version = "1.0.95" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c1fd03a028ef38ba2276dce7e33fcd6369c158a1bca17946c4b1b701891c1ff7" +checksum = "34ac096ce696dc2fcabef30516bb13c0a68a11d30131d3df6f04711467681b04" [[package]] name = "autocfg" @@ -71,9 +72,9 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] name = "bitflags" -version = "2.6.0" +version = "2.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b048fb63fd8b5923fc5aa7b340d8e156aec7ec02f0c78fa8a6ddc2613f6f71de" +checksum = "8f68f53c83ab957f72c32642f3868eec03eb974d1fb82e453128456482613d36" [[package]] name = "cfg-if" @@ -83,9 +84,9 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "clap" -version = "4.5.23" +version = "4.5.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3135e7ec2ef7b10c6ed8950f0f792ed96ee093fa088608f1c76e569722700c84" +checksum = "a8eb5e908ef3a6efbe1ed62520fb7287959888c88485abe072543190ecc66783" dependencies = [ "clap_builder", "clap_derive", @@ -93,9 +94,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.5.23" +version = "4.5.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "30582fc632330df2bd26877bde0c1f4470d57c582bbc070376afcd04d8cb4838" +checksum = "96b01801b5fc6a0a232407abc821660c9c6d25a1cafc0d4f85f29fb8d9afc121" dependencies = [ "anstream", "anstyle", @@ -105,9 +106,9 @@ dependencies = [ [[package]] name = "clap_derive" -version = "4.5.18" +version = "4.5.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ac6a0c7b1a9e9a5186361f67dfa1b88213572f427fb9ab038efb2bd8c582dab" +checksum = "54b755194d6389280185988721fffba69495eed5ee9feeee9a599b53db80318c" dependencies = [ "heck", "proc-macro2", @@ -133,7 +134,7 @@ version = "0.28.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "829d955a0bb380ef178a640b91779e3987da38c9aea133b20614cfed8cdea9c6" dependencies = [ - "bitflags 2.6.0", + "bitflags 2.8.0", "crossterm_winapi", "mio", "parking_lot", @@ -195,6 +196,17 @@ dependencies = [ "libc", ] +[[package]] +name = "getrandom" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c4567c8db10ae91089c99af84c68c38da3ec2f087c3f82960bcdbf3656b6f4d7" +dependencies = [ + "cfg-if", + "libc", + "wasi", +] + [[package]] name = "hashbrown" version = "0.15.2" @@ -219,11 +231,11 @@ dependencies = [ [[package]] name = "inotify" -version = "0.10.2" +version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fdd168d97690d0b8c412d6b6c10360277f4d7ee495c5d0d5d5fe0854923255cc" +checksum = "f37dccff2791ab604f9babef0ba14fbe0be30bd368dc541e2b08d07c8aa908f3" dependencies = [ - "bitflags 1.3.2", + "bitflags 2.8.0", "inotify-sys", "libc", ] @@ -237,15 +249,6 @@ dependencies = [ "libc", ] -[[package]] -name = "instant" -version = "0.1.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e0242819d153cba4b4b05a5a8f2a7e9bbf97b6055b2a002b395c96b5ff3c0222" -dependencies = [ - "cfg-if", -] - [[package]] name = "is_terminal_polyfill" version = "1.70.1" @@ -280,9 +283,9 @@ dependencies = [ [[package]] name = "libc" -version = "0.2.168" +version = "0.2.169" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5aaeb2981e0606ca11d79718f8bb01164f1d6ed75080182d3abf017e6d244b6d" +checksum = "b5aba8db14291edd000dfcc4d620c7ebfb122c613afb886ca8803fa4e128a20a" [[package]] name = "libredox" @@ -290,16 +293,16 @@ version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c0ff37bd590ca25063e35af745c343cb7a0271906fb7b37e4813e8f79f00268d" dependencies = [ - "bitflags 2.6.0", + "bitflags 2.8.0", "libc", "redox_syscall", ] [[package]] name = "linux-raw-sys" -version = "0.4.14" +version = "0.4.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "78b3ae25bc7c8c38cec158d1f2757ee79e9b3740fbc7ccf0e59e4b08d793fa89" +checksum = "d26c52dbd32dccf2d10cac7725f8eae5296885fb5703b261f7d0a0739ec807ab" [[package]] name = "lock_api" @@ -313,9 +316,9 @@ dependencies = [ [[package]] name = "log" -version = "0.4.22" +version = "0.4.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a7a70ba024b9dc04c27ea2f0c0548feb474ec5c54bba33a7f72f873a39d07b24" +checksum = "04cbf5b083de1c7e0222a7a51dbfdba1cbe1c6ab0b15e29fff3f6c077fd9cd9f" [[package]] name = "memchr" @@ -337,11 +340,11 @@ dependencies = [ [[package]] name = "notify" -version = "7.0.0" +version = "8.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c533b4c39709f9ba5005d8002048266593c1cfaf3c5f0739d5b8ab0c6c504009" +checksum = "2fee8403b3d66ac7b26aee6e40a897d85dc5ce26f44da36b8b73e987cc52e943" dependencies = [ - "bitflags 2.6.0", + "bitflags 2.8.0", "filetime", "fsevent-sys", "inotify", @@ -351,17 +354,14 @@ dependencies = [ "mio", "notify-types", "walkdir", - "windows-sys 0.52.0", + "windows-sys 0.59.0", ] [[package]] name = "notify-types" -version = "1.0.0" +version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7393c226621f817964ffb3dc5704f9509e107a8b024b489cc2c1b217378785df" -dependencies = [ - "instant", -] +checksum = "5e0826a989adedc2a244799e823aece04662b66609d96af8dff7ac6df9a8925d" [[package]] name = "once_cell" @@ -404,38 +404,38 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.92" +version = "1.0.93" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "37d3544b3f2748c54e147655edb5025752e2303145b5aefb3c3ea2c78b973bb0" +checksum = "60946a68e5f9d28b0dc1c21bb8a97ee7d018a8b322fa57838ba31cc878e22d99" dependencies = [ "unicode-ident", ] [[package]] name = "quote" -version = "1.0.37" +version = "1.0.38" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5b9d34b8991d19d98081b46eacdd8eb58c6f2b201139f7c5f643cc155a633af" +checksum = "0e4dccaaaf89514f546c693ddc140f729f958c247918a13380cccc6078391acc" dependencies = [ "proc-macro2", ] [[package]] name = "redox_syscall" -version = "0.5.7" +version = "0.5.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b6dfecf2c74bce2466cabf93f6664d6998a69eb21e39f4207930065b27b771f" +checksum = "03a862b389f93e68874fbf580b9de08dd02facb9a788ebadaf4a3fd33cf58834" dependencies = [ - "bitflags 2.6.0", + "bitflags 2.8.0", ] [[package]] name = "rustix" -version = "0.38.42" +version = "0.38.43" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f93dc38ecbab2eb790ff964bb77fa94faf256fd3e73285fd7ba0903b76bedb85" +checksum = "a78891ee6bf2340288408954ac787aa063d8e8817e9f53abb37c695c6d834ef6" dependencies = [ - "bitflags 2.6.0", + "bitflags 2.8.0", "errno", "libc", "linux-raw-sys", @@ -491,18 +491,18 @@ checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" [[package]] name = "serde" -version = "1.0.215" +version = "1.0.217" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6513c1ad0b11a9376da888e3e0baa0077f1aed55c17f50e7b2397136129fb88f" +checksum = "02fc4265df13d6fa1d00ecff087228cc0a2b5f3c0e87e258d8b94a156e984c70" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.215" +version = "1.0.217" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ad1e866f866923f252f05c889987993144fb74e722403468a4ebd70c3cd756c0" +checksum = "5a9bf7cf98d04a2b28aead066b7496853d4779c9cc183c440dbac457641e19a0" dependencies = [ "proc-macro2", "quote", @@ -511,9 +511,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.133" +version = "1.0.135" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c7fceb2473b9166b2294ef05efcb65a3db80803f0b03ef86a5fc88a2b85ee377" +checksum = "2b0d7ba2887406110130a978386c4e1befb98c674b4fba677954e4db976630d9" dependencies = [ "itoa", "memchr", @@ -574,9 +574,9 @@ checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" [[package]] name = "syn" -version = "2.0.90" +version = "2.0.96" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "919d3b74a5dd0ccd15aeb8f93e7006bd9e14c295087c9896a110f490752bcf31" +checksum = "d5d0adab1ae378d7f53bdebc67a39f1f151407ef230f0ce2883572f5d8985c80" dependencies = [ "proc-macro2", "quote", @@ -585,12 +585,13 @@ dependencies = [ [[package]] name = "tempfile" -version = "3.14.0" +version = "3.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "28cce251fcbc87fac86a866eeb0d6c2d536fc16d06f184bb61aeae11aa4cee0c" +checksum = "9a8a559c81686f576e8cd0290cd2a24a2a9ad80c98b3478856500fcbd7acd704" dependencies = [ "cfg-if", "fastrand", + "getrandom", "once_cell", "rustix", "windows-sys 0.59.0", @@ -761,9 +762,9 @@ checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" [[package]] name = "winnow" -version = "0.6.20" +version = "0.6.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "36c1fec1a2bb5866f07c25f68c26e565c4c200aebb96d7e55710c19d3e8ac49b" +checksum = "c8d71a593cc5c42ad7876e2c1fda56f314f3754c084128833e64f1345ff8a03a" dependencies = [ "memchr", ] diff --git a/Cargo.toml b/Cargo.toml index 102bd6c5..c0eb1d12 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -19,7 +19,7 @@ edition = "2021" # On Update: Update the edition of the `rustfmt` command that c rust-version = "1.80" [workspace.dependencies] -serde = { version = "1.0.215", features = ["derive"] } +serde = { version = "1.0.217", features = ["derive"] } toml_edit = { version = "0.22.22", default-features = false, features = ["parse", "serde"] } [package] @@ -46,21 +46,21 @@ include = [ ] [dependencies] -anyhow = "1.0.94" -clap = { version = "4.5.23", features = ["derive"] } +anyhow = "1.0.95" +clap = { version = "4.5.26", features = ["derive"] } crossterm = { version = "0.28.1", default-features = false, features = ["windows", "events"] } -notify = "7.0.0" +notify = "8.0.0" os_pipe = "1.2.1" rustlings-macros = { path = "rustlings-macros", version = "=6.4.0" } -serde_json = "1.0.133" +serde_json = "1.0.135" serde.workspace = true toml_edit.workspace = true [target.'cfg(not(windows))'.dependencies] -rustix = { version = "0.38.42", default-features = false, features = ["std", "stdio", "termios"] } +rustix = { version = "0.38.43", default-features = false, features = ["std", "stdio", "termios"] } [dev-dependencies] -tempfile = "3.14.0" +tempfile = "3.15.0" [profile.release] panic = "abort" From fbfd4f25e7e715007f5f3f6678f5d336d24d3660 Mon Sep 17 00:00:00 2001 From: mo8it Date: Thu, 16 Jan 2025 10:41:48 +0100 Subject: [PATCH 030/120] Disable following symlinks in the watcher --- src/watch.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/watch.rs b/src/watch.rs index 6259c9df..3a56b4b6 100644 --- a/src/watch.rs +++ b/src/watch.rs @@ -74,7 +74,9 @@ fn run_watch( let mut watcher = RecommendedWatcher::new( notify_event_handler, - Config::default().with_poll_interval(Duration::from_secs(1)), + Config::default() + .with_follow_symlinks(false) + .with_poll_interval(Duration::from_secs(1)), ) .inspect_err(|_| eprintln!("{NOTIFY_ERR}"))?; From 298be671b9108e490fcef6b8febace8659ec710a Mon Sep 17 00:00:00 2001 From: mo8it Date: Tue, 18 Feb 2025 20:03:49 +0100 Subject: [PATCH 031/120] Update deps --- Cargo.lock | 87 +++++++++++++++++++++++++++++++++--------------------- Cargo.toml | 10 +++---- 2 files changed, 58 insertions(+), 39 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 32750f03..3c340b64 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -84,9 +84,9 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "clap" -version = "4.5.26" +version = "4.5.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a8eb5e908ef3a6efbe1ed62520fb7287959888c88485abe072543190ecc66783" +checksum = "92b7b18d71fad5313a1e320fa9897994228ce274b60faa4d694fe0ea89cd9e6d" dependencies = [ "clap_builder", "clap_derive", @@ -94,9 +94,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.5.26" +version = "4.5.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96b01801b5fc6a0a232407abc821660c9c6d25a1cafc0d4f85f29fb8d9afc121" +checksum = "a35db2071778a7344791a4fb4f95308b5673d219dee3ae348b86642574ecc90c" dependencies = [ "anstream", "anstyle", @@ -106,9 +106,9 @@ dependencies = [ [[package]] name = "clap_derive" -version = "4.5.24" +version = "4.5.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "54b755194d6389280185988721fffba69495eed5ee9feeee9a599b53db80318c" +checksum = "bf4ced95c6f4a675af3da73304b9ac4ed991640c36374e4b46795c49e17cf1ed" dependencies = [ "heck", "proc-macro2", @@ -155,9 +155,9 @@ dependencies = [ [[package]] name = "equivalent" -version = "1.0.1" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" +checksum = "877a4ace8713b0bcf2a4e7eec82529c029f1d0619886d18145fea96c3ffe5c0f" [[package]] name = "errno" @@ -198,13 +198,14 @@ dependencies = [ [[package]] name = "getrandom" -version = "0.2.15" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c4567c8db10ae91089c99af84c68c38da3ec2f087c3f82960bcdbf3656b6f4d7" +checksum = "43a49c392881ce6d5c3b8cb70f98717b7c07aabbdff06687b9030dbfbe2725f8" dependencies = [ "cfg-if", "libc", - "wasi", + "wasi 0.13.3+wasi-0.2.2", + "windows-targets", ] [[package]] @@ -221,9 +222,9 @@ checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" [[package]] name = "indexmap" -version = "2.7.0" +version = "2.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62f822373a4fe84d4bb149bf54e584a7f4abec90e072ed49cda0edea5b95471f" +checksum = "8c9c992b02b5b4c94ea26e32fe5bccb7aa7d9f390ab5c1221ff895bc7ea8b652" dependencies = [ "equivalent", "hashbrown", @@ -334,7 +335,7 @@ checksum = "2886843bf800fba2e3377cff24abf6379b4c4d5c6681eaf9ea5b0d15090450bd" dependencies = [ "libc", "log", - "wasi", + "wasi 0.11.0+wasi-snapshot-preview1", "windows-sys 0.52.0", ] @@ -365,9 +366,9 @@ checksum = "5e0826a989adedc2a244799e823aece04662b66609d96af8dff7ac6df9a8925d" [[package]] name = "once_cell" -version = "1.20.2" +version = "1.20.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1261fe7e33c73b354eab43b1273a57c8f967d0391e80353e51f764ac02cf6775" +checksum = "945462a4b81e43c4e3ba96bd7b49d834c6f61198356aa858733bc4acf3cbe62e" [[package]] name = "os_pipe" @@ -431,9 +432,9 @@ dependencies = [ [[package]] name = "rustix" -version = "0.38.43" +version = "0.38.44" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a78891ee6bf2340288408954ac787aa063d8e8817e9f53abb37c695c6d834ef6" +checksum = "fdb5bc1ae2baa591800df16c9ca78619bf65c0488b41b96ccec5d11220d8c154" dependencies = [ "bitflags 2.8.0", "errno", @@ -470,9 +471,9 @@ dependencies = [ [[package]] name = "ryu" -version = "1.0.18" +version = "1.0.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f3cb5ba0dc43242ce17de99c180e96db90b235b8a9fdc9543c96d2209116bd9f" +checksum = "6ea1a2d0a644769cc99faa24c3ad26b379b786fe7c36fd3c546254801650e6dd" [[package]] name = "same-file" @@ -511,9 +512,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.135" +version = "1.0.138" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b0d7ba2887406110130a978386c4e1befb98c674b4fba677954e4db976630d9" +checksum = "d434192e7da787e94a6ea7e9670b26a036d0ca41e0b7efb2676dd32bae872949" dependencies = [ "itoa", "memchr", @@ -562,9 +563,9 @@ dependencies = [ [[package]] name = "smallvec" -version = "1.13.2" +version = "1.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67" +checksum = "7fcf8323ef1faaee30a44a340193b1ac6814fd9b7b4e88e9d4519a3e4abe1cfd" [[package]] name = "strsim" @@ -574,9 +575,9 @@ checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" [[package]] name = "syn" -version = "2.0.96" +version = "2.0.98" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d5d0adab1ae378d7f53bdebc67a39f1f151407ef230f0ce2883572f5d8985c80" +checksum = "36147f1a48ae0ec2b5b3bc5b537d267457555a10dc06f3dbc8cb11ba3006d3b1" dependencies = [ "proc-macro2", "quote", @@ -585,9 +586,9 @@ dependencies = [ [[package]] name = "tempfile" -version = "3.15.0" +version = "3.17.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a8a559c81686f576e8cd0290cd2a24a2a9ad80c98b3478856500fcbd7acd704" +checksum = "22e5a0acb1f3f55f65cc4a866c361b2fb2a0ff6366785ae6fbb5f85df07ba230" dependencies = [ "cfg-if", "fastrand", @@ -608,9 +609,9 @@ dependencies = [ [[package]] name = "toml_edit" -version = "0.22.22" +version = "0.22.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ae48d6208a266e853d946088ed816055e556cc6028c5e8e2b84d9fa5dd7c7f5" +checksum = "17b4795ff5edd201c7cd6dca065ae59972ce77d1b80fa0a84d94950ece7d1474" dependencies = [ "indexmap", "serde", @@ -621,9 +622,9 @@ dependencies = [ [[package]] name = "unicode-ident" -version = "1.0.14" +version = "1.0.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "adb9e6ca4f869e1180728b7950e35922a7fc6397f7b641499e8f3ef06e50dc83" +checksum = "a210d160f08b701c8721ba1c726c11662f877ea6b7094007e1ca9a1041945034" [[package]] name = "utf8parse" @@ -647,6 +648,15 @@ version = "0.11.0+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" +[[package]] +name = "wasi" +version = "0.13.3+wasi-0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "26816d2e1a4a36a2940b96c5296ce403917633dff8f3440e9b236ed6f6bacad2" +dependencies = [ + "wit-bindgen-rt", +] + [[package]] name = "winapi" version = "0.3.9" @@ -762,9 +772,18 @@ checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" [[package]] name = "winnow" -version = "0.6.24" +version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c8d71a593cc5c42ad7876e2c1fda56f314f3754c084128833e64f1345ff8a03a" +checksum = "59690dea168f2198d1a3b0cac23b8063efcd11012f10ae4698f284808c8ef603" dependencies = [ "memchr", ] + +[[package]] +name = "wit-bindgen-rt" +version = "0.33.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3268f3d866458b787f390cf61f4bbb563b922d091359f9608842999eaee3943c" +dependencies = [ + "bitflags 2.8.0", +] diff --git a/Cargo.toml b/Cargo.toml index c0eb1d12..c229a3fd 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -20,7 +20,7 @@ rust-version = "1.80" [workspace.dependencies] serde = { version = "1.0.217", features = ["derive"] } -toml_edit = { version = "0.22.22", default-features = false, features = ["parse", "serde"] } +toml_edit = { version = "0.22.24", default-features = false, features = ["parse", "serde"] } [package] name = "rustlings" @@ -47,20 +47,20 @@ include = [ [dependencies] anyhow = "1.0.95" -clap = { version = "4.5.26", features = ["derive"] } +clap = { version = "4.5.30", features = ["derive"] } crossterm = { version = "0.28.1", default-features = false, features = ["windows", "events"] } notify = "8.0.0" os_pipe = "1.2.1" rustlings-macros = { path = "rustlings-macros", version = "=6.4.0" } -serde_json = "1.0.135" +serde_json = "1.0.138" serde.workspace = true toml_edit.workspace = true [target.'cfg(not(windows))'.dependencies] -rustix = { version = "0.38.43", default-features = false, features = ["std", "stdio", "termios"] } +rustix = { version = "0.38.44", default-features = false, features = ["std", "stdio", "termios"] } [dev-dependencies] -tempfile = "3.15.0" +tempfile = "3.17.1" [profile.release] panic = "abort" From d9872f2615a11ce94deb85c8f1c215d69abd7992 Mon Sep 17 00:00:00 2001 From: mo8it Date: Tue, 18 Feb 2025 20:10:52 +0100 Subject: [PATCH 032/120] Upgrade to edition 2024 --- CHANGELOG.md | 7 ++++ Cargo.toml | 4 +- dev/Cargo.toml | 2 +- src/app_state.rs | 54 +++++++++++++------------ src/cmd.rs | 2 +- src/dev.rs | 2 +- src/dev/check.rs | 62 ++++++++++++++++++++--------- src/dev/new.rs | 10 +++-- src/exercise.rs | 4 +- src/info_file.rs | 2 +- src/init.rs | 12 ++++-- src/list.rs | 7 ++-- src/list/state.rs | 4 +- src/main.rs | 2 +- src/run.rs | 4 +- src/term.rs | 2 +- src/watch/notify_event.rs | 6 +-- src/watch/state.rs | 9 +++-- src/watch/terminal_event.rs | 2 +- tests/test_exercises/dev/Cargo.toml | 2 +- 20 files changed, 120 insertions(+), 79 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a2085b91..b9826cf0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,10 @@ +## Unreleased + +### Changed + +- Upgrade to Rust edition 2024 +- Raise the minimum supported Rust version to `1.85` + ## 6.4.0 (2024-11-11) diff --git a/Cargo.toml b/Cargo.toml index c229a3fd..e9b29eca 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -15,8 +15,8 @@ authors = [ ] repository = "https://github.com/rust-lang/rustlings" license = "MIT" -edition = "2021" # On Update: Update the edition of the `rustfmt` command that checks the solutions. -rust-version = "1.80" +edition = "2024" # On Update: Update the edition of the `rustfmt` command that checks the solutions. +rust-version = "1.85" [workspace.dependencies] serde = { version = "1.0.217", features = ["derive"] } diff --git a/dev/Cargo.toml b/dev/Cargo.toml index 29a557a0..ae380d17 100644 --- a/dev/Cargo.toml +++ b/dev/Cargo.toml @@ -192,7 +192,7 @@ bin = [ [package] name = "exercises" -edition = "2021" +edition = "2024" # Don't publish the exercises on crates.io! publish = false diff --git a/src/app_state.rs b/src/app_state.rs index 5979150f..d1c45d49 100644 --- a/src/app_state.rs +++ b/src/app_state.rs @@ -1,11 +1,11 @@ -use anyhow::{bail, Context, Error, Result}; -use crossterm::{cursor, terminal, QueueableCommand}; +use anyhow::{Context, Error, Result, bail}; +use crossterm::{QueueableCommand, cursor, terminal}; use std::{ collections::HashSet, env, fs::{File, OpenOptions}, io::{Read, Seek, StdoutLock, Write}, - path::{Path, MAIN_SEPARATOR_STR}, + path::{MAIN_SEPARATOR_STR, Path}, process::{Command, Stdio}, sync::{ atomic::{AtomicUsize, Ordering::Relaxed}, @@ -427,32 +427,34 @@ impl AppState { let next_exercise_ind = &next_exercise_ind; let slf = &self; thread::Builder::new() - .spawn_scoped(s, move || loop { - let exercise_ind = next_exercise_ind.fetch_add(1, Relaxed); - let Some(exercise) = slf.exercises.get(exercise_ind) else { - // No more exercises. - break; - }; + .spawn_scoped(s, move || { + loop { + let exercise_ind = next_exercise_ind.fetch_add(1, Relaxed); + let Some(exercise) = slf.exercises.get(exercise_ind) else { + // No more exercises. + break; + }; - if exercise_progress_sender - .send((exercise_ind, CheckProgress::Checking)) - .is_err() - { - break; - }; + if exercise_progress_sender + .send((exercise_ind, CheckProgress::Checking)) + .is_err() + { + break; + }; - let success = exercise.run_exercise(None, &slf.cmd_runner); - let progress = match success { - Ok(true) => CheckProgress::Done, - Ok(false) => CheckProgress::Pending, - Err(_) => CheckProgress::None, - }; + let success = exercise.run_exercise(None, &slf.cmd_runner); + let progress = match success { + Ok(true) => CheckProgress::Done, + Ok(false) => CheckProgress::Pending, + Err(_) => CheckProgress::None, + }; - if exercise_progress_sender - .send((exercise_ind, progress)) - .is_err() - { - break; + if exercise_progress_sender + .send((exercise_ind, progress)) + .is_err() + { + break; + } } }) .context("Failed to spawn a thread to check all exercises")?; diff --git a/src/cmd.rs b/src/cmd.rs index 30f988a6..551df8f0 100644 --- a/src/cmd.rs +++ b/src/cmd.rs @@ -1,4 +1,4 @@ -use anyhow::{bail, Context, Result}; +use anyhow::{Context, Result, bail}; use serde::Deserialize; use std::{ io::Read, diff --git a/src/dev.rs b/src/dev.rs index 8af40d69..354d77c4 100644 --- a/src/dev.rs +++ b/src/dev.rs @@ -1,4 +1,4 @@ -use anyhow::{bail, Context, Result}; +use anyhow::{Context, Result, bail}; use clap::Subcommand; use std::path::PathBuf; diff --git a/src/dev/check.rs b/src/dev/check.rs index 956c2be2..aacc2f44 100644 --- a/src/dev/check.rs +++ b/src/dev/check.rs @@ -1,8 +1,8 @@ -use anyhow::{anyhow, bail, Context, Error, Result}; +use anyhow::{Context, Error, Result, anyhow, bail}; use std::{ cmp::Ordering, collections::HashSet, - fs::{self, read_dir, OpenOptions}, + fs::{self, OpenOptions, read_dir}, io::{self, Read, Write}, path::{Path, PathBuf}, process::{Command, Stdio}, @@ -10,11 +10,11 @@ use std::{ }; use crate::{ - cargo_toml::{append_bins, bins_start_end_ind, BINS_BUFFER_CAPACITY}, - cmd::CmdRunner, - exercise::{RunnableExercise, OUTPUT_CAPACITY}, - info_file::{ExerciseInfo, InfoFile}, CURRENT_FORMAT_VERSION, + cargo_toml::{BINS_BUFFER_CAPACITY, append_bins, bins_start_end_ind}, + cmd::CmdRunner, + exercise::{OUTPUT_CAPACITY, RunnableExercise}, + info_file::{ExerciseInfo, InfoFile}, }; const MAX_N_EXERCISES: usize = 999; @@ -42,10 +42,14 @@ fn check_cargo_toml( if old_bins != new_bins { if cfg!(debug_assertions) { - bail!("The file `dev/Cargo.toml` is outdated. Run `cargo run -- dev update` to update it. Then run `cargo run -- dev check` again"); + bail!( + "The file `dev/Cargo.toml` is outdated. Run `cargo run -- dev update` to update it. Then run `cargo run -- dev check` again" + ); } - bail!("The file `Cargo.toml` is outdated. Run `rustlings dev update` to update it. Then run `rustlings dev check` again"); + bail!( + "The file `Cargo.toml` is outdated. Run `rustlings dev update` to update it. Then run `rustlings dev check` again" + ); } Ok(()) @@ -63,7 +67,9 @@ fn check_info_file_exercises(info_file: &InfoFile) -> Result> { bail!("Found an empty exercise name in `info.toml`"); } if name.len() > MAX_EXERCISE_NAME_LEN { - bail!("The length of the exercise name `{name}` is bigger than the maximum {MAX_EXERCISE_NAME_LEN}"); + bail!( + "The length of the exercise name `{name}` is bigger than the maximum {MAX_EXERCISE_NAME_LEN}" + ); } if let Some(c) = forbidden_char(name) { bail!("Char `{c}` in the exercise name `{name}` is not allowed"); @@ -79,7 +85,9 @@ fn check_info_file_exercises(info_file: &InfoFile) -> Result> { } if exercise_info.hint.trim_ascii().is_empty() { - bail!("The exercise `{name}` has an empty hint. Please provide a hint or at least tell the user why a hint isn't needed for this exercise"); + bail!( + "The exercise `{name}` has an empty hint. Please provide a hint or at least tell the user why a hint isn't needed for this exercise" + ); } if !names.insert(name) { @@ -96,20 +104,28 @@ fn check_info_file_exercises(info_file: &InfoFile) -> Result> { .with_context(|| format!("Failed to read the file {path}"))?; 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"); + bail!( + "The `main` function is missing in the file `{path}`.\nCreate 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."); + bail!( + "Didn't find any `// TODO` comment in the file `{path}`.\nYou need to have at least one such comment to guide the user." + ); } let contains_tests = file_buf.contains("#[test]\n"); if exercise_info.test { if !contains_tests { - bail!("The file `{path}` doesn't contain any tests. If you don't want to add tests to this exercise, set `test = false` for this exercise in the `info.toml` file"); + bail!( + "The file `{path}` doesn't contain any tests. If you don't want to add tests to this exercise, set `test = false` for this exercise in the `info.toml` file" + ); } } else if contains_tests { - bail!("The file `{path}` contains tests annotated with `#[test]` but the exercise `{name}` has `test = false` in the `info.toml` file"); + bail!( + "The file `{path}` contains tests annotated with `#[test]` but the exercise `{name}` has `test = false` in the `info.toml` file" + ); } file_buf.clear(); @@ -125,7 +141,10 @@ fn check_info_file_exercises(info_file: &InfoFile) -> Result> { // Only one level of directory nesting is allowed. fn check_unexpected_files(dir: &str, allowed_rust_files: &HashSet) -> Result<()> { let unexpected_file = |path: &Path| { - anyhow!("Found the file `{}`. Only `README.md` and Rust files related to an exercise in `info.toml` are allowed in the `{dir}` directory", path.display()) + anyhow!( + "Found the file `{}`. Only `README.md` and Rust files related to an exercise in `info.toml` are allowed in the `{dir}` directory", + path.display() + ) }; for entry in read_dir(dir).with_context(|| format!("Failed to open the `{dir}` directory"))? { @@ -154,7 +173,10 @@ fn check_unexpected_files(dir: &str, allowed_rust_files: &HashSet) -> R let path = entry.path(); if !entry.file_type().unwrap().is_file() { - bail!("Found `{}` but expected only files. Only one level of exercise nesting is allowed", path.display()); + bail!( + "Found `{}` but expected only files. Only one level of exercise nesting is allowed", + path.display() + ); } let file_name = path.file_name().unwrap(); @@ -224,8 +246,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"), - Ordering::Greater => bail!("`format_version` > {CURRENT_FORMAT_VERSION} (supported version)\nTry updating the Rustlings program"), + Ordering::Less => bail!( + "`format_version` < {CURRENT_FORMAT_VERSION} (supported version)\nPlease migrate to the latest format version" + ), + Ordering::Greater => bail!( + "`format_version` > {CURRENT_FORMAT_VERSION} (supported version)\nTry updating the Rustlings program" + ), Ordering::Equal => (), } diff --git a/src/dev/new.rs b/src/dev/new.rs index 154cd224..ba3517f5 100644 --- a/src/dev/new.rs +++ b/src/dev/new.rs @@ -1,4 +1,4 @@ -use anyhow::{bail, Context, Result}; +use anyhow::{Context, Result, bail}; use std::{ env::set_current_dir, fs::{self, create_dir}, @@ -6,7 +6,7 @@ use std::{ process::Command, }; -use crate::{init::RUST_ANALYZER_TOML, CURRENT_FORMAT_VERSION}; +use crate::{CURRENT_FORMAT_VERSION, init::RUST_ANALYZER_TOML}; // Create a directory relative to the current directory and print its path. fn create_rel_dir(dir_name: &str, current_dir: &str) -> Result<()> { @@ -55,7 +55,9 @@ pub fn new(path: &Path, no_git: bool) -> Result<()> { write_rel_file( "info.toml", &dir_path_str, - format!("{INFO_FILE_BEFORE_FORMAT_VERSION}{CURRENT_FORMAT_VERSION}{INFO_FILE_AFTER_FORMAT_VERSION}"), + format!( + "{INFO_FILE_BEFORE_FORMAT_VERSION}{CURRENT_FORMAT_VERSION}{INFO_FILE_AFTER_FORMAT_VERSION}" + ), )?; write_rel_file("Cargo.toml", &dir_path_str, CARGO_TOML)?; @@ -130,7 +132,7 @@ bin = [] [package] name = "exercises" -edition = "2021" +edition = "2024" # Don't publish the exercises on crates.io! publish = false diff --git a/src/exercise.rs b/src/exercise.rs index 84908284..fdfbc4f6 100644 --- a/src/exercise.rs +++ b/src/exercise.rs @@ -1,13 +1,13 @@ use anyhow::Result; use crossterm::{ - style::{Attribute, Color, ResetColor, SetAttribute, SetForegroundColor}, QueueableCommand, + style::{Attribute, Color, ResetColor, SetAttribute, SetForegroundColor}, }; use std::io::{self, StdoutLock, Write}; use crate::{ cmd::CmdRunner, - term::{self, terminal_file_link, write_ansi, CountedWrite}, + term::{self, CountedWrite, terminal_file_link, write_ansi}, }; /// The initial capacity of the output buffer. diff --git a/src/info_file.rs b/src/info_file.rs index fdc8f0f3..ec61f8ad 100644 --- a/src/info_file.rs +++ b/src/info_file.rs @@ -1,4 +1,4 @@ -use anyhow::{bail, Context, Error, Result}; +use anyhow::{Context, Error, Result, bail}; use serde::Deserialize; use std::{fs, io::ErrorKind}; diff --git a/src/init.rs b/src/init.rs index ce49bb65..208425c2 100644 --- a/src/init.rs +++ b/src/init.rs @@ -1,7 +1,7 @@ -use anyhow::{bail, Context, Result}; +use anyhow::{Context, Result, bail}; use crossterm::{ - style::{Attribute, Color, ResetColor, SetAttribute, SetForegroundColor}, QueueableCommand, + style::{Attribute, Color, ResetColor, SetAttribute, SetForegroundColor}, }; use serde::Deserialize; use std::{ @@ -57,7 +57,9 @@ pub fn init() -> Result<()> { if !workspace_manifest_content.contains("[workspace]\n") && !workspace_manifest_content.contains("workspace.") { - bail!("The current directory is already part of a Cargo project.\nPlease initialize Rustlings in a different directory"); + bail!( + "The current directory is already part of a Cargo project.\nPlease 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 ")?; @@ -75,7 +77,9 @@ pub fn init() -> Result<()> { .stdout(Stdio::null()) .status()?; if !status.success() { - bail!("Failed to initialize a new Cargo workspace member.\nPlease initialize Rustlings in a different directory"); + bail!( + "Failed to initialize a new Cargo workspace member.\nPlease initialize Rustlings in a different directory" + ); } stdout.write_all(b"The directory `rustlings` has been added to `workspace.members` in the `Cargo.toml` file of this Cargo workspace.\n")?; diff --git a/src/list.rs b/src/list.rs index 9f243a17..a2eee9e1 100644 --- a/src/list.rs +++ b/src/list.rs @@ -1,14 +1,13 @@ use anyhow::{Context, Result}; use crossterm::{ - cursor, + QueueableCommand, cursor, event::{ self, DisableMouseCapture, EnableMouseCapture, Event, KeyCode, KeyEventKind, MouseEventKind, }, terminal::{ - disable_raw_mode, enable_raw_mode, DisableLineWrap, EnableLineWrap, EnterAlternateScreen, - LeaveAlternateScreen, + DisableLineWrap, EnableLineWrap, EnterAlternateScreen, LeaveAlternateScreen, + disable_raw_mode, enable_raw_mode, }, - QueueableCommand, }; use std::io::{self, StdoutLock, Write}; diff --git a/src/list/state.rs b/src/list/state.rs index 0670fa46..ae65ec2b 100644 --- a/src/list/state.rs +++ b/src/list/state.rs @@ -1,11 +1,11 @@ use anyhow::{Context, Result}; use crossterm::{ + QueueableCommand, cursor::{MoveTo, MoveToNextLine}, style::{ Attribute, Attributes, Color, ResetColor, SetAttribute, SetAttributes, SetForegroundColor, }, terminal::{self, BeginSynchronizedUpdate, Clear, ClearType, EndSynchronizedUpdate}, - QueueableCommand, }; use std::{ fmt::Write as _, @@ -15,7 +15,7 @@ use std::{ use crate::{ app_state::AppState, exercise::Exercise, - term::{progress_bar, CountedWrite, MaxLenWriter}, + term::{CountedWrite, MaxLenWriter, progress_bar}, }; use super::scroll_state::ScrollState; diff --git a/src/main.rs b/src/main.rs index eeb1883e..6688e3e6 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,4 +1,4 @@ -use anyhow::{bail, Context, Result}; +use anyhow::{Context, Result, bail}; use app_state::StateFileStatus; use clap::{Parser, Subcommand}; use std::{ diff --git a/src/run.rs b/src/run.rs index ac8b26ad..6f4f099b 100644 --- a/src/run.rs +++ b/src/run.rs @@ -1,7 +1,7 @@ use anyhow::Result; use crossterm::{ - style::{Color, ResetColor, SetForegroundColor}, QueueableCommand, + style::{Color, ResetColor, SetForegroundColor}, }; use std::{ io::{self, Write}, @@ -10,7 +10,7 @@ use std::{ use crate::{ app_state::{AppState, ExercisesProgress}, - exercise::{solution_link_line, RunnableExercise, OUTPUT_CAPACITY}, + exercise::{OUTPUT_CAPACITY, RunnableExercise, solution_link_line}, }; pub fn run(app_state: &mut AppState) -> Result { diff --git a/src/term.rs b/src/term.rs index cb0a07ce..1e08c84f 100644 --- a/src/term.rs +++ b/src/term.rs @@ -1,8 +1,8 @@ use crossterm::{ + Command, QueueableCommand, cursor::MoveTo, style::{Attribute, Color, ResetColor, SetAttribute, SetForegroundColor}, terminal::{Clear, ClearType}, - Command, QueueableCommand, }; use std::{ fmt, fs, diff --git a/src/watch/notify_event.rs b/src/watch/notify_event.rs index 2051e544..9c05f10d 100644 --- a/src/watch/notify_event.rs +++ b/src/watch/notify_event.rs @@ -1,18 +1,18 @@ use anyhow::{Context, Result}; use notify::{ - event::{AccessKind, AccessMode, MetadataKind, ModifyKind, RenameMode}, Event, EventKind, + event::{AccessKind, AccessMode, MetadataKind, ModifyKind, RenameMode}, }; use std::{ sync::{ atomic::Ordering::Relaxed, - mpsc::{sync_channel, RecvTimeoutError, Sender, SyncSender}, + mpsc::{RecvTimeoutError, Sender, SyncSender, sync_channel}, }, thread, time::Duration, }; -use super::{WatchEvent, EXERCISE_RUNNING}; +use super::{EXERCISE_RUNNING, WatchEvent}; const DEBOUNCE_DURATION: Duration = Duration::from_millis(200); diff --git a/src/watch/state.rs b/src/watch/state.rs index 5263bc57..2413becd 100644 --- a/src/watch/state.rs +++ b/src/watch/state.rs @@ -1,24 +1,25 @@ use anyhow::{Context, Result}; use crossterm::{ + QueueableCommand, style::{ Attribute, Attributes, Color, ResetColor, SetAttribute, SetAttributes, SetForegroundColor, }, - terminal, QueueableCommand, + terminal, }; use std::{ io::{self, Read, StdoutLock, Write}, - sync::mpsc::{sync_channel, Sender, SyncSender}, + sync::mpsc::{Sender, SyncSender, sync_channel}, thread, }; use crate::{ app_state::{AppState, ExercisesProgress}, clear_terminal, - exercise::{solution_link_line, RunnableExercise, OUTPUT_CAPACITY}, + exercise::{OUTPUT_CAPACITY, RunnableExercise, solution_link_line}, term::progress_bar, }; -use super::{terminal_event::terminal_event_handler, InputPauseGuard, WatchEvent}; +use super::{InputPauseGuard, WatchEvent, terminal_event::terminal_event_handler}; const HEADING_ATTRIBUTES: Attributes = Attributes::none() .with(Attribute::Bold) diff --git a/src/watch/terminal_event.rs b/src/watch/terminal_event.rs index 48411db0..2400a3df 100644 --- a/src/watch/terminal_event.rs +++ b/src/watch/terminal_event.rs @@ -4,7 +4,7 @@ use std::sync::{ mpsc::{Receiver, Sender}, }; -use super::{WatchEvent, EXERCISE_RUNNING}; +use super::{EXERCISE_RUNNING, WatchEvent}; pub enum InputEvent { Next, diff --git a/tests/test_exercises/dev/Cargo.toml b/tests/test_exercises/dev/Cargo.toml index 01fe7c10..74dcc20a 100644 --- a/tests/test_exercises/dev/Cargo.toml +++ b/tests/test_exercises/dev/Cargo.toml @@ -7,5 +7,5 @@ bin = [ [package] name = "test_exercises" -edition = "2021" +edition = "2024" publish = false From a56ccb6f4ff168803b44b975a257acb028a82cad Mon Sep 17 00:00:00 2001 From: mo8it Date: Tue, 18 Feb 2025 20:12:23 +0100 Subject: [PATCH 033/120] Fix new Clippy lint --- src/cargo_toml.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cargo_toml.rs b/src/cargo_toml.rs index 8d417ffa..e966809f 100644 --- a/src/cargo_toml.rs +++ b/src/cargo_toml.rs @@ -74,13 +74,13 @@ pub fn updated_cargo_toml( let (bins_start_ind, bins_end_ind) = bins_start_end_ind(current_cargo_toml)?; let mut updated_cargo_toml = Vec::with_capacity(BINS_BUFFER_CAPACITY); - updated_cargo_toml.extend_from_slice(current_cargo_toml[..bins_start_ind].as_bytes()); + updated_cargo_toml.extend_from_slice(¤t_cargo_toml.as_bytes()[..bins_start_ind]); append_bins( &mut updated_cargo_toml, exercise_infos, exercise_path_prefix, ); - updated_cargo_toml.extend_from_slice(current_cargo_toml[bins_end_ind..].as_bytes()); + updated_cargo_toml.extend_from_slice(¤t_cargo_toml.as_bytes()[bins_end_ind..]); Ok(updated_cargo_toml) } From 65dc019fa6a5fe7518fcb77f1f076dfc5b8d9f1b Mon Sep 17 00:00:00 2001 From: mo8it Date: Tue, 18 Feb 2025 20:15:28 +0100 Subject: [PATCH 034/120] Fix new Clippy error in solution --- solutions/13_error_handling/errors2.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/solutions/13_error_handling/errors2.rs b/solutions/13_error_handling/errors2.rs index 0597c8c9..f0e144e7 100644 --- a/solutions/13_error_handling/errors2.rs +++ b/solutions/13_error_handling/errors2.rs @@ -16,7 +16,7 @@ use std::num::ParseIntError; -#[allow(unused_variables)] +#[allow(unused_variables, clippy::question_mark)] fn total_cost(item_quantity: &str) -> Result { let processing_fee = 1; let cost_per_item = 5; From 06af3ffc99f803f3be349bbb88bb0ce3b31982e0 Mon Sep 17 00:00:00 2001 From: mo8it Date: Tue, 18 Feb 2025 20:17:27 +0100 Subject: [PATCH 035/120] Bump MSRV in release hook --- release-hook.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/release-hook.sh b/release-hook.sh index 8da5636d..db3d86ee 100755 --- a/release-hook.sh +++ b/release-hook.sh @@ -13,4 +13,4 @@ cargo test --workspace --all-targets cargo run -- dev check --require-solutions # MSRV -cargo +1.80 run -- dev check --require-solutions +cargo +1.85 run -- dev check --require-solutions From 1eb6c1e469de2492d823d4739114d8a85cd6660b Mon Sep 17 00:00:00 2001 From: mo8it Date: Fri, 21 Feb 2025 13:06:11 +0100 Subject: [PATCH 036/120] Update the edition of the solution format checker --- Cargo.toml | 2 +- src/dev/check.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index e9b29eca..a3b1d0d7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -15,7 +15,7 @@ authors = [ ] repository = "https://github.com/rust-lang/rustlings" license = "MIT" -edition = "2024" # On Update: Update the edition of the `rustfmt` command that checks the solutions. +edition = "2024" # On Update: Update the edition of `rustfmt` in `dev check` and `CARGO_TOML` in `dev new`. rust-version = "1.85" [workspace.dependencies] diff --git a/src/dev/check.rs b/src/dev/check.rs index aacc2f44..c89c4eb2 100644 --- a/src/dev/check.rs +++ b/src/dev/check.rs @@ -313,7 +313,7 @@ fn check_solutions( fmt_cmd .arg("--check") .arg("--edition") - .arg("2021") + .arg("2024") .arg("--color") .arg("always") .stdin(Stdio::null()); From 374c3874afcd01ed0c88047589967d568ceac49f Mon Sep 17 00:00:00 2001 From: mo8it Date: Fri, 21 Feb 2025 13:08:34 +0100 Subject: [PATCH 037/120] Apply 2024 edition formatting to solutions --- solutions/03_if/if1.rs | 6 +----- solutions/11_hashmaps/hashmaps3.rs | 8 +++++--- solutions/16_lifetimes/lifetimes1.rs | 6 +----- solutions/16_lifetimes/lifetimes2.rs | 6 +----- solutions/quizzes/quiz2.rs | 2 +- 5 files changed, 9 insertions(+), 19 deletions(-) diff --git a/solutions/03_if/if1.rs b/solutions/03_if/if1.rs index 079c6715..8512a60f 100644 --- a/solutions/03_if/if1.rs +++ b/solutions/03_if/if1.rs @@ -1,9 +1,5 @@ fn bigger(a: i32, b: i32) -> i32 { - if a > b { - a - } else { - b - } + if a > b { a } else { b } } fn main() { diff --git a/solutions/11_hashmaps/hashmaps3.rs b/solutions/11_hashmaps/hashmaps3.rs index 433b16c3..485bf830 100644 --- a/solutions/11_hashmaps/hashmaps3.rs +++ b/solutions/11_hashmaps/hashmaps3.rs @@ -60,9 +60,11 @@ England,Spain,1,0"; fn build_scores() { let scores = build_scores_table(RESULTS); - assert!(["England", "France", "Germany", "Italy", "Poland", "Spain"] - .into_iter() - .all(|team_name| scores.contains_key(team_name))); + assert!( + ["England", "France", "Germany", "Italy", "Poland", "Spain"] + .into_iter() + .all(|team_name| scores.contains_key(team_name)) + ); } #[test] diff --git a/solutions/16_lifetimes/lifetimes1.rs b/solutions/16_lifetimes/lifetimes1.rs index ca7b688d..4f56834f 100644 --- a/solutions/16_lifetimes/lifetimes1.rs +++ b/solutions/16_lifetimes/lifetimes1.rs @@ -5,11 +5,7 @@ fn longest<'a>(x: &'a str, y: &'a str) -> &'a str { // ^^^^ ^^ ^^ ^^ - if x.len() > y.len() { - x - } else { - y - } + if x.len() > y.len() { x } else { y } } fn main() { diff --git a/solutions/16_lifetimes/lifetimes2.rs b/solutions/16_lifetimes/lifetimes2.rs index b0f2ef1f..3ca49093 100644 --- a/solutions/16_lifetimes/lifetimes2.rs +++ b/solutions/16_lifetimes/lifetimes2.rs @@ -1,9 +1,5 @@ fn longest<'a>(x: &'a str, y: &'a str) -> &'a str { - if x.len() > y.len() { - x - } else { - y - } + if x.len() > y.len() { x } else { y } } fn main() { diff --git a/solutions/quizzes/quiz2.rs b/solutions/quizzes/quiz2.rs index 58cbe4e2..8b073b18 100644 --- a/solutions/quizzes/quiz2.rs +++ b/solutions/quizzes/quiz2.rs @@ -62,8 +62,8 @@ mod tests { // Import `transformer`. use super::my_module::transformer; - use super::my_module::transformer_iter; use super::Command; + use super::my_module::transformer_iter; #[test] fn it_works() { From 46c6fb2c82d632a9b635ce74d4ef4292e3e0e90f Mon Sep 17 00:00:00 2001 From: mo8it Date: Tue, 25 Feb 2025 11:21:19 +0100 Subject: [PATCH 038/120] Update deps --- Cargo.lock | 46 +++++++++++++++++++++++----------------------- Cargo.toml | 8 ++++---- 2 files changed, 27 insertions(+), 27 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 3c340b64..3eaf2dc8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1,6 +1,6 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. -version = 3 +version = 4 [[package]] name = "anstream" @@ -54,9 +54,9 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.95" +version = "1.0.96" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "34ac096ce696dc2fcabef30516bb13c0a68a11d30131d3df6f04711467681b04" +checksum = "6b964d184e89d9b6b67dd2715bc8e74cf3107fb2b529990c90cf517326150bf4" [[package]] name = "autocfg" @@ -84,9 +84,9 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "clap" -version = "4.5.30" +version = "4.5.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "92b7b18d71fad5313a1e320fa9897994228ce274b60faa4d694fe0ea89cd9e6d" +checksum = "027bb0d98429ae334a8698531da7077bdf906419543a35a55c2cb1b66437d767" dependencies = [ "clap_builder", "clap_derive", @@ -94,9 +94,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.5.30" +version = "4.5.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a35db2071778a7344791a4fb4f95308b5673d219dee3ae348b86642574ecc90c" +checksum = "5589e0cba072e0f3d23791efac0fd8627b49c829c196a492e88168e6a669d863" dependencies = [ "anstream", "anstyle", @@ -284,9 +284,9 @@ dependencies = [ [[package]] name = "libc" -version = "0.2.169" +version = "0.2.170" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5aba8db14291edd000dfcc4d620c7ebfb122c613afb886ca8803fa4e128a20a" +checksum = "875b3680cb2f8f71bdcf9a30f38d48282f5d3c95cbf9b3fa57269bb5d5c06828" [[package]] name = "libredox" @@ -317,9 +317,9 @@ dependencies = [ [[package]] name = "log" -version = "0.4.25" +version = "0.4.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "04cbf5b083de1c7e0222a7a51dbfdba1cbe1c6ab0b15e29fff3f6c077fd9cd9f" +checksum = "30bde2b3dc3671ae49d8e2e9f044c7c005836e7a023ee57cffa25ab82764bb9e" [[package]] name = "memchr" @@ -423,9 +423,9 @@ dependencies = [ [[package]] name = "redox_syscall" -version = "0.5.8" +version = "0.5.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "03a862b389f93e68874fbf580b9de08dd02facb9a788ebadaf4a3fd33cf58834" +checksum = "82b568323e98e49e2a0899dcee453dd679fae22d69adf9b11dd508d1549b7e2f" dependencies = [ "bitflags 2.8.0", ] @@ -492,18 +492,18 @@ checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" [[package]] name = "serde" -version = "1.0.217" +version = "1.0.218" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "02fc4265df13d6fa1d00ecff087228cc0a2b5f3c0e87e258d8b94a156e984c70" +checksum = "e8dfc9d19bdbf6d17e22319da49161d5d0108e4188e8b680aef6299eed22df60" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.217" +version = "1.0.218" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a9bf7cf98d04a2b28aead066b7496853d4779c9cc183c440dbac457641e19a0" +checksum = "f09503e191f4e797cb8aac08e9a4a4695c5edf6a2e70e376d961ddd5c969f82b" dependencies = [ "proc-macro2", "quote", @@ -512,9 +512,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.138" +version = "1.0.139" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d434192e7da787e94a6ea7e9670b26a036d0ca41e0b7efb2676dd32bae872949" +checksum = "44f86c3acccc9c65b153fe1b85a3be07fe5515274ec9f0653b4a0875731c72a6" dependencies = [ "itoa", "memchr", @@ -622,9 +622,9 @@ dependencies = [ [[package]] name = "unicode-ident" -version = "1.0.16" +version = "1.0.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a210d160f08b701c8721ba1c726c11662f877ea6b7094007e1ca9a1041945034" +checksum = "00e2473a93778eb0bad35909dff6a10d28e63f792f16ed15e404fca9d5eeedbe" [[package]] name = "utf8parse" @@ -772,9 +772,9 @@ checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" [[package]] name = "winnow" -version = "0.7.2" +version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "59690dea168f2198d1a3b0cac23b8063efcd11012f10ae4698f284808c8ef603" +checksum = "0e7f4ea97f6f78012141bcdb6a216b2609f0979ada50b20ca5b52dde2eac2bb1" dependencies = [ "memchr", ] diff --git a/Cargo.toml b/Cargo.toml index a3b1d0d7..693d9fde 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -19,7 +19,7 @@ edition = "2024" # On Update: Update the edition of `rustfmt` in `dev check` and rust-version = "1.85" [workspace.dependencies] -serde = { version = "1.0.217", features = ["derive"] } +serde = { version = "1.0.218", features = ["derive"] } toml_edit = { version = "0.22.24", default-features = false, features = ["parse", "serde"] } [package] @@ -46,13 +46,13 @@ include = [ ] [dependencies] -anyhow = "1.0.95" -clap = { version = "4.5.30", features = ["derive"] } +anyhow = "1.0.96" +clap = { version = "4.5.31", features = ["derive"] } crossterm = { version = "0.28.1", default-features = false, features = ["windows", "events"] } notify = "8.0.0" os_pipe = "1.2.1" rustlings-macros = { path = "rustlings-macros", version = "=6.4.0" } -serde_json = "1.0.138" +serde_json = "1.0.139" serde.workspace = true toml_edit.workspace = true From 425c9821e0ef2d69f5b59750a8fc444165d64689 Mon Sep 17 00:00:00 2001 From: Peter Neave Date: Fri, 28 Feb 2025 11:46:39 +1100 Subject: [PATCH 039/120] Use consistent apostrophes in markdown files --- exercises/01_variables/README.md | 2 +- exercises/08_enums/README.md | 2 +- exercises/13_error_handling/README.md | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/exercises/01_variables/README.md b/exercises/01_variables/README.md index 7964ff29..5ba2efca 100644 --- a/exercises/01_variables/README.md +++ b/exercises/01_variables/README.md @@ -1,7 +1,7 @@ # Variables In Rust, variables are immutable by default. -When a variable is immutable, once a value is bound to a name, you can’t change that value. +When a variable is immutable, once a value is bound to a name, you can't change that value. You can make them mutable by adding `mut` in front of the variable name. ## Further information diff --git a/exercises/08_enums/README.md b/exercises/08_enums/README.md index 30d4d91d..2ca95e6c 100644 --- a/exercises/08_enums/README.md +++ b/exercises/08_enums/README.md @@ -1,7 +1,7 @@ # Enums Rust allows you to define types called "enums" which enumerate possible values. -Enums are a feature in many languages, but their capabilities differ in each language. Rust’s enums are most similar to algebraic data types in functional languages, such as F#, OCaml, and Haskell. +Enums are a feature in many languages, but their capabilities differ in each language. Rust's enums are most similar to algebraic data types in functional languages, such as F#, OCaml, and Haskell. Useful in combination with enums is Rust's "pattern matching" facility, which makes it easy to run different code for different values of an enumeration. ## Further information diff --git a/exercises/13_error_handling/README.md b/exercises/13_error_handling/README.md index 3b21f2b7..9b6674bc 100644 --- a/exercises/13_error_handling/README.md +++ b/exercises/13_error_handling/README.md @@ -1,8 +1,8 @@ # Error handling -Most errors aren’t serious enough to require the program to stop entirely. -Sometimes, when a function fails, it’s for a reason that you can easily interpret and respond to. -For example, if you try to open a file and that operation fails because the file doesn’t exist, you might want to create the file instead of terminating the process. +Most errors aren't serious enough to require the program to stop entirely. +Sometimes, when a function fails, it's for a reason that you can easily interpret and respond to. +For example, if you try to open a file and that operation fails because the file doesn't exist, you might want to create the file instead of terminating the process. ## Further information From fcd77a83ccb557d68c3224c8d705889f891a06de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ricardo=20Fern=C3=A1ndez=20Serrata?= <76864299+Rudxain@users.noreply.github.com> Date: Fri, 7 Mar 2025 19:17:11 -0400 Subject: [PATCH 040/120] test trim idempotence --- exercises/09_strings/strings3.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/exercises/09_strings/strings3.rs b/exercises/09_strings/strings3.rs index 39fce18c..f5e45b0f 100644 --- a/exercises/09_strings/strings3.rs +++ b/exercises/09_strings/strings3.rs @@ -23,6 +23,7 @@ mod tests { assert_eq!(trim_me("Hello! "), "Hello!"); assert_eq!(trim_me(" What's up!"), "What's up!"); assert_eq!(trim_me(" Hola! "), "Hola!"); + assert_eq!(trim_me("Hi!"), "Hi!"); } #[test] From 7019f4d1783e9b20ff6c9225a173490985d2658e Mon Sep 17 00:00:00 2001 From: mo8it Date: Fri, 14 Mar 2025 11:33:37 +0100 Subject: [PATCH 041/120] Update pipeline --- .github/workflows/rust.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 80f052d6..9a5d8693 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -22,22 +22,22 @@ jobs: - uses: DavidAnson/markdownlint-cli2-action@v16 with: globs: "exercises/**/*.md" - - name: Run cargo fmt + - name: rustfmt run: cargo fmt --all --check test: runs-on: ${{ matrix.os }} strategy: matrix: - os: [ubuntu-latest, windows-latest, macOS-latest] + os: [ubuntu-latest, windows-latest, macos-latest] steps: - uses: actions/checkout@v4 - uses: swatinem/rust-cache@v2 - - name: Run cargo test + - name: cargo test run: cargo test --workspace dev-check: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - uses: swatinem/rust-cache@v2 - - name: Run rustlings dev check + - name: rustlings dev check run: cargo run -- dev check --require-solutions From 8db85946af22ccbcbcca1432acfb73036bd2a099 Mon Sep 17 00:00:00 2001 From: mo8it Date: Fri, 14 Mar 2025 11:33:45 +0100 Subject: [PATCH 042/120] Update deps --- Cargo.lock | 122 ++++++++++++++++++++++++++++++----------------------- Cargo.toml | 12 +++--- 2 files changed, 76 insertions(+), 58 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 3eaf2dc8..f5b19d7b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -54,9 +54,9 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.96" +version = "1.0.97" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6b964d184e89d9b6b67dd2715bc8e74cf3107fb2b529990c90cf517326150bf4" +checksum = "dcfed56ad506cb2c684a14971b8861fdc3baaaae314b9e5f9bb532cbe3ba7a4f" [[package]] name = "autocfg" @@ -72,9 +72,9 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] name = "bitflags" -version = "2.8.0" +version = "2.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f68f53c83ab957f72c32642f3868eec03eb974d1fb82e453128456482613d36" +checksum = "5c8214115b7bf84099f1309324e63141d4c5d7cc26862f97a0a857dbefe165bd" [[package]] name = "cfg-if" @@ -84,9 +84,9 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "clap" -version = "4.5.31" +version = "4.5.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "027bb0d98429ae334a8698531da7077bdf906419543a35a55c2cb1b66437d767" +checksum = "6088f3ae8c3608d19260cd7445411865a485688711b78b5be70d78cd96136f83" dependencies = [ "clap_builder", "clap_derive", @@ -94,9 +94,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.5.31" +version = "4.5.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5589e0cba072e0f3d23791efac0fd8627b49c829c196a492e88168e6a669d863" +checksum = "22a7ef7f676155edfb82daa97f99441f3ebf4a58d5e32f295a56259f1b6facc8" dependencies = [ "anstream", "anstyle", @@ -106,9 +106,9 @@ dependencies = [ [[package]] name = "clap_derive" -version = "4.5.28" +version = "4.5.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bf4ced95c6f4a675af3da73304b9ac4ed991640c36374e4b46795c49e17cf1ed" +checksum = "09176aae279615badda0765c0c0b3f6ed53f4709118af73cf4655d85d1530cd7" dependencies = [ "heck", "proc-macro2", @@ -134,11 +134,11 @@ version = "0.28.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "829d955a0bb380ef178a640b91779e3987da38c9aea133b20614cfed8cdea9c6" dependencies = [ - "bitflags 2.8.0", + "bitflags 2.9.0", "crossterm_winapi", "mio", "parking_lot", - "rustix", + "rustix 0.38.44", "signal-hook", "signal-hook-mio", "winapi", @@ -222,9 +222,9 @@ checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" [[package]] name = "indexmap" -version = "2.7.1" +version = "2.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c9c992b02b5b4c94ea26e32fe5bccb7aa7d9f390ab5c1221ff895bc7ea8b652" +checksum = "3954d50fe15b02142bf25d3b8bdadb634ec3948f103d04ffe3031bc8fe9d7058" dependencies = [ "equivalent", "hashbrown", @@ -236,7 +236,7 @@ version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f37dccff2791ab604f9babef0ba14fbe0be30bd368dc541e2b08d07c8aa908f3" dependencies = [ - "bitflags 2.8.0", + "bitflags 2.9.0", "inotify-sys", "libc", ] @@ -258,9 +258,9 @@ checksum = "7943c866cc5cd64cbc25b2e01621d07fa8eb2a1a23160ee81ce38704e97b8ecf" [[package]] name = "itoa" -version = "1.0.14" +version = "1.0.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d75a2a4b1b190afb6f5425f10f6a8f959d2ea0b9c2b1d79553551850539e4674" +checksum = "4a5f13b858c8d314ee3e8f639011f7ccefe71f97f96e50151fb991f267928e2c" [[package]] name = "kqueue" @@ -284,9 +284,9 @@ dependencies = [ [[package]] name = "libc" -version = "0.2.170" +version = "0.2.171" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "875b3680cb2f8f71bdcf9a30f38d48282f5d3c95cbf9b3fa57269bb5d5c06828" +checksum = "c19937216e9d3aa9956d9bb8dfc0b0c8beb6058fc4f7a4dc4d850edf86a237d6" [[package]] name = "libredox" @@ -294,7 +294,7 @@ version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c0ff37bd590ca25063e35af745c343cb7a0271906fb7b37e4813e8f79f00268d" dependencies = [ - "bitflags 2.8.0", + "bitflags 2.9.0", "libc", "redox_syscall", ] @@ -305,6 +305,12 @@ version = "0.4.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d26c52dbd32dccf2d10cac7725f8eae5296885fb5703b261f7d0a0739ec807ab" +[[package]] +name = "linux-raw-sys" +version = "0.9.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6db9c683daf087dc577b7506e9695b3d556a9f3849903fa28186283afd6809e9" + [[package]] name = "lock_api" version = "0.4.12" @@ -345,7 +351,7 @@ version = "8.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2fee8403b3d66ac7b26aee6e40a897d85dc5ce26f44da36b8b73e987cc52e943" dependencies = [ - "bitflags 2.8.0", + "bitflags 2.9.0", "filetime", "fsevent-sys", "inotify", @@ -366,9 +372,9 @@ checksum = "5e0826a989adedc2a244799e823aece04662b66609d96af8dff7ac6df9a8925d" [[package]] name = "once_cell" -version = "1.20.3" +version = "1.21.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "945462a4b81e43c4e3ba96bd7b49d834c6f61198356aa858733bc4acf3cbe62e" +checksum = "d75b0bedcc4fe52caa0e03d9f1151a323e4aa5e2d78ba3580400cd3c9e2bc4bc" [[package]] name = "os_pipe" @@ -405,29 +411,29 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.93" +version = "1.0.94" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "60946a68e5f9d28b0dc1c21bb8a97ee7d018a8b322fa57838ba31cc878e22d99" +checksum = "a31971752e70b8b2686d7e46ec17fb38dad4051d94024c88df49b667caea9c84" dependencies = [ "unicode-ident", ] [[package]] name = "quote" -version = "1.0.38" +version = "1.0.40" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0e4dccaaaf89514f546c693ddc140f729f958c247918a13380cccc6078391acc" +checksum = "1885c039570dc00dcb4ff087a89e185fd56bae234ddc7f056a945bf36467248d" dependencies = [ "proc-macro2", ] [[package]] name = "redox_syscall" -version = "0.5.9" +version = "0.5.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "82b568323e98e49e2a0899dcee453dd679fae22d69adf9b11dd508d1549b7e2f" +checksum = "0b8c0c260b63a8219631167be35e6a988e9554dbd323f8bd08439c8ed1302bd1" dependencies = [ - "bitflags 2.8.0", + "bitflags 2.9.0", ] [[package]] @@ -436,10 +442,23 @@ version = "0.38.44" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fdb5bc1ae2baa591800df16c9ca78619bf65c0488b41b96ccec5d11220d8c154" dependencies = [ - "bitflags 2.8.0", + "bitflags 2.9.0", "errno", "libc", - "linux-raw-sys", + "linux-raw-sys 0.4.15", + "windows-sys 0.59.0", +] + +[[package]] +name = "rustix" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f7178faa4b75a30e269c71e61c353ce2748cf3d76f0c44c393f4e60abf49b825" +dependencies = [ + "bitflags 2.9.0", + "errno", + "libc", + "linux-raw-sys 0.9.2", "windows-sys 0.59.0", ] @@ -452,7 +471,7 @@ dependencies = [ "crossterm", "notify", "os_pipe", - "rustix", + "rustix 1.0.2", "rustlings-macros", "serde", "serde_json", @@ -471,9 +490,9 @@ dependencies = [ [[package]] name = "ryu" -version = "1.0.19" +version = "1.0.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ea1a2d0a644769cc99faa24c3ad26b379b786fe7c36fd3c546254801650e6dd" +checksum = "28d3b2b1366ec20994f1fd18c3c594f05c5dd4bc44d8bb0c1c632c8d6829481f" [[package]] name = "same-file" @@ -492,18 +511,18 @@ checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" [[package]] name = "serde" -version = "1.0.218" +version = "1.0.219" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e8dfc9d19bdbf6d17e22319da49161d5d0108e4188e8b680aef6299eed22df60" +checksum = "5f0e2c6ed6606019b4e29e69dbaba95b11854410e5347d525002456dbbb786b6" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.218" +version = "1.0.219" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f09503e191f4e797cb8aac08e9a4a4695c5edf6a2e70e376d961ddd5c969f82b" +checksum = "5b0276cf7f2c73365f7157c8123c21cd9a50fbbd844757af28ca1f5925fc2a00" dependencies = [ "proc-macro2", "quote", @@ -512,9 +531,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.139" +version = "1.0.140" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "44f86c3acccc9c65b153fe1b85a3be07fe5515274ec9f0653b4a0875731c72a6" +checksum = "20068b6e96dc6c9bd23e01df8827e6c7e1f2fddd43c21810382803c136b99373" dependencies = [ "itoa", "memchr", @@ -575,9 +594,9 @@ checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" [[package]] name = "syn" -version = "2.0.98" +version = "2.0.100" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "36147f1a48ae0ec2b5b3bc5b537d267457555a10dc06f3dbc8cb11ba3006d3b1" +checksum = "b09a44accad81e1ba1cd74a32461ba89dee89095ba17b32f5d03683b1b1fc2a0" dependencies = [ "proc-macro2", "quote", @@ -586,15 +605,14 @@ dependencies = [ [[package]] name = "tempfile" -version = "3.17.1" +version = "3.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22e5a0acb1f3f55f65cc4a866c361b2fb2a0ff6366785ae6fbb5f85df07ba230" +checksum = "488960f40a3fd53d72c2a29a58722561dee8afdd175bd88e3db4677d7b2ba600" dependencies = [ - "cfg-if", "fastrand", "getrandom", "once_cell", - "rustix", + "rustix 1.0.2", "windows-sys 0.59.0", ] @@ -622,9 +640,9 @@ dependencies = [ [[package]] name = "unicode-ident" -version = "1.0.17" +version = "1.0.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "00e2473a93778eb0bad35909dff6a10d28e63f792f16ed15e404fca9d5eeedbe" +checksum = "5a5f39404a5da50712a4c1eecf25e90dd62b613502b7e925fd4e4d19b5c96512" [[package]] name = "utf8parse" @@ -772,9 +790,9 @@ checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" [[package]] name = "winnow" -version = "0.7.3" +version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0e7f4ea97f6f78012141bcdb6a216b2609f0979ada50b20ca5b52dde2eac2bb1" +checksum = "0e97b544156e9bebe1a0ffbc03484fc1ffe3100cbce3ffb17eac35f7cdd7ab36" dependencies = [ "memchr", ] @@ -785,5 +803,5 @@ version = "0.33.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3268f3d866458b787f390cf61f4bbb563b922d091359f9608842999eaee3943c" dependencies = [ - "bitflags 2.8.0", + "bitflags 2.9.0", ] diff --git a/Cargo.toml b/Cargo.toml index 693d9fde..c7c277ce 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -19,7 +19,7 @@ edition = "2024" # On Update: Update the edition of `rustfmt` in `dev check` and rust-version = "1.85" [workspace.dependencies] -serde = { version = "1.0.218", features = ["derive"] } +serde = { version = "1.0.219", features = ["derive"] } toml_edit = { version = "0.22.24", default-features = false, features = ["parse", "serde"] } [package] @@ -46,21 +46,21 @@ include = [ ] [dependencies] -anyhow = "1.0.96" -clap = { version = "4.5.31", features = ["derive"] } +anyhow = "1.0.97" +clap = { version = "4.5.32", features = ["derive"] } crossterm = { version = "0.28.1", default-features = false, features = ["windows", "events"] } notify = "8.0.0" os_pipe = "1.2.1" rustlings-macros = { path = "rustlings-macros", version = "=6.4.0" } -serde_json = "1.0.139" +serde_json = "1.0.140" serde.workspace = true toml_edit.workspace = true [target.'cfg(not(windows))'.dependencies] -rustix = { version = "0.38.44", default-features = false, features = ["std", "stdio", "termios"] } +rustix = { version = "1.0.2", default-features = false, features = ["std", "stdio", "termios"] } [dev-dependencies] -tempfile = "3.17.1" +tempfile = "3.19.0" [profile.release] panic = "abort" From 7c0d269279aaed64d6b8240ed5c1e9f6a981181e Mon Sep 17 00:00:00 2001 From: mo8it Date: Fri, 14 Mar 2025 11:42:16 +0100 Subject: [PATCH 043/120] Update README --- README.md | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 3118451f..3e6d6c7c 100644 --- a/README.md +++ b/README.md @@ -21,12 +21,13 @@ Before installing Rustlings, you need to have the **latest version of Rust** ins Visit [www.rust-lang.org/tools/install](https://www.rust-lang.org/tools/install) for further instructions on installing Rust. This will also install _Cargo_, Rust's package/project manager. -> 🐧 If you're on Linux, make sure you've installed `gcc` (for a linker). +> 🐧 If you are on Linux, make sure you have installed `gcc` (for a linker). > -> Deb: `sudo apt install gcc`. -> Dnf: `sudo dnf install gcc`. +> Deb: `sudo apt install gcc` +> +> Dnf: `sudo dnf install gcc` -> 🍎 If you're on MacOS, make sure you've installed Xcode and its developer tools by running `xcode-select --install`. +> 🍎 If you are on MacOS, make sure you have installed Xcode and its developer tools by running `xcode-select --install`. ### Installing Rustlings @@ -102,7 +103,7 @@ Ask for hints by entering `h` in the _watch mode_ 💡 ### Watch Mode -After [initialization](#initialization), Rustlings can be launched by simply running the command `rustlings`. +After the [initialization](#initialization), Rustlings can be launched by simply running the command `rustlings`. This will start the _watch mode_ which walks you through the exercises in a predefined order (what we think is best for newcomers). It will rerun the current exercise automatically every time you change the exercise's file in the `exercises/` directory. @@ -161,6 +162,4 @@ cargo uninstall rustlings See [CONTRIBUTING.md](https://github.com/rust-lang/rustlings/blob/main/CONTRIBUTING.md) 🔗 -## Contributors ✨ - -Thanks to [all the wonderful contributors](https://github.com/rust-lang/rustlings/graphs/contributors) 🎉 +Thanks to [all the wonderful contributors](https://github.com/rust-lang/rustlings/graphs/contributors) ✨ From d2abc359cc10c42a94aa680294eeaca2d7c502b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20B=C5=93sch?= Date: Mon, 17 Mar 2025 18:36:13 +0100 Subject: [PATCH 044/120] Remove TODO from 2 solutions --- solutions/06_move_semantics/move_semantics4.rs | 2 -- solutions/19_smart_pointers/rc1.rs | 2 -- 2 files changed, 4 deletions(-) diff --git a/solutions/06_move_semantics/move_semantics4.rs b/solutions/06_move_semantics/move_semantics4.rs index 64fdd9db..1a39d4fc 100644 --- a/solutions/06_move_semantics/move_semantics4.rs +++ b/solutions/06_move_semantics/move_semantics4.rs @@ -4,8 +4,6 @@ fn main() { #[cfg(test)] mod tests { - // TODO: Fix the compiler errors only by reordering the lines in the test. - // Don't add, change or remove any line. #[test] fn move_semantics4() { let mut x = Vec::new(); diff --git a/solutions/19_smart_pointers/rc1.rs b/solutions/19_smart_pointers/rc1.rs index c0a41abf..edf40ebe 100644 --- a/solutions/19_smart_pointers/rc1.rs +++ b/solutions/19_smart_pointers/rc1.rs @@ -63,12 +63,10 @@ mod tests { println!("reference count = {}", Rc::strong_count(&sun)); // 7 references saturn.details(); - // TODO let uranus = Planet::Uranus(Rc::clone(&sun)); println!("reference count = {}", Rc::strong_count(&sun)); // 8 references uranus.details(); - // TODO let neptune = Planet::Neptune(Rc::clone(&sun)); println!("reference count = {}", Rc::strong_count(&sun)); // 9 references neptune.details(); From 3cc7e0377c71080708281c2d8661d20f00a54df6 Mon Sep 17 00:00:00 2001 From: cassian-goode Date: Tue, 25 Mar 2025 09:24:49 -0400 Subject: [PATCH 045/120] Fix typo - errors5.rs Minor typo correction in exercise instructions --- exercises/13_error_handling/errors5.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exercises/13_error_handling/errors5.rs b/exercises/13_error_handling/errors5.rs index 57218351..125779b8 100644 --- a/exercises/13_error_handling/errors5.rs +++ b/exercises/13_error_handling/errors5.rs @@ -6,7 +6,7 @@ // // In short, this particular use case for boxes is for when you want to own a // value and you care only that it is a type which implements a particular -// trait. To do so, The `Box` is declared as of type `Box` where +// trait. To do so, the `Box` is declared as of type `Box` where // `Trait` is the trait the compiler looks for on any value used in that // context. For this exercise, that context is the potential errors which // can be returned in a `Result`. From 9978c17d5fc651ac61a4526d717c7f645bc932f8 Mon Sep 17 00:00:00 2001 From: Hunter Z Date: Mon, 31 Mar 2025 12:58:06 +0800 Subject: [PATCH 046/120] Update README.md Update the URL while add more reference. --- exercises/21_macros/README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/exercises/21_macros/README.md b/exercises/21_macros/README.md index 337816d6..724c8441 100644 --- a/exercises/21_macros/README.md +++ b/exercises/21_macros/README.md @@ -10,5 +10,6 @@ of exercises to Rustlings, but is all about learning to write Macros. ## Further information -- [Macros](https://doc.rust-lang.org/book/ch19-06-macros.html) +- [The Rust Book - Macros](https://doc.rust-lang.org/book/ch20-06-macros.html#macros) - [The Little Book of Rust Macros](https://veykril.github.io/tlborm/) +- [Rust by Example - macro_rules!](https://doc.rust-lang.org/rust-by-example/macros.html) From ecaecc2f76b67d6300dfc789bb4c812d93e1973b Mon Sep 17 00:00:00 2001 From: mo8it Date: Thu, 3 Apr 2025 17:58:27 +0200 Subject: [PATCH 047/120] Update deps --- Cargo.lock | 56 ++++++++++++++++++++----------------- Cargo.toml | 20 ++++++------- rustlings-macros/Cargo.toml | 2 +- 3 files changed, 42 insertions(+), 36 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index f5b19d7b..d534f8e0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -84,9 +84,9 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "clap" -version = "4.5.32" +version = "4.5.35" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6088f3ae8c3608d19260cd7445411865a485688711b78b5be70d78cd96136f83" +checksum = "d8aa86934b44c19c50f87cc2790e19f54f7a67aedb64101c2e1a2e5ecfb73944" dependencies = [ "clap_builder", "clap_derive", @@ -94,9 +94,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.5.32" +version = "4.5.35" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22a7ef7f676155edfb82daa97f99441f3ebf4a58d5e32f295a56259f1b6facc8" +checksum = "2414dbb2dd0695280da6ea9261e327479e9d37b0630f6b53ba2a11c60c679fd9" dependencies = [ "anstream", "anstyle", @@ -198,14 +198,14 @@ dependencies = [ [[package]] name = "getrandom" -version = "0.3.1" +version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "43a49c392881ce6d5c3b8cb70f98717b7c07aabbdff06687b9030dbfbe2725f8" +checksum = "73fea8450eea4bac3940448fb7ae50d91f034f941199fcd9d909a5a07aa455f0" dependencies = [ "cfg-if", "libc", - "wasi 0.13.3+wasi-0.2.2", - "windows-targets", + "r-efi", + "wasi 0.14.2+wasi-0.2.4", ] [[package]] @@ -307,9 +307,9 @@ checksum = "d26c52dbd32dccf2d10cac7725f8eae5296885fb5703b261f7d0a0739ec807ab" [[package]] name = "linux-raw-sys" -version = "0.9.2" +version = "0.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6db9c683daf087dc577b7506e9695b3d556a9f3849903fa28186283afd6809e9" +checksum = "fe7db12097d22ec582439daf8618b8fdd1a7bef6270e9af3b1ebcd30893cf413" [[package]] name = "lock_api" @@ -323,9 +323,9 @@ dependencies = [ [[package]] name = "log" -version = "0.4.26" +version = "0.4.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "30bde2b3dc3671ae49d8e2e9f044c7c005836e7a023ee57cffa25ab82764bb9e" +checksum = "13dc2df351e3202783a1fe0d44375f7295ffb4049267b0f3018346dc122a1d94" [[package]] name = "memchr" @@ -372,9 +372,9 @@ checksum = "5e0826a989adedc2a244799e823aece04662b66609d96af8dff7ac6df9a8925d" [[package]] name = "once_cell" -version = "1.21.1" +version = "1.21.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d75b0bedcc4fe52caa0e03d9f1151a323e4aa5e2d78ba3580400cd3c9e2bc4bc" +checksum = "42f5e15c9953c5e4ccceeb2e7382a716482c34515315f7b03532b8b4e8393d2d" [[package]] name = "os_pipe" @@ -427,6 +427,12 @@ dependencies = [ "proc-macro2", ] +[[package]] +name = "r-efi" +version = "5.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "74765f6d916ee2faa39bc8e68e4f3ed8949b48cccdac59983d287a7cb71ce9c5" + [[package]] name = "redox_syscall" version = "0.5.10" @@ -451,14 +457,14 @@ dependencies = [ [[package]] name = "rustix" -version = "1.0.2" +version = "1.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f7178faa4b75a30e269c71e61c353ce2748cf3d76f0c44c393f4e60abf49b825" +checksum = "d97817398dd4bb2e6da002002db259209759911da105da92bec29ccb12cf58bf" dependencies = [ "bitflags 2.9.0", "errno", "libc", - "linux-raw-sys 0.9.2", + "linux-raw-sys 0.9.3", "windows-sys 0.59.0", ] @@ -471,7 +477,7 @@ dependencies = [ "crossterm", "notify", "os_pipe", - "rustix 1.0.2", + "rustix 1.0.5", "rustlings-macros", "serde", "serde_json", @@ -605,14 +611,14 @@ dependencies = [ [[package]] name = "tempfile" -version = "3.19.0" +version = "3.19.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "488960f40a3fd53d72c2a29a58722561dee8afdd175bd88e3db4677d7b2ba600" +checksum = "7437ac7763b9b123ccf33c338a5cc1bac6f69b45a136c19bdd8a65e3916435bf" dependencies = [ "fastrand", "getrandom", "once_cell", - "rustix 1.0.2", + "rustix 1.0.5", "windows-sys 0.59.0", ] @@ -668,9 +674,9 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] name = "wasi" -version = "0.13.3+wasi-0.2.2" +version = "0.14.2+wasi-0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26816d2e1a4a36a2940b96c5296ce403917633dff8f3440e9b236ed6f6bacad2" +checksum = "9683f9a5a998d873c0d21fcbe3c083009670149a8fab228644b8bd36b2c48cb3" dependencies = [ "wit-bindgen-rt", ] @@ -799,9 +805,9 @@ dependencies = [ [[package]] name = "wit-bindgen-rt" -version = "0.33.0" +version = "0.39.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3268f3d866458b787f390cf61f4bbb563b922d091359f9608842999eaee3943c" +checksum = "6f42320e61fe2cfd34354ecb597f86f413484a798ba44a8ca1165c58d42da6c1" dependencies = [ "bitflags 2.9.0", ] diff --git a/Cargo.toml b/Cargo.toml index c7c277ce..9d9a0f94 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -19,8 +19,8 @@ edition = "2024" # On Update: Update the edition of `rustfmt` in `dev check` and rust-version = "1.85" [workspace.dependencies] -serde = { version = "1.0.219", features = ["derive"] } -toml_edit = { version = "0.22.24", default-features = false, features = ["parse", "serde"] } +serde = { version = "1.0", features = ["derive"] } +toml_edit = { version = "0.22", default-features = false, features = ["parse", "serde"] } [package] name = "rustlings" @@ -46,21 +46,21 @@ include = [ ] [dependencies] -anyhow = "1.0.97" -clap = { version = "4.5.32", features = ["derive"] } -crossterm = { version = "0.28.1", default-features = false, features = ["windows", "events"] } -notify = "8.0.0" -os_pipe = "1.2.1" +anyhow = "1.0" +clap = { version = "4.5", features = ["derive"] } +crossterm = { version = "0.28", default-features = false, features = ["windows", "events"] } +notify = "8.0" +os_pipe = "1.2" rustlings-macros = { path = "rustlings-macros", version = "=6.4.0" } -serde_json = "1.0.140" +serde_json = "1.0" serde.workspace = true toml_edit.workspace = true [target.'cfg(not(windows))'.dependencies] -rustix = { version = "1.0.2", default-features = false, features = ["std", "stdio", "termios"] } +rustix = { version = "1.0", default-features = false, features = ["std", "stdio", "termios"] } [dev-dependencies] -tempfile = "3.19.0" +tempfile = "3.19" [profile.release] panic = "abort" diff --git a/rustlings-macros/Cargo.toml b/rustlings-macros/Cargo.toml index 3ed56a18..1bf6d1b8 100644 --- a/rustlings-macros/Cargo.toml +++ b/rustlings-macros/Cargo.toml @@ -16,7 +16,7 @@ include = [ proc-macro = true [dependencies] -quote = "1.0.37" +quote = "1.0" serde.workspace = true toml_edit.workspace = true From 63d8986f2a6bc97496065d3bac495a77016fd42f Mon Sep 17 00:00:00 2001 From: mo8it Date: Thu, 3 Apr 2025 18:22:55 +0200 Subject: [PATCH 048/120] Update links --- exercises/08_enums/README.md | 2 +- exercises/21_macros/README.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/exercises/08_enums/README.md b/exercises/08_enums/README.md index 2ca95e6c..b05cb422 100644 --- a/exercises/08_enums/README.md +++ b/exercises/08_enums/README.md @@ -7,4 +7,4 @@ Useful in combination with enums is Rust's "pattern matching" facility, which ma ## Further information - [Enums](https://doc.rust-lang.org/book/ch06-00-enums.html) -- [Pattern syntax](https://doc.rust-lang.org/book/ch18-03-pattern-syntax.html) +- [Pattern syntax](https://doc.rust-lang.org/book/ch19-03-pattern-syntax.html) diff --git a/exercises/21_macros/README.md b/exercises/21_macros/README.md index 724c8441..de7fb7ba 100644 --- a/exercises/21_macros/README.md +++ b/exercises/21_macros/README.md @@ -10,6 +10,6 @@ of exercises to Rustlings, but is all about learning to write Macros. ## Further information -- [The Rust Book - Macros](https://doc.rust-lang.org/book/ch20-06-macros.html#macros) +- [The Rust Book - Macros](https://doc.rust-lang.org/book/ch20-05-macros.html) - [The Little Book of Rust Macros](https://veykril.github.io/tlborm/) - [Rust by Example - macro_rules!](https://doc.rust-lang.org/rust-by-example/macros.html) From bd3bdd620bce981f648a1c5fcc3efe0a80cf9911 Mon Sep 17 00:00:00 2001 From: Ethan Date: Tue, 8 Apr 2025 20:23:11 -0500 Subject: [PATCH 049/120] Fix typo in traits hint --- rustlings-macros/info.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rustlings-macros/info.toml b/rustlings-macros/info.toml index e7055981..f46754d4 100644 --- a/rustlings-macros/info.toml +++ b/rustlings-macros/info.toml @@ -763,7 +763,7 @@ hint = """ Notice how the trait takes ownership of `self` and returns `Self`. Although the signature of `append_bar` in the trait takes `self` as argument, -the implementation can take `mut self` instead. This is possible because the +the implementation can take `mut self` instead. This is possible because the value is owned anyway.""" [[exercises]] From 7b2d42b0f01a859c0cc0e28260a01769759b1362 Mon Sep 17 00:00:00 2001 From: Rahmat Nazali Salimi Date: Thu, 10 Apr 2025 15:38:43 +0700 Subject: [PATCH 050/120] Change `icecream` to `ice cream` --- exercises/12_options/options1.rs | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/exercises/12_options/options1.rs b/exercises/12_options/options1.rs index 99648078..d0c412a8 100644 --- a/exercises/12_options/options1.rs +++ b/exercises/12_options/options1.rs @@ -1,8 +1,8 @@ -// This function returns how much icecream there is left in the fridge. +// This function returns how much ice cream there is left in the fridge. // If it's before 22:00 (24-hour system), then 5 scoops are left. At 22:00, -// someone eats it all, so no icecream is left (value 0). Return `None` if +// someone eats it all, so no ice cream is left (value 0). Return `None` if // `hour_of_day` is higher than 23. -fn maybe_icecream(hour_of_day: u16) -> Option { +fn maybe_ice_cream(hour_of_day: u16) -> Option { // TODO: Complete the function body. } @@ -18,19 +18,19 @@ mod tests { fn raw_value() { // TODO: Fix this test. How do you get the value contained in the // Option? - let icecreams = maybe_icecream(12); + let ice_creams = maybe_ice_cream(12); - assert_eq!(icecreams, 5); // Don't change this line. + assert_eq!(ice_creams, 5); // Don't change this line. } #[test] - fn check_icecream() { - assert_eq!(maybe_icecream(0), Some(5)); - assert_eq!(maybe_icecream(9), Some(5)); - assert_eq!(maybe_icecream(18), Some(5)); - assert_eq!(maybe_icecream(22), Some(0)); - assert_eq!(maybe_icecream(23), Some(0)); - assert_eq!(maybe_icecream(24), None); - assert_eq!(maybe_icecream(25), None); + fn check_ice_cream() { + assert_eq!(maybe_ice_cream(0), Some(5)); + assert_eq!(maybe_ice_cream(9), Some(5)); + assert_eq!(maybe_ice_cream(18), Some(5)); + assert_eq!(maybe_ice_cream(22), Some(0)); + assert_eq!(maybe_ice_cream(23), Some(0)); + assert_eq!(maybe_ice_cream(24), None); + assert_eq!(maybe_ice_cream(25), None); } } From 29dc8ea9fa7b081201ebcec5eb01c588082b459d Mon Sep 17 00:00:00 2001 From: mo8it Date: Tue, 29 Apr 2025 21:35:55 +0200 Subject: [PATCH 051/120] Update deps --- Cargo.lock | 101 ++++++++++++++++++++++++++--------------------------- Cargo.toml | 2 +- 2 files changed, 50 insertions(+), 53 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index d534f8e0..a514a9e6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -54,9 +54,9 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.97" +version = "1.0.98" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dcfed56ad506cb2c684a14971b8861fdc3baaaae314b9e5f9bb532cbe3ba7a4f" +checksum = "e16d2d3311acee920a9eb8d33b8cbc1787ce4a264e85f964c2404b969bdcd487" [[package]] name = "autocfg" @@ -84,9 +84,9 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "clap" -version = "4.5.35" +version = "4.5.37" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d8aa86934b44c19c50f87cc2790e19f54f7a67aedb64101c2e1a2e5ecfb73944" +checksum = "eccb054f56cbd38340b380d4a8e69ef1f02f1af43db2f0cc817a4774d80ae071" dependencies = [ "clap_builder", "clap_derive", @@ -94,9 +94,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.5.35" +version = "4.5.37" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2414dbb2dd0695280da6ea9261e327479e9d37b0630f6b53ba2a11c60c679fd9" +checksum = "efd9466fac8543255d3b1fcad4762c5e116ffe808c8a3043d4263cd4fd4862a2" dependencies = [ "anstream", "anstyle", @@ -130,15 +130,16 @@ checksum = "5b63caa9aa9397e2d9480a9b13673856c78d8ac123288526c37d7839f2a86990" [[package]] name = "crossterm" -version = "0.28.1" +version = "0.29.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "829d955a0bb380ef178a640b91779e3987da38c9aea133b20614cfed8cdea9c6" +checksum = "d8b9f2e4c67f833b660cdb0a3523065869fb35570177239812ed4c905aeff87b" dependencies = [ "bitflags 2.9.0", "crossterm_winapi", + "document-features", "mio", "parking_lot", - "rustix 0.38.44", + "rustix", "signal-hook", "signal-hook-mio", "winapi", @@ -153,6 +154,15 @@ dependencies = [ "winapi", ] +[[package]] +name = "document-features" +version = "0.2.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "95249b50c6c185bee49034bcb378a49dc2b5dff0be90ff6616d31d64febab05d" +dependencies = [ + "litrs", +] + [[package]] name = "equivalent" version = "1.0.2" @@ -161,9 +171,9 @@ checksum = "877a4ace8713b0bcf2a4e7eec82529c029f1d0619886d18145fea96c3ffe5c0f" [[package]] name = "errno" -version = "0.3.10" +version = "0.3.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "33d852cb9b869c2a9b3df2f71a3074817f01e1844f839a144f5fcef059a4eb5d" +checksum = "976dd42dc7e85965fe702eb8164f21f450704bdde31faefd6471dba214cb594e" dependencies = [ "libc", "windows-sys 0.59.0", @@ -222,9 +232,9 @@ checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" [[package]] name = "indexmap" -version = "2.8.0" +version = "2.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3954d50fe15b02142bf25d3b8bdadb634ec3948f103d04ffe3031bc8fe9d7058" +checksum = "cea70ddb795996207ad57735b50c5982d8844f38ba9ee5f1aedcfb708a2aa11e" dependencies = [ "equivalent", "hashbrown", @@ -284,9 +294,9 @@ dependencies = [ [[package]] name = "libc" -version = "0.2.171" +version = "0.2.172" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c19937216e9d3aa9956d9bb8dfc0b0c8beb6058fc4f7a4dc4d850edf86a237d6" +checksum = "d750af042f7ef4f724306de029d18836c26c1765a54a6a3f094cbd23a7267ffa" [[package]] name = "libredox" @@ -301,15 +311,15 @@ dependencies = [ [[package]] name = "linux-raw-sys" -version = "0.4.15" +version = "0.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d26c52dbd32dccf2d10cac7725f8eae5296885fb5703b261f7d0a0739ec807ab" +checksum = "cd945864f07fe9f5371a27ad7b52a172b4b499999f1d97574c9fa68373937e12" [[package]] -name = "linux-raw-sys" -version = "0.9.3" +name = "litrs" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fe7db12097d22ec582439daf8618b8fdd1a7bef6270e9af3b1ebcd30893cf413" +checksum = "b4ce301924b7887e9d637144fdade93f9dfff9b60981d4ac161db09720d39aa5" [[package]] name = "lock_api" @@ -411,9 +421,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.94" +version = "1.0.95" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a31971752e70b8b2686d7e46ec17fb38dad4051d94024c88df49b667caea9c84" +checksum = "02b3e5e68a3a1a02aad3ec490a98007cbc13c37cbe84a3cd7b8e406d76e7f778" dependencies = [ "unicode-ident", ] @@ -435,26 +445,13 @@ checksum = "74765f6d916ee2faa39bc8e68e4f3ed8949b48cccdac59983d287a7cb71ce9c5" [[package]] name = "redox_syscall" -version = "0.5.10" +version = "0.5.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b8c0c260b63a8219631167be35e6a988e9554dbd323f8bd08439c8ed1302bd1" +checksum = "d2f103c6d277498fbceb16e84d317e2a400f160f46904d5f5410848c829511a3" dependencies = [ "bitflags 2.9.0", ] -[[package]] -name = "rustix" -version = "0.38.44" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fdb5bc1ae2baa591800df16c9ca78619bf65c0488b41b96ccec5d11220d8c154" -dependencies = [ - "bitflags 2.9.0", - "errno", - "libc", - "linux-raw-sys 0.4.15", - "windows-sys 0.59.0", -] - [[package]] name = "rustix" version = "1.0.5" @@ -464,7 +461,7 @@ dependencies = [ "bitflags 2.9.0", "errno", "libc", - "linux-raw-sys 0.9.3", + "linux-raw-sys", "windows-sys 0.59.0", ] @@ -477,7 +474,7 @@ dependencies = [ "crossterm", "notify", "os_pipe", - "rustix 1.0.5", + "rustix", "rustlings-macros", "serde", "serde_json", @@ -579,18 +576,18 @@ dependencies = [ [[package]] name = "signal-hook-registry" -version = "1.4.2" +version = "1.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a9e9e0b4211b72e7b8b6e85c807d36c212bdb33ea8587f7569562a84df5465b1" +checksum = "9203b8055f63a2a00e2f593bb0510367fe707d7ff1e5c872de2f537b339e5410" dependencies = [ "libc", ] [[package]] name = "smallvec" -version = "1.14.0" +version = "1.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7fcf8323ef1faaee30a44a340193b1ac6814fd9b7b4e88e9d4519a3e4abe1cfd" +checksum = "8917285742e9f3e1683f0a9c4e6b57960b7314d0b08d30d1ecd426713ee2eee9" [[package]] name = "strsim" @@ -600,9 +597,9 @@ checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" [[package]] name = "syn" -version = "2.0.100" +version = "2.0.101" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b09a44accad81e1ba1cd74a32461ba89dee89095ba17b32f5d03683b1b1fc2a0" +checksum = "8ce2b7fc941b3a24138a0a7cf8e858bfc6a992e7978a068a5c760deb0ed43caf" dependencies = [ "proc-macro2", "quote", @@ -618,24 +615,24 @@ dependencies = [ "fastrand", "getrandom", "once_cell", - "rustix 1.0.5", + "rustix", "windows-sys 0.59.0", ] [[package]] name = "toml_datetime" -version = "0.6.8" +version = "0.6.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0dd7358ecb8fc2f8d014bf86f6f638ce72ba252a2c3a2572f2a795f1d23efb41" +checksum = "3da5db5a963e24bc68be8b17b6fa82814bb22ee8660f192bb182771d498f09a3" dependencies = [ "serde", ] [[package]] name = "toml_edit" -version = "0.22.24" +version = "0.22.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "17b4795ff5edd201c7cd6dca065ae59972ce77d1b80fa0a84d94950ece7d1474" +checksum = "310068873db2c5b3e7659d2cc35d21855dbafa50d1ce336397c666e3cb08137e" dependencies = [ "indexmap", "serde", @@ -796,9 +793,9 @@ checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" [[package]] name = "winnow" -version = "0.7.4" +version = "0.7.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0e97b544156e9bebe1a0ffbc03484fc1ffe3100cbce3ffb17eac35f7cdd7ab36" +checksum = "6cb8234a863ea0e8cd7284fcdd4f145233eb00fee02bbdd9861aec44e6477bc5" dependencies = [ "memchr", ] diff --git a/Cargo.toml b/Cargo.toml index 9d9a0f94..34a4791a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -48,7 +48,7 @@ include = [ [dependencies] anyhow = "1.0" clap = { version = "4.5", features = ["derive"] } -crossterm = { version = "0.28", default-features = false, features = ["windows", "events"] } +crossterm = { version = "0.29", default-features = false, features = ["windows", "events"] } notify = "8.0" os_pipe = "1.2" rustlings-macros = { path = "rustlings-macros", version = "=6.4.0" } From 9bcd4198c5bcfdb85ba8b493e0c75ab6750a9325 Mon Sep 17 00:00:00 2001 From: mo8it Date: Tue, 29 Apr 2025 21:36:56 +0200 Subject: [PATCH 052/120] Fix formatting --- rustlings-macros/info.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rustlings-macros/info.toml b/rustlings-macros/info.toml index f46754d4..516fd321 100644 --- a/rustlings-macros/info.toml +++ b/rustlings-macros/info.toml @@ -763,8 +763,8 @@ hint = """ Notice how the trait takes ownership of `self` and returns `Self`. Although the signature of `append_bar` in the trait takes `self` as argument, -the implementation can take `mut self` instead. This is possible because -the value is owned anyway.""" +the implementation can take `mut self` instead. This is possible because the +value is owned anyway.""" [[exercises]] name = "traits3" From c5f49cfa48500ff71893070578206903f58ed2cc Mon Sep 17 00:00:00 2001 From: mo8it Date: Mon, 12 May 2025 20:30:51 +0200 Subject: [PATCH 053/120] Remove needless_option_as_deref exception --- Cargo.toml | 2 -- 1 file changed, 2 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 34a4791a..dbab70a9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -84,8 +84,6 @@ infinite_loop = "deny" mem_forget = "deny" dbg_macro = "warn" todo = "warn" -# TODO: Remove after the following fix is released: https://github.com/rust-lang/rust-clippy/pull/13102 -needless_option_as_deref = "allow" [lints] workspace = true From a063bcfb4cf5e7e6cb98a8738a73aee8b7a57c7a Mon Sep 17 00:00:00 2001 From: mo8it Date: Mon, 12 May 2025 20:30:56 +0200 Subject: [PATCH 054/120] Update deps --- Cargo.lock | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index a514a9e6..707c921d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -84,9 +84,9 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "clap" -version = "4.5.37" +version = "4.5.38" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eccb054f56cbd38340b380d4a8e69ef1f02f1af43db2f0cc817a4774d80ae071" +checksum = "ed93b9805f8ba930df42c2590f05453d5ec36cbb85d018868a5b24d31f6ac000" dependencies = [ "clap_builder", "clap_derive", @@ -94,9 +94,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.5.37" +version = "4.5.38" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "efd9466fac8543255d3b1fcad4762c5e116ffe808c8a3043d4263cd4fd4862a2" +checksum = "379026ff283facf611b0ea629334361c4211d1b12ee01024eec1591133b04120" dependencies = [ "anstream", "anstyle", @@ -208,9 +208,9 @@ dependencies = [ [[package]] name = "getrandom" -version = "0.3.2" +version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "73fea8450eea4bac3940448fb7ae50d91f034f941199fcd9d909a5a07aa455f0" +checksum = "26145e563e54f2cadc477553f1ec5ee650b00862f0a58bcd12cbdc5f0ea2d2f4" dependencies = [ "cfg-if", "libc", @@ -220,9 +220,9 @@ dependencies = [ [[package]] name = "hashbrown" -version = "0.15.2" +version = "0.15.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bf151400ff0baff5465007dd2f3e717f3fe502074ca563069ce3a6629d07b289" +checksum = "84b26c544d002229e640969970a2e74021aadf6e2f96372b9c58eff97de08eb3" [[package]] name = "heck" @@ -274,9 +274,9 @@ checksum = "4a5f13b858c8d314ee3e8f639011f7ccefe71f97f96e50151fb991f267928e2c" [[package]] name = "kqueue" -version = "1.0.8" +version = "1.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7447f1ca1b7b563588a205fe93dea8df60fd981423a768bc1c0ded35ed147d0c" +checksum = "eac30106d7dce88daf4a3fcb4879ea939476d5074a9b7ddd0fb97fa4bed5596a" dependencies = [ "kqueue-sys", "libc", @@ -445,18 +445,18 @@ checksum = "74765f6d916ee2faa39bc8e68e4f3ed8949b48cccdac59983d287a7cb71ce9c5" [[package]] name = "redox_syscall" -version = "0.5.11" +version = "0.5.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d2f103c6d277498fbceb16e84d317e2a400f160f46904d5f5410848c829511a3" +checksum = "928fca9cf2aa042393a8325b9ead81d2f0df4cb12e1e24cef072922ccd99c5af" dependencies = [ "bitflags 2.9.0", ] [[package]] name = "rustix" -version = "1.0.5" +version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d97817398dd4bb2e6da002002db259209759911da105da92bec29ccb12cf58bf" +checksum = "c71e83d6afe7ff64890ec6b71d6a69bb8a610ab78ce364b3352876bb4c801266" dependencies = [ "bitflags 2.9.0", "errno", @@ -555,9 +555,9 @@ dependencies = [ [[package]] name = "signal-hook" -version = "0.3.17" +version = "0.3.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8621587d4798caf8eb44879d42e56b9a93ea5dcd315a6487c357130095b62801" +checksum = "d881a16cf4426aa584979d30bd82cb33429027e42122b169753d6ef1085ed6e2" dependencies = [ "libc", "signal-hook-registry", @@ -608,9 +608,9 @@ dependencies = [ [[package]] name = "tempfile" -version = "3.19.1" +version = "3.20.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7437ac7763b9b123ccf33c338a5cc1bac6f69b45a136c19bdd8a65e3916435bf" +checksum = "e8a64e3985349f2441a1a9ef0b853f869006c3855f2cda6862a94d26ebb9d6a1" dependencies = [ "fastrand", "getrandom", @@ -793,9 +793,9 @@ checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" [[package]] name = "winnow" -version = "0.7.7" +version = "0.7.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6cb8234a863ea0e8cd7284fcdd4f145233eb00fee02bbdd9861aec44e6477bc5" +checksum = "c06928c8748d81b05c9be96aad92e1b6ff01833332f281e8cfca3be4b35fc9ec" dependencies = [ "memchr", ] From 48bab776096cde6ddd6547dfdb7d879a49c3edfe Mon Sep 17 00:00:00 2001 From: mo8it Date: Mon, 12 May 2025 20:31:13 +0200 Subject: [PATCH 055/120] Apply Clippy lints --- exercises/01_variables/variables5.rs | 2 +- solutions/01_variables/variables5.rs | 2 +- solutions/22_clippy/clippy3.rs | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/exercises/01_variables/variables5.rs b/exercises/01_variables/variables5.rs index 49db8e9e..cf5620da 100644 --- a/exercises/01_variables/variables5.rs +++ b/exercises/01_variables/variables5.rs @@ -1,6 +1,6 @@ fn main() { let number = "T-H-R-E-E"; // Don't change this line - println!("Spell a number: {}", number); + println!("Spell a number: {number}"); // TODO: Fix the compiler error by changing the line below without renaming the variable. number = 3; diff --git a/solutions/01_variables/variables5.rs b/solutions/01_variables/variables5.rs index 9057754c..0ea39030 100644 --- a/solutions/01_variables/variables5.rs +++ b/solutions/01_variables/variables5.rs @@ -1,6 +1,6 @@ fn main() { let number = "T-H-R-E-E"; - println!("Spell a number: {}", number); + println!("Spell a number: {number}"); // Using variable shadowing // https://doc.rust-lang.org/book/ch03-01-variables-and-mutability.html#shadowing diff --git a/solutions/22_clippy/clippy3.rs b/solutions/22_clippy/clippy3.rs index b7eaa570..81f381e0 100644 --- a/solutions/22_clippy/clippy3.rs +++ b/solutions/22_clippy/clippy3.rs @@ -15,7 +15,7 @@ fn main() { -1, -2, -3, -4, -5, -6, ]; - println!("My array! Here it is: {:?}", my_arr); + println!("My array! Here it is: {my_arr:?}"); let mut my_empty_vec = vec![1, 2, 3, 4, 5]; // `resize` mutates a vector instead of returning a new one. @@ -27,5 +27,5 @@ fn main() { let mut value_b = 66; // Use `mem::swap` to correctly swap two values. mem::swap(&mut value_a, &mut value_b); - println!("value a: {}; value b: {}", value_a, value_b); + println!("value a: {value_a}; value b: {value_b}"); } From e76ca5e2b97f0b7b292bbe504debb42ec7b36a87 Mon Sep 17 00:00:00 2001 From: mo8it Date: Mon, 12 May 2025 20:38:04 +0200 Subject: [PATCH 056/120] Use a separate target dir for rust analyzer --- src/init.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/init.rs b/src/init.rs index 208425c2..a60fba70 100644 --- a/src/init.rs +++ b/src/init.rs @@ -178,6 +178,7 @@ const INIT_SOLUTION_FILE: &[u8] = b"fn main() { pub const RUST_ANALYZER_TOML: &[u8] = br#"check.command = "clippy" check.extraArgs = ["--profile", "test"] +cargo.targetDir = true "#; const GITIGNORE: &[u8] = b"Cargo.lock From 9a3586878d73cede3258ce076c609324cef8cc07 Mon Sep 17 00:00:00 2001 From: mo8it Date: Tue, 13 May 2025 16:24:42 +0200 Subject: [PATCH 057/120] Sync solution --- solutions/09_strings/strings3.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/solutions/09_strings/strings3.rs b/solutions/09_strings/strings3.rs index a478e62a..ee6b56af 100644 --- a/solutions/09_strings/strings3.rs +++ b/solutions/09_strings/strings3.rs @@ -26,6 +26,7 @@ mod tests { assert_eq!(trim_me("Hello! "), "Hello!"); assert_eq!(trim_me(" What's up!"), "What's up!"); assert_eq!(trim_me(" Hola! "), "Hola!"); + assert_eq!(trim_me("Hi!"), "Hi!"); } #[test] From 5ee7dfb5c22ab0ac9037c86bc9320c944010038b Mon Sep 17 00:00:00 2001 From: liv Date: Fri, 16 May 2025 11:05:02 +0200 Subject: [PATCH 058/120] chore: build site with proper path prefix --- oranda.json | 3 +++ 1 file changed, 3 insertions(+) diff --git a/oranda.json b/oranda.json index ecc490b2..626e4968 100644 --- a/oranda.json +++ b/oranda.json @@ -1,4 +1,7 @@ { + "build": { + "path_prefix": "rustlings" + }, "project": { "homepage": "https://rustlings.cool", "repository": "https://github.com/rust-lang/rustlings" From 8dff0df2667d3c6f1812bdb390c708709b762847 Mon Sep 17 00:00:00 2001 From: mo8it Date: Fri, 16 May 2025 10:50:07 +0200 Subject: [PATCH 059/120] Use std pipe --- CHANGELOG.md | 2 +- Cargo.lock | 33 +++++++++++---------------------- Cargo.toml | 3 +-- src/cmd.rs | 4 ++-- 4 files changed, 15 insertions(+), 27 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b9826cf0..70529775 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,7 +3,7 @@ ### Changed - Upgrade to Rust edition 2024 -- Raise the minimum supported Rust version to `1.85` +- Raise the minimum supported Rust version to `1.87` diff --git a/Cargo.lock b/Cargo.lock index 707c921d..c285a52a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -72,9 +72,9 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] name = "bitflags" -version = "2.9.0" +version = "2.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c8214115b7bf84099f1309324e63141d4c5d7cc26862f97a0a857dbefe165bd" +checksum = "1b8e56985ec62d17e9c1001dc89c88ecd7dc08e47eba5ec7c29c7b5eeecde967" [[package]] name = "cfg-if" @@ -134,7 +134,7 @@ version = "0.29.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d8b9f2e4c67f833b660cdb0a3523065869fb35570177239812ed4c905aeff87b" dependencies = [ - "bitflags 2.9.0", + "bitflags 2.9.1", "crossterm_winapi", "document-features", "mio", @@ -171,9 +171,9 @@ checksum = "877a4ace8713b0bcf2a4e7eec82529c029f1d0619886d18145fea96c3ffe5c0f" [[package]] name = "errno" -version = "0.3.11" +version = "0.3.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "976dd42dc7e85965fe702eb8164f21f450704bdde31faefd6471dba214cb594e" +checksum = "cea14ef9355e3beab063703aa9dab15afd25f0667c341310c1e5274bb1d0da18" dependencies = [ "libc", "windows-sys 0.59.0", @@ -246,7 +246,7 @@ version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f37dccff2791ab604f9babef0ba14fbe0be30bd368dc541e2b08d07c8aa908f3" dependencies = [ - "bitflags 2.9.0", + "bitflags 2.9.1", "inotify-sys", "libc", ] @@ -304,7 +304,7 @@ version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c0ff37bd590ca25063e35af745c343cb7a0271906fb7b37e4813e8f79f00268d" dependencies = [ - "bitflags 2.9.0", + "bitflags 2.9.1", "libc", "redox_syscall", ] @@ -361,7 +361,7 @@ version = "8.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2fee8403b3d66ac7b26aee6e40a897d85dc5ce26f44da36b8b73e987cc52e943" dependencies = [ - "bitflags 2.9.0", + "bitflags 2.9.1", "filetime", "fsevent-sys", "inotify", @@ -386,16 +386,6 @@ version = "1.21.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "42f5e15c9953c5e4ccceeb2e7382a716482c34515315f7b03532b8b4e8393d2d" -[[package]] -name = "os_pipe" -version = "1.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ffd2b0a5634335b135d5728d84c5e0fd726954b87111f7506a61c502280d982" -dependencies = [ - "libc", - "windows-sys 0.59.0", -] - [[package]] name = "parking_lot" version = "0.12.3" @@ -449,7 +439,7 @@ version = "0.5.12" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "928fca9cf2aa042393a8325b9ead81d2f0df4cb12e1e24cef072922ccd99c5af" dependencies = [ - "bitflags 2.9.0", + "bitflags 2.9.1", ] [[package]] @@ -458,7 +448,7 @@ version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c71e83d6afe7ff64890ec6b71d6a69bb8a610ab78ce364b3352876bb4c801266" dependencies = [ - "bitflags 2.9.0", + "bitflags 2.9.1", "errno", "libc", "linux-raw-sys", @@ -473,7 +463,6 @@ dependencies = [ "clap", "crossterm", "notify", - "os_pipe", "rustix", "rustlings-macros", "serde", @@ -806,5 +795,5 @@ version = "0.39.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6f42320e61fe2cfd34354ecb597f86f413484a798ba44a8ca1165c58d42da6c1" dependencies = [ - "bitflags 2.9.0", + "bitflags 2.9.1", ] diff --git a/Cargo.toml b/Cargo.toml index dbab70a9..27531b37 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -16,7 +16,7 @@ authors = [ repository = "https://github.com/rust-lang/rustlings" license = "MIT" edition = "2024" # On Update: Update the edition of `rustfmt` in `dev check` and `CARGO_TOML` in `dev new`. -rust-version = "1.85" +rust-version = "1.87" [workspace.dependencies] serde = { version = "1.0", features = ["derive"] } @@ -50,7 +50,6 @@ anyhow = "1.0" clap = { version = "4.5", features = ["derive"] } crossterm = { version = "0.29", default-features = false, features = ["windows", "events"] } notify = "8.0" -os_pipe = "1.2" rustlings-macros = { path = "rustlings-macros", version = "=6.4.0" } serde_json = "1.0" serde.workspace = true diff --git a/src/cmd.rs b/src/cmd.rs index 551df8f0..b2c58f6a 100644 --- a/src/cmd.rs +++ b/src/cmd.rs @@ -1,7 +1,7 @@ use anyhow::{Context, Result, bail}; use serde::Deserialize; use std::{ - io::Read, + io::{Read, pipe}, path::PathBuf, process::{Command, Stdio}, }; @@ -17,7 +17,7 @@ fn run_cmd(mut cmd: Command, description: &str, output: Option<&mut Vec>) -> }; let mut handle = if let Some(output) = output { - let (mut reader, writer) = os_pipe::pipe().with_context(|| { + let (mut reader, writer) = pipe().with_context(|| { format!("Failed to create a pipe to run the command `{description}``") })?; From e73fff3bd4d6c55a2b741415ef02b9e945ef3b42 Mon Sep 17 00:00:00 2001 From: mo8it Date: Fri, 16 May 2025 11:08:25 +0200 Subject: [PATCH 060/120] Add dev alias --- .cargo/config.toml | 2 ++ dev/Cargo.toml | 2 +- src/dev/check.rs | 4 ++-- src/dev/update.rs | 2 +- 4 files changed, 6 insertions(+), 4 deletions(-) create mode 100644 .cargo/config.toml diff --git a/.cargo/config.toml b/.cargo/config.toml new file mode 100644 index 00000000..b8fa3f77 --- /dev/null +++ b/.cargo/config.toml @@ -0,0 +1,2 @@ +[alias] +dev = ["run", "--", "dev"] diff --git a/dev/Cargo.toml b/dev/Cargo.toml index ae380d17..4f725b70 100644 --- a/dev/Cargo.toml +++ b/dev/Cargo.toml @@ -1,4 +1,4 @@ -# Don't edit the `bin` list manually! It is updated by `cargo run -- dev update`. This comment line will be stripped in `rustlings init`. +# Don't edit the `bin` list manually! It is updated by `cargo dev update`. This comment line will be stripped in `rustlings init`. bin = [ { name = "intro1", path = "../exercises/00_intro/intro1.rs" }, { name = "intro1_sol", path = "../solutions/00_intro/intro1.rs" }, diff --git a/src/dev/check.rs b/src/dev/check.rs index c89c4eb2..9cde7f24 100644 --- a/src/dev/check.rs +++ b/src/dev/check.rs @@ -43,7 +43,7 @@ fn check_cargo_toml( if old_bins != new_bins { if cfg!(debug_assertions) { bail!( - "The file `dev/Cargo.toml` is outdated. Run `cargo run -- dev update` to update it. Then run `cargo run -- dev check` again" + "The file `dev/Cargo.toml` is outdated. Run `cargo dev update` to update it. Then run `cargo run -- dev check` again" ); } @@ -379,7 +379,7 @@ pub fn check(require_solutions: bool) -> Result<()> { } if cfg!(debug_assertions) { - // A hack to make `cargo run -- dev check` work when developing Rustlings. + // A hack to make `cargo dev check` work when developing Rustlings. check_cargo_toml(&info_file.exercises, "dev/Cargo.toml", b"../")?; } else { check_cargo_toml(&info_file.exercises, "Cargo.toml", b"")?; diff --git a/src/dev/update.rs b/src/dev/update.rs index 6de3c8f7..e0855a0e 100644 --- a/src/dev/update.rs +++ b/src/dev/update.rs @@ -28,7 +28,7 @@ pub fn update() -> Result<()> { let info_file = InfoFile::parse()?; if cfg!(debug_assertions) { - // A hack to make `cargo run -- dev update` work when developing Rustlings. + // A hack to make `cargo dev update` work when developing Rustlings. update_cargo_toml(&info_file.exercises, "dev/Cargo.toml", b"../") .context("Failed to update the file `dev/Cargo.toml`")?; From 5927a781a31f496223721f33ea19460daa3f70ab Mon Sep 17 00:00:00 2001 From: mo8it Date: Fri, 16 May 2025 11:29:32 +0200 Subject: [PATCH 061/120] Remove Oranda --- .github/workflows/web.yml | 87 ------------------------------------- .gitignore | 4 -- CHANGELOG.md | 90 --------------------------------------- README.md | 4 -- oranda.json | 16 ------- 5 files changed, 201 deletions(-) delete mode 100644 .github/workflows/web.yml delete mode 100644 oranda.json diff --git a/.github/workflows/web.yml b/.github/workflows/web.yml deleted file mode 100644 index ec5d4462..00000000 --- a/.github/workflows/web.yml +++ /dev/null @@ -1,87 +0,0 @@ -# Workflow to build your docs with oranda (and mdbook) -# and deploy them to Github Pages -name: Web - -# We're going to push to the gh-pages branch, so we need that permission -permissions: - contents: write - -# What situations do we want to build docs in? -# All of these work independently and can be removed / commented out -# if you don't want oranda/mdbook running in that situation -on: - # Check that a PR didn't break docs! - # - # Note that the "Deploy to Github Pages" step won't run in this mode, - # so this won't have any side-effects. But it will tell you if a PR - # completely broke oranda/mdbook. Sadly we don't provide previews (yet)! - pull_request: - - # Whenever something gets pushed to main, update the docs! - # This is great for getting docs changes live without cutting a full release. - # - # Note that if you're using cargo-dist, this will "race" the Release workflow - # that actually builds the Github Release that oranda tries to read (and - # this will almost certainly complete first). As a result you will publish - # docs for the latest commit but the oranda landing page won't know about - # the latest release. The workflow_run trigger below will properly wait for - # cargo-dist, and so this half-published state will only last for ~10 minutes. - # - # If you only want docs to update with releases, disable this, or change it to - # a "release" branch. You can, of course, also manually trigger a workflow run - # when you want the docs to update. - push: - branches: - - main - - # Whenever a workflow called "Release" completes, update the docs! - # - # If you're using cargo-dist, this is recommended, as it will ensure that - # oranda always sees the latest release right when it's available. Note - # however that Github's UI is wonky when you use workflow_run, and won't - # show this workflow as part of any commit. You have to go to the "actions" - # tab for your repo to see this one running (the gh-pages deploy will also - # only show up there). - workflow_run: - workflows: [ "Release" ] - types: - - completed - -# Alright, let's do it! -jobs: - web: - name: Build and deploy site and docs - runs-on: ubuntu-latest - steps: - # Setup - - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - uses: swatinem/rust-cache@v2 - - # If you use any mdbook plugins, here's the place to install them! - - # Install and run oranda (and mdbook) - # This will write all output to ./public/ (including copying mdbook's output to there) - - name: Install and run oranda - run: | - curl --proto '=https' --tlsv1.2 -LsSf https://github.com/axodotdev/oranda/releases/download/v0.3.1/oranda-installer.sh | sh - oranda build - - # Deploy to our gh-pages branch (creating it if it doesn't exist) - # the "public" dir that oranda made above will become the root dir - # of this branch. - # - # Note that once the gh-pages branch exists, you must - # go into repo's settings > pages and set "deploy from branch: gh-pages" - # the other defaults work fine. - - name: Deploy to Github Pages - uses: JamesIves/github-pages-deploy-action@v4.4.1 - # ONLY if we're on main (so no PRs or feature branches allowed!) - if: ${{ github.ref == 'refs/heads/main' }} - with: - branch: gh-pages - # Gotta tell the action where to find oranda's output - folder: public - token: ${{ secrets.GITHUB_TOKEN }} - single-commit: true diff --git a/.gitignore b/.gitignore index 945382c3..ea65eb1e 100644 --- a/.gitignore +++ b/.gitignore @@ -6,10 +6,6 @@ Cargo.lock # State file .rustlings-state.txt -# oranda -public/ -.netlify - # OS .DS_Store .direnv/ diff --git a/CHANGELOG.md b/CHANGELOG.md index 70529775..6781ba89 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,8 +5,6 @@ - Upgrade to Rust edition 2024 - Raise the minimum supported Rust version to `1.87` - - ## 6.4.0 (2024-11-11) ### Added @@ -36,8 +34,6 @@ - Fix bad contrast in the list on terminals with a light theme. - - ## 6.3.0 (2024-08-29) ### Added @@ -77,8 +73,6 @@ - Fix the list when the terminal height is too low. - Restore the terminal after an error in the list. - - ## 6.2.0 (2024-08-09) ### Added @@ -95,8 +89,6 @@ - Run the final check of all exercises in parallel. - Small exercise improvements. - - ## 6.1.0 (2024-07-10) #### Added @@ -114,15 +106,11 @@ - Exit with a helpful error message on missing/unsupported terminal/TTY. - Mark the last exercise as done. - - ## 6.0.1 (2024-07-04) Small exercise improvements and fixes. Most importantly, fixed that the exercise `clippy1` was already solved 😅 - - ## 6.0.0 (2024-07-03) This release is the result of a complete rewrite to deliver a ton of new features and improvements ✨ @@ -188,8 +176,6 @@ Do you want to create your own set of Rustlings exercises to focus on some speci Or do you want to translate the original Rustlings exercises? Then follow the link to the guide about [third-party exercises](THIRD_PARTY_EXERCISES.md)! - - ## 5.6.1 (2023-09-18) #### Changed @@ -205,8 +191,6 @@ Then follow the link to the guide about [third-party exercises](THIRD_PARTY_EXER - `as_ref_mut`: Fixed a typo in a test function name. - `enums3`: Fixed formatting with `rustfmt`. - - ## 5.6.0 (2023-09-04) #### Added @@ -246,16 +230,12 @@ Then follow the link to the guide about [third-party exercises](THIRD_PARTY_EXER - Lots of Nix housekeeping that I don't feel qualified to write about! - Improved CI workflows, we're now testing on multiple platforms at once. - - ## 5.5.1 (2023-05-17) #### Fixed - Reverted `rust-project.json` path generation due to an upstream `rust-analyzer` fix. - - ## 5.5.0 (2023-05-17) #### Added @@ -290,8 +270,6 @@ Then follow the link to the guide about [third-party exercises](THIRD_PARTY_EXER - Added a markdown linter to run on GitHub actions - Split quick installation section into two code blocks - - ## 5.4.1 (2023-03-10) #### Changed @@ -307,8 +285,6 @@ Then follow the link to the guide about [third-party exercises](THIRD_PARTY_EXER - `macros4`: Prevented auto-fix by adding `#[rustfmt::skip]` - `cli`: Actually show correct progress percentages - - ## 5.4.0 (2023-02-12) #### Changed @@ -337,8 +313,6 @@ Then follow the link to the guide about [third-party exercises](THIRD_PARTY_EXER - Bumped min Rust version to 1.58 in installation script - - ## 5.3.0 (2022-12-23) #### Added @@ -371,8 +345,6 @@ Then follow the link to the guide about [third-party exercises](THIRD_PARTY_EXER - Applied some Clippy and rustfmt formatting - Added a note on Windows PowerShell and other shell compatibility - - ## 5.2.1 (2022-09-06) #### Fixed @@ -386,8 +358,6 @@ Then follow the link to the guide about [third-party exercises](THIRD_PARTY_EXER - Fixed a typo in README.md - - ## 5.2.0 (2022-08-27) #### Added @@ -404,16 +374,12 @@ Then follow the link to the guide about [third-party exercises](THIRD_PARTY_EXER - **quiz1**: Adjusted the explanations to be consistent with the tests - - ## 5.1.1 (2022-08-17) #### Bug Fixes - Fixed an incorrect assertion in options1 - - ## 5.1.0 (2022-08-16) #### Features @@ -448,8 +414,6 @@ Then follow the link to the guide about [third-party exercises](THIRD_PARTY_EXER - Clarified manual installation instructions using `cargo install --path .` - Added a link to our Zulip in the readme file - - ## 5.0.0 (2022-07-16) #### Features @@ -522,8 +486,6 @@ Then follow the link to the guide about [third-party exercises](THIRD_PARTY_EXER - Updated spacing in Cargo.toml. - Added a GitHub actions config so that tests run on every PR/commit. - - ## 4.8.0 (2022-07-01) #### Features @@ -544,8 +506,6 @@ Then follow the link to the guide about [third-party exercises](THIRD_PARTY_EXER - Replaced the git.io URL with the fully qualified URL because of git.io's sunsetting. - Removed the deprecated Rust GitPod extension. - - ## 4.7.1 (2022-04-20) #### Features @@ -566,8 +526,6 @@ Then follow the link to the guide about [third-party exercises](THIRD_PARTY_EXER - The changelog will now be manually written instead of being automatically generated by the Git log. - - ## 4.7.0 (2022-04-14) #### Features @@ -608,8 +566,6 @@ Then follow the link to the guide about [third-party exercises](THIRD_PARTY_EXER - Add hints on how to get GCC installed (#741) ([bc56861](https://github.com/rust-lang/rustlings/commit/bc5686174463ad6f4f6b824b0e9b97c3039d4886)) - Fix some code blocks that were not highlighted ([17f9d74](https://github.com/rust-lang/rustlings/commit/17f9d7429ccd133a72e815fb5618e0ce79560929)) - - ## 4.6.0 (2021-09-25) #### Features @@ -632,8 +588,6 @@ Then follow the link to the guide about [third-party exercises](THIRD_PARTY_EXER - Clarify instructions ([df25684c](https://github.com/rust-lang/rustlings/commit/df25684cb79f8413915e00b5efef29369849cef1)) - **quiz1:** Fix inconsistent wording (#826) ([03131a3d](https://github.com/rust-lang/rustlings/commit/03131a3d35d9842598150f9da817f7cc26e2669a)) - - ## 4.5.0 (2021-07-07) #### Features @@ -654,8 +608,6 @@ Then follow the link to the guide about [third-party exercises](THIRD_PARTY_EXER - **try_from_into, from_str:** hints for dyn Error ([11d2cf0d](https://github.com/rust-lang/rustlings/commit/11d2cf0d604dee3f5023c17802d69438e69fa50e)) - **variables5:** confine the answer further ([48ffcbd2](https://github.com/rust-lang/rustlings/commit/48ffcbd2c4cc4d936c2c7480019190f179813cc5)) - - ## 4.4.0 (2021-04-24) #### Bug Fixes @@ -697,8 +649,6 @@ Then follow the link to the guide about [third-party exercises](THIRD_PARTY_EXER - updated progress percentage ([1c6f7e4b](https://github.com/rust-lang/rustlings/commit/1c6f7e4b7b9b3bd36f4da2bb2b69c549cc8bd913)) - added progress info ([c0e3daac](https://github.com/rust-lang/rustlings/commit/c0e3daacaf6850811df5bc57fa43e0f249d5cfa4)) - - ## 4.3.0 (2020-12-29) #### Features @@ -721,8 +671,6 @@ Then follow the link to the guide about [third-party exercises](THIRD_PARTY_EXER - Update description (#584) ([96347df9](https://github.com/rust-lang/rustlings/commit/96347df9df294f01153b29d9ad4ba361f665c755)) - **vec1:** Have test compare every element in a and v ([9b6c6293](https://github.com/rust-lang/rustlings/commit/9b6c629397b24b944f484f5b2bbd8144266b5695)) - - ## 4.2.0 (2020-11-07) #### Features @@ -743,8 +691,6 @@ Then follow the link to the guide about [third-party exercises](THIRD_PARTY_EXER - missing comma in test ([4fb230da](https://github.com/rust-lang/rustlings/commit/4fb230daf1251444fcf29e085cee222a91f8a37e)) - **quiz3:** Second test is for odd numbers, not even. (#553) ([18e0bfef](https://github.com/rust-lang/rustlings/commit/18e0bfef1de53071e353ba1ec5837002ff7290e6)) - - ## 4.1.0 (2020-10-05) #### Bug Fixes @@ -767,8 +713,6 @@ Then follow the link to the guide about [third-party exercises](THIRD_PARTY_EXER - **cli:** Added 'cls' command to 'watch' mode (#474) ([4f2468e1](https://github.com/rust-lang/rustlings/commit/4f2468e14f574a93a2e9b688367b5752ed96ae7b)) - **try_from_into:** Add insufficient length test (#469) ([523d18b8](https://github.com/rust-lang/rustlings/commit/523d18b873a319f7c09262f44bd40e2fab1830e5)) - - ## 4.0.0 (2020-07-08) #### Breaking Changes @@ -810,8 +754,6 @@ Then follow the link to the guide about [third-party exercises](THIRD_PARTY_EXER - **test2:** name of type String and &str (#394) ([d6c0a688](https://github.com/rust-lang/rustlings/commit/d6c0a688e6a96f93ad60d540d4b326f342fc0d45)) - **variables6:** minor typo (#419) ([524e17df](https://github.com/rust-lang/rustlings/commit/524e17df10db95f7b90a0f75cc8997182a8a4094)) - - ## 3.0.0 (2020-04-11) #### Breaking Changes @@ -834,8 +776,6 @@ Then follow the link to the guide about [third-party exercises](THIRD_PARTY_EXER - add new exercises for generics (#280) ([76be5e4e](https://github.com/rust-lang/rustlings/commit/76be5e4e991160f5fd9093f03ee2ba260e8f7229)) - **ci:** add buildkite config ([b049fa2c](https://github.com/rust-lang/rustlings/commit/b049fa2c84dba0f0c8906ac44e28fd45fba51a71)) - - ### 2.2.1 (2020-02-27) #### Bug Fixes @@ -846,8 +786,6 @@ Then follow the link to the guide about [third-party exercises](THIRD_PARTY_EXER - Add clippy lints (#269) ([1e2fd9c9](https://github.com/rust-lang/rustlings/commit/1e2fd9c92f8cd6e389525ca1a999fca4c90b5921)) - - ## 2.2.0 (2020-02-25) #### Bug Fixes @@ -875,8 +813,6 @@ Then follow the link to the guide about [third-party exercises](THIRD_PARTY_EXER - Added traits exercises (#274 but specifically #216, which originally added this :heart:) ([b559cdd](https://github.com/rust-lang/rustlings/commit/b559cdd73f32c0d0cfc1feda39f82b3e3583df17)) - - ## 2.1.0 (2019-11-27) #### Bug Fixes @@ -894,8 +830,6 @@ Then follow the link to the guide about [third-party exercises](THIRD_PARTY_EXER - **watch:** show hint while watching ([8143d57b](https://github.com/rust-lang/rustlings/commit/8143d57b4e88c51341dd4a18a14c536042cc009c)) - - ## 2.0.0 (2019-11-12) #### Bug Fixes @@ -916,8 +850,6 @@ Then follow the link to the guide about [third-party exercises](THIRD_PARTY_EXER - **cli:** check for rustc before doing anything ([36a033b8](https://github.com/rust-lang/rustlings/commit/36a033b87a6549c1e5639c908bf7381c84f4f425)) - **hint:** Add test for hint ([ce9fa6eb](https://github.com/rust-lang/rustlings/commit/ce9fa6ebbfdc3e7585d488d9409797285708316f)) - - ### 1.5.1 (2019-11-11) #### Bug Fixes @@ -929,8 +861,6 @@ Then follow the link to the guide about [third-party exercises](THIRD_PARTY_EXER - **threads:** Move Threads behind SLT ([fbe91a67](https://github.com/rust-lang/rustlings/commit/fbe91a67a482bfe64cbcdd58d06ba830a0f39da3), closes [#205](https://github.com/rust-lang/rustlings/issues/205)) - **watch:** clear screen before each `verify()` ([3aff590](https://github.com/rust-lang/rustlings/commit/3aff59085586c24196a547c2693adbdcf4432648)) - - ## 1.5.0 (2019-11-09) #### Bug Fixes @@ -955,8 +885,6 @@ Then follow the link to the guide about [third-party exercises](THIRD_PARTY_EXER - Added exercise for struct update syntax ([1c4c8764](https://github.com/rust-lang/rustlings/commit/1c4c8764ed118740cd4cee73272ddc6cceb9d959)) - **iterators2:** adds iterators2 exercise including config ([9288fccf](https://github.com/rust-lang/rustlings/commit/9288fccf07a2c5043b76d0fd6491e4cf72d76031)) - - ### 1.4.1 (2019-08-13) #### Bug Fixes @@ -965,8 +893,6 @@ Then follow the link to the guide about [third-party exercises](THIRD_PARTY_EXER - **option1:** Add test for prematurely passing exercise ([a750e4a1](https://github.com/rust-lang/rustlings/commit/a750e4a1a3006227292bb17d57d78ce84da6bfc6)) - **test1:** Swap assertion parameter order ([4086d463](https://github.com/rust-lang/rustlings/commit/4086d463a981e81d97781851d17db2ced290f446)) - - ## 1.4.0 (2019-07-13) #### Bug Fixes @@ -983,8 +909,6 @@ Then follow the link to the guide about [third-party exercises](THIRD_PARTY_EXER - **changelog:** Use clog for changelogs ([34e31232](https://github.com/rust-lang/rustlings/commit/34e31232dfddde284a341c9609b33cd27d9d5724)) - **iterators2:** adds iterators2 exercise including config ([9288fccf](https://github.com/rust-lang/rustlings/commit/9288fccf07a2c5043b76d0fd6491e4cf72d76031)) - - ### 1.3.0 (2019-06-05) #### Features @@ -1000,16 +924,12 @@ Then follow the link to the guide about [third-party exercises](THIRD_PARTY_EXER - Fix broken link (#164, @HanKruiger) - Remove highlighting and syntect (#167, @komaeda) - - ### 1.2.2 (2019-05-07) #### Bug Fixes - Reverted `--nocapture` flag since it was causing tests to pass unconditionally - - ### 1.2.1 (2019-04-22) #### Bug Fixes @@ -1017,8 +937,6 @@ Then follow the link to the guide about [third-party exercises](THIRD_PARTY_EXER - Fix the `--nocapture` feature (@komaeda) - Provide a nicer error message for when you're in the wrong directory - - ### 1.2.0 (2019-04-22) #### Features @@ -1026,8 +944,6 @@ Then follow the link to the guide about [third-party exercises](THIRD_PARTY_EXER - Add errors to exercises that compile without user changes (@yvan-sraka) - Use --nocapture when testing, enabling `println!` when running (@komaeda) - - ### 1.1.1 (2019-04-14) #### Bug fixes @@ -1040,8 +956,6 @@ Then follow the link to the guide about [third-party exercises](THIRD_PARTY_EXER - Fix links by deleting book version (@diodfr, #142) - Canonicalize paths to fix path matching (@cjpearce, #143) - - ### 1.1.0 (2019-03-20) - errors2.rs: update link to Rust book (#124) @@ -1051,16 +965,12 @@ Then follow the link to the guide about [third-party exercises](THIRD_PARTY_EXER - Give a warning when Rustlings isn't run from the right directory (#123) - Verify that rust version is recent enough to install Rustlings (#131) - - ### 1.0.1 (2019-03-06) - Adds a way to install Rustlings in one command (`curl -L https://git.io/rustlings | bash`) - Makes `rustlings watch` react to create file events (@shaunbennett, #117) - Reworks the exercise management to use an external TOML file instead of just listing them in the code - - ### 1.0.0 (2019-03-06) Initial release. diff --git a/README.md b/README.md index 3e6d6c7c..8480b1a3 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,5 @@ -
- # Rustlings 🦀❤️ -
- Greetings and welcome to Rustlings. This project contains small exercises to get you used to reading and writing Rust code. This includes reading and responding to compiler messages! diff --git a/oranda.json b/oranda.json deleted file mode 100644 index 626e4968..00000000 --- a/oranda.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "build": { - "path_prefix": "rustlings" - }, - "project": { - "homepage": "https://rustlings.cool", - "repository": "https://github.com/rust-lang/rustlings" - }, - "marketing": { - "analytics": { - "plausible": { - "domain": "rustlings.cool" - } - } - } -} From 08548abcc27ede812b69c399aff24b8a8ff9d041 Mon Sep 17 00:00:00 2001 From: mo8it Date: Fri, 16 May 2025 11:35:24 +0200 Subject: [PATCH 062/120] Remove .editorconfig --- .editorconfig | 7 ------- 1 file changed, 7 deletions(-) delete mode 100644 .editorconfig diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index aab09aa3..00000000 --- a/.editorconfig +++ /dev/null @@ -1,7 +0,0 @@ -root = true - -[*.rs] -end_of_line = lf -insert_final_newline = true -indent_style = space -indent_size = 4 From a28000acc4945bc0865f15964b3605ea9d31cedf Mon Sep 17 00:00:00 2001 From: mo8it Date: Fri, 16 May 2025 11:35:46 +0200 Subject: [PATCH 063/120] Remove markdown lint --- .github/workflows/rust.yml | 7 ++----- .markdownlint.yml | 2 -- 2 files changed, 2 insertions(+), 7 deletions(-) delete mode 100644 .markdownlint.yml diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 9a5d8693..24469399 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -1,4 +1,4 @@ -name: Rustlings Tests +name: Check on: push: @@ -19,9 +19,6 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - uses: DavidAnson/markdownlint-cli2-action@v16 - with: - globs: "exercises/**/*.md" - name: rustfmt run: cargo fmt --all --check test: @@ -40,4 +37,4 @@ jobs: - uses: actions/checkout@v4 - uses: swatinem/rust-cache@v2 - name: rustlings dev check - run: cargo run -- dev check --require-solutions + run: cargo dev check --require-solutions diff --git a/.markdownlint.yml b/.markdownlint.yml deleted file mode 100644 index d5f7e391..00000000 --- a/.markdownlint.yml +++ /dev/null @@ -1,2 +0,0 @@ -# MD013/line-length Line length, Expected: 80 -MD013: false From 74ab9924b4193c0fb66f3c0e3667a4d7b4edfb18 Mon Sep 17 00:00:00 2001 From: mo8it Date: Fri, 16 May 2025 21:08:29 +0200 Subject: [PATCH 064/120] Start with Zola --- website/.gitignore | 7 ++++++ website/config.toml | 20 ++++++++++++++++ website/input.css | 54 ++++++++++++++++++++++++++++++++++++++++++++ website/justfile | 5 ++++ website/package.json | 7 ++++++ 5 files changed, 93 insertions(+) create mode 100644 website/.gitignore create mode 100644 website/config.toml create mode 100644 website/input.css create mode 100644 website/justfile create mode 100644 website/package.json diff --git a/website/.gitignore b/website/.gitignore new file mode 100644 index 00000000..648e0774 --- /dev/null +++ b/website/.gitignore @@ -0,0 +1,7 @@ +/node_modules/ +/package-lock.json + +/public/ + +/static/main.css +/static/processed_images/ diff --git a/website/config.toml b/website/config.toml new file mode 100644 index 00000000..d23b3314 --- /dev/null +++ b/website/config.toml @@ -0,0 +1,20 @@ +base_url = "https://rust-lang.github.io/rustlings" +title = "Rustlings" +description = "Small exercises to get you used to reading and writing Rust code!" + +compile_sass = false +build_search_index = false + +[markdown] +highlight_code = true + +[[extra.menu_items]] +name = "Home" +url = "/" +[[extra.menu_items]] +name = "Custom Exercises" +url = "/custom-exercises" + +[[extra.footer_items]] +name = "Repository" +url = "https://github.com/rust-lang/rustlings" diff --git a/website/input.css b/website/input.css new file mode 100644 index 00000000..b26d9ba4 --- /dev/null +++ b/website/input.css @@ -0,0 +1,54 @@ +@import 'tailwindcss'; + +@layer base { + h1 { + @apply text-4xl mt-3 mb-3 text-gray-50 font-bold; + } + h2 { + @apply text-3xl mt-4 mb-1.5 text-gray-50 font-bold; + } + h3 { + @apply text-2xl mt-5 mb-1.5 text-gray-50 font-bold; + } + h4 { + @apply text-xl mt-6 mb-1.5 text-gray-50 font-bold; + } + p { + @apply mb-2; + } + a { + @apply text-[#F74C00] underline hover:decoration-orange-400 transition duration-300; + } + ul { + @apply mt-2 mb-3 ml-1 list-disc list-inside marker:text-sky-600; + } + ol { + @apply mt-2 mb-3 ml-1 list-decimal list-inside marker:text-sky-500; + } + li { + @apply my-0.5; + } + code { + @apply bg-white/10 px-1 pb-px pt-1 rounded-md; + } + pre code { + @apply bg-inherit p-0 text-inherit; + } + hr { + @apply my-5 rounded-full; + } + img { + @apply max-w-full w-full h-full mx-auto my-5 object-contain md:w-3/4 lg:w-3/5 rounded-sm shadow-sm; + } + blockquote { + @apply p-4 my-3 border-s-4 border-gray-300 bg-gray-800 italic; + } + + pre { + @apply px-2 pt-2 pb-px overflow-x-auto text-sm sm:text-base rounded-sm mt-2 mb-4 after:content-[attr(data-lang)] after:text-[8px] after:opacity-40 selection:bg-gray-500/75; + } + pre code mark { + @apply pb-0.5 pt-1 pr-px text-inherit rounded-xs; + } +} + diff --git a/website/justfile b/website/justfile new file mode 100644 index 00000000..5c9c6770 --- /dev/null +++ b/website/justfile @@ -0,0 +1,5 @@ +zola: + zola serve --open + +tailwind: + fnm exec --using latest npx @tailwindcss/cli -i input.css -o static/main.css diff --git a/website/package.json b/website/package.json new file mode 100644 index 00000000..ee8a1c88 --- /dev/null +++ b/website/package.json @@ -0,0 +1,7 @@ +{ + "devDependencies": { + "rustywind": "^0.24", + "tailwindcss": "^4.1", + "@tailwindcss/cli": "^4.1" + } +} From 7ec698696537aac4433bb0e60fb10310a6b34bc1 Mon Sep 17 00:00:00 2001 From: mo8it Date: Fri, 16 May 2025 23:11:08 +0200 Subject: [PATCH 065/120] Add templates --- website/config.toml | 6 + website/content/_index.md | 143 ++++++++++++++++++++++ website/content/custom-exercises/index.md | 66 ++++++++++ website/input.css | 14 +-- website/justfile | 2 +- website/templates/404.html | 16 +++ website/templates/anchor-link.html | 2 + website/templates/base.html | 83 +++++++++++++ website/templates/index.html | 11 ++ website/templates/macros.html | 46 +++++++ website/templates/page.html | 11 ++ 11 files changed, 392 insertions(+), 8 deletions(-) create mode 100644 website/content/_index.md create mode 100644 website/content/custom-exercises/index.md create mode 100644 website/templates/404.html create mode 100644 website/templates/anchor-link.html create mode 100644 website/templates/base.html create mode 100644 website/templates/index.html create mode 100644 website/templates/macros.html create mode 100644 website/templates/page.html diff --git a/website/config.toml b/website/config.toml index d23b3314..6a9114a9 100644 --- a/website/config.toml +++ b/website/config.toml @@ -7,6 +7,12 @@ build_search_index = false [markdown] highlight_code = true +highlight_theme = "ayu-mirage" + +insert_anchor_links = "heading" + +[extra] +logo_path = "images/happy_ferris.svg" [[extra.menu_items]] name = "Home" diff --git a/website/content/_index.md b/website/content/_index.md new file mode 100644 index 00000000..2ad12ebb --- /dev/null +++ b/website/content/_index.md @@ -0,0 +1,143 @@ ++++ ++++ + +Greetings and welcome to Rustlings. +This project contains small exercises to get you used to reading and writing Rust code. +This includes reading and responding to compiler messages! + +It is recommended to do the Rustlings exercises in parallel to reading [the official Rust book](https://doc.rust-lang.org/book/), the most comprehensive resource for learning Rust 📚️ + + + +## Getting Started + +### Installing Rust + +Before installing Rustlings, you need to have the **latest version of Rust** installed. +Visit [www.rust-lang.org/tools/install](https://www.rust-lang.org/tools/install) for further instructions on installing Rust. +This will also install _Cargo_, Rust's package/project manager. + +> 🐧 If you are on Linux, make sure you have installed `gcc` (for a linker). +> +> Deb: `sudo apt install gcc` +> +> Dnf: `sudo dnf install gcc` + +> 🍎 If you are on MacOS, make sure you have installed Xcode and its developer tools by running `xcode-select --install`. + +### Installing Rustlings + +The following command will download and compile Rustlings: + +```bash +cargo install rustlings +``` + +
+If the installation fails… (click to expand) + +- Make sure you have the latest Rust version by running `rustup update` +- Try adding the `--locked` flag: `cargo install rustlings --locked` +- Otherwise, please [report the issue](https://github.com/rust-lang/rustlings/issues/new) + +
+ +### Initialization + +After installing Rustlings, run the following command to initialize the `rustlings/` directory: + +```bash +rustlings init +``` + +
+If the command rustlings can't be found… (click to expand) + +You are probably using Linux and installed Rust using your package manager. + +Cargo installs binaries to the directory `~/.cargo/bin`. +Sadly, package managers often don't add `~/.cargo/bin` to your `PATH` environment variable. + +The solution is to … + +- either add `~/.cargo/bin` manually to `PATH` +- or to uninstall Rust from the package manager and install it using the official way with `rustup`: https://www.rust-lang.org/tools/install + +
+ +Now, go into the newly initialized directory and launch Rustlings for further instructions on getting started with the exercises: + +```bash +cd rustlings/ +rustlings +``` + +## Working environment + +### Editor + +Our general recommendation is [VS Code](https://code.visualstudio.com/) with the [rust-analyzer plugin](https://marketplace.visualstudio.com/items?itemName=rust-lang.rust-analyzer). +But any editor that supports [rust-analyzer](https://rust-analyzer.github.io/) should be enough for working on the exercises. + +### Terminal + +While working with Rustlings, please use a modern terminal for the best user experience. +The default terminal on Linux and Mac should be sufficient. +On Windows, we recommend the [Windows Terminal](https://aka.ms/terminal). + +## Doing exercises + +The exercises are sorted by topic and can be found in the subdirectory `exercises/`. +For every topic, there is an additional `README.md` file with some resources to get you started on the topic. +We highly recommend that you have a look at them before you start 📚️ + +Most exercises contain an error that keeps them from compiling, and it's up to you to fix it! +Some exercises contain tests that need to pass for the exercise to be done ✅ + +Search for `TODO` and `todo!()` to find out what you need to change. +Ask for hints by entering `h` in the _watch mode_ 💡 + +### Watch Mode + +After the [initialization](#initialization), Rustlings can be launched by simply running the command `rustlings`. + +This will start the _watch mode_ which walks you through the exercises in a predefined order (what we think is best for newcomers). +It will rerun the current exercise automatically every time you change the exercise's file in the `exercises/` directory. + +
+If detecting file changes in the exercises/ directory fails… (click to expand) + +> You can add the **`--manual-run`** flag (`rustlings --manual-run`) to manually rerun the current exercise by entering `r` in the watch mode. +> +> Please [report the issue](https://github.com/rust-lang/rustlings/issues/new) with some information about your operating system and whether you run Rustlings in a container or virtual machine (e.g. WSL). + +
+ +### Exercise List + +In the [watch mode](#watch-mode) (after launching `rustlings`), you can enter `l` to open the interactive exercise list. + +The list allows you to… + +- See the status of all exercises (done or pending) +- `c`: Continue at another exercise (temporarily skip some exercises or go back to a previous one) +- `r`: Reset status and file of the selected exercise (you need to _reload/reopen_ its file in your editor afterwards) + +See the footer of the list for all possible keys. + +## Questions? + +If you need any help while doing the exercises and the builtin-hints aren't helpful, feel free to ask in the [_Q&A_ category of the discussions](https://github.com/rust-lang/rustlings/discussions/categories/q-a?discussions_q=) if your question wasn't asked yet 💡 + +## Continuing On + +Once you've completed Rustlings, put your new knowledge to good use! +Continue practicing your Rust skills by building your own projects, contributing to Rustlings, or finding other open-source projects to contribute to. + +## Uninstalling Rustlings + +If you want to remove Rustlings from your system, run the following command: + +```bash +cargo uninstall rustlings +``` diff --git a/website/content/custom-exercises/index.md b/website/content/custom-exercises/index.md new file mode 100644 index 00000000..e8bef769 --- /dev/null +++ b/website/content/custom-exercises/index.md @@ -0,0 +1,66 @@ ++++ +title = "Custom Exercises" ++++ + +Custom exercises are a set of exercises maintained by the community. +You can use the same `rustlings` program that you installed with `cargo install rustlings` to run them: + +- 🇯🇵 [Japanese Rustlings](https://github.com/sotanengel/rustlings-jp):A Japanese translation of the Rustlings exercises. +- 🇨🇳 [Simplified Chinese Rustlings](https://github.com/SandmeyerX/rustlings-zh-cn): A simplified Chinese translation of the Rustlings exercises. + +Do you want to create your own set of Rustlings exercises to focus on some specific topic? +Or do you want to translate the original Rustlings exercises? + + + +The support of Rustlings for custom exercises allows you to create your own set of Rustlings exercises to focus on some specific topic. +You could also offer a translation of the original Rustlings exercises as custom exercises. + +## Getting started + +To create custom exercises, install Rustlings and run `rustlings dev new PROJECT_NAME`. +This command will, similar to `cargo new PROJECT_NAME`, create a template directory called `PROJECT_NAME` with all what you need to get started. + +Read the comments in the generated `info.toml` file to understand its format. +It allows you to set a custom welcome and final message and specify the metadata of every exercise. + +## Create an exercise + +Here is an example of the metadata of one file: + +```toml +[[exercises]] +name = "intro1" +hint = """ +To finish this exercise, you need to … +This link might help you …""" +``` + +After entering this in `info.toml`, create the file `intro1.rs` in the `exercises/` directory. +The exercise needs to contain a `main` function, but it can be empty. +Adding tests is recommended. +Look at the official Rustlings exercises for inspiration. + +You can optionally add a solution file `intro1.rs` to the `solutions/` directory. + +Now, run `rustlings dev check`. +It will tell you about any issues with your exercises. +For example, it will tell you to run `rustlings dev update` to update the `Cargo.toml` file to include the new exercise `intro1`. + +`rustlings dev check` will also run your solutions (if you have any) to make sure that they run successfully. + +That's it! +You finished your first exercise 🎉 + +## Publish + +Now, add more exercises and publish them as a Git repository. + +Users just have to clone that repository and run `rustlings` in it to start working on your set of exercises just like the official ones. + +One difference to the official exercises is that the solution files will not be hidden until the user finishes an exercise. +But you can trust the users to not look at the solution too early 😉 + +## Share + +After publishing your set of exercises, open an issue or a pull request in the official Rustlings repository to link to your project in the README 😃 diff --git a/website/input.css b/website/input.css index b26d9ba4..cd7a777b 100644 --- a/website/input.css +++ b/website/input.css @@ -2,22 +2,22 @@ @layer base { h1 { - @apply text-4xl mt-3 mb-3 text-gray-50 font-bold; + @apply text-4xl mt-3 mb-3 font-bold; } h2 { - @apply text-3xl mt-4 mb-1.5 text-gray-50 font-bold; + @apply text-3xl mt-4 mb-1.5 font-bold; } h3 { - @apply text-2xl mt-5 mb-1.5 text-gray-50 font-bold; + @apply text-2xl mt-5 mb-1.5 font-bold; } h4 { - @apply text-xl mt-6 mb-1.5 text-gray-50 font-bold; + @apply text-xl mt-6 mb-1.5 font-bold; } p { @apply mb-2; } a { - @apply text-[#F74C00] underline hover:decoration-orange-400 transition duration-300; + @apply text-[#FFC832] underline hover:decoration-orange-400 transition duration-300; } ul { @apply mt-2 mb-3 ml-1 list-disc list-inside marker:text-sky-600; @@ -41,11 +41,11 @@ @apply max-w-full w-full h-full mx-auto my-5 object-contain md:w-3/4 lg:w-3/5 rounded-sm shadow-sm; } blockquote { - @apply p-4 my-3 border-s-4 border-gray-300 bg-gray-800 italic; + @apply px-3 pt-2 pb-0.5 my-4 border-s-4 border-white/80 bg-white/7 rounded-sm italic; } pre { - @apply px-2 pt-2 pb-px overflow-x-auto text-sm sm:text-base rounded-sm mt-2 mb-4 after:content-[attr(data-lang)] after:text-[8px] after:opacity-40 selection:bg-gray-500/75; + @apply px-2 pt-2 pb-px overflow-x-auto text-sm sm:text-base rounded-sm mt-2 mb-4 after:content-[attr(data-lang)] after:text-[8px] after:opacity-40 selection:bg-white/15; } pre code mark { @apply pb-0.5 pt-1 pr-px text-inherit rounded-xs; diff --git a/website/justfile b/website/justfile index 5c9c6770..6d419138 100644 --- a/website/justfile +++ b/website/justfile @@ -2,4 +2,4 @@ zola: zola serve --open tailwind: - fnm exec --using latest npx @tailwindcss/cli -i input.css -o static/main.css + fnm exec --using latest npx @tailwindcss/cli -w -i input.css -o static/main.css diff --git a/website/templates/404.html b/website/templates/404.html new file mode 100644 index 00000000..ecee207d --- /dev/null +++ b/website/templates/404.html @@ -0,0 +1,16 @@ +{% extends "base.html" %} + +{% import "macros.html" as macros %} + +{% block content %} +
+

DON'T PANIC!

+

404: Page not found!

+ + + + {{ macros::btn(link=get_url(path="/") , content="Back to the homepage") }} +
+{% endblock %} diff --git a/website/templates/anchor-link.html b/website/templates/anchor-link.html new file mode 100644 index 00000000..c8644d96 --- /dev/null +++ b/website/templates/anchor-link.html @@ -0,0 +1,2 @@ + diff --git a/website/templates/base.html b/website/templates/base.html new file mode 100644 index 00000000..64beaab3 --- /dev/null +++ b/website/templates/base.html @@ -0,0 +1,83 @@ + + + + + + + {%- set timestamp = now(timestamp=true) -%} + + {%- if page.title -%} + {% set_global title = page.title %} + {%- elif section.title -%} + {% set_global title = section.title %} + {%- else -%} + {% set_global title = config.title %} + {%- endif -%} + + {%- if page.description -%} + {% set_global description = page.description %} + {%- elif section.description -%} + {% set_global description = section.description %} + {%- else -%} + {% set_global description = config.description %} + {%- endif -%} + + {%- if page.permalink -%} + {% set_global permalink = page.permalink %} + {%- elif section.permalink -%} + {% set_global permalink = section.permalink %} + {%- endif %} + + {%- block title -%}{{- title -}}{%- endblock -%} + + + + + + + + + + + {% if permalink %}{% endif %} + + + +
+ + + +
+ +
+ {% block content %}{% endblock %} +
+ + + + diff --git a/website/templates/index.html b/website/templates/index.html new file mode 100644 index 00000000..58777651 --- /dev/null +++ b/website/templates/index.html @@ -0,0 +1,11 @@ +{% extends "base.html" %} + +{% import "macros.html" as macros %} + +{% block content %} +
+

Rustlings

+ + {{ section.content | replace(from="", to=macros::toc() ) | safe }} +
+{% endblock %} diff --git a/website/templates/macros.html b/website/templates/macros.html new file mode 100644 index 00000000..c40abe53 --- /dev/null +++ b/website/templates/macros.html @@ -0,0 +1,46 @@ +{% macro toc() %} +

Landscape mode recommended on mobile devices

+ + {%- if page.toc -%} + {% set_global toc = page.toc %} + {%- else -%} + {% set_global toc = section.toc %} + {%- endif -%} + + {% if toc %} +
+ +
+ {% endif %} +{% endmacro %} + +{% macro btn(link, content) %} + {{ content | safe }} +{% endmacro %} diff --git a/website/templates/page.html b/website/templates/page.html new file mode 100644 index 00000000..90b269df --- /dev/null +++ b/website/templates/page.html @@ -0,0 +1,11 @@ +{% extends "base.html" %} + +{% import "macros.html" as macros %} + +{% block content %} +
+

{{ page.title }}

+ + {{ page.content | replace(from="", to=macros::toc() ) | safe }} +
+{% endblock %} From fda18e8895a162f484245b8a6a2eb0921632d0c7 Mon Sep 17 00:00:00 2001 From: mo8it Date: Sat, 17 May 2025 12:24:27 +0200 Subject: [PATCH 066/120] Add Ferris SVGs --- website/static/images/happy_ferris.svg | 33 ++++++++++++ website/static/images/panic.svg | 70 ++++++++++++++++++++++++++ 2 files changed, 103 insertions(+) create mode 100644 website/static/images/happy_ferris.svg create mode 100644 website/static/images/panic.svg diff --git a/website/static/images/happy_ferris.svg b/website/static/images/happy_ferris.svg new file mode 100644 index 00000000..c7f240dd --- /dev/null +++ b/website/static/images/happy_ferris.svg @@ -0,0 +1,33 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/website/static/images/panic.svg b/website/static/images/panic.svg new file mode 100644 index 00000000..be55f5e0 --- /dev/null +++ b/website/static/images/panic.svg @@ -0,0 +1,70 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + From 61c17cb349b649223e943b6db0786feacabc8ca5 Mon Sep 17 00:00:00 2001 From: mo8it Date: Sat, 17 May 2025 12:24:44 +0200 Subject: [PATCH 067/120] Change syntax highlighting theme --- website/config.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/website/config.toml b/website/config.toml index 6a9114a9..906bb8bc 100644 --- a/website/config.toml +++ b/website/config.toml @@ -7,7 +7,7 @@ build_search_index = false [markdown] highlight_code = true -highlight_theme = "ayu-mirage" +highlight_theme = "dracula" insert_anchor_links = "heading" From 7e26418952afa7d25d1958ee0e4d810955acf94a Mon Sep 17 00:00:00 2001 From: mo8it Date: Sat, 17 May 2025 12:25:08 +0200 Subject: [PATCH 068/120] Remove the third-party exercises file --- THIRD_PARTY_EXERCISES.md | 53 ---------------------------------------- 1 file changed, 53 deletions(-) delete mode 100644 THIRD_PARTY_EXERCISES.md diff --git a/THIRD_PARTY_EXERCISES.md b/THIRD_PARTY_EXERCISES.md deleted file mode 100644 index 62646c5b..00000000 --- a/THIRD_PARTY_EXERCISES.md +++ /dev/null @@ -1,53 +0,0 @@ -# Third-Party Exercises - -The support of Rustlings for third-party exercises allows you to create your own set of Rustlings exercises to focus on some specific topic. -You could also offer a translation of the original Rustlings exercises as third-party exercises. - -## Getting started - -To create third-party exercises, install Rustlings and run `rustlings dev new PROJECT_NAME`. -This command will, similar to `cargo new PROJECT_NAME`, create a template directory called `PROJECT_NAME` with all what you need to get started. - -Read the comments in the generated `info.toml` file to understand its format. -It allows you to set a custom welcome and final message and specify the metadata of every exercise. - -## Create an exercise - -Here is an example of the metadata of one file: - -```toml -[[exercises]] -name = "intro1" -hint = """ -To finish this exercise, you need to … -This link might help you …""" -``` - -After entering this in `info.toml`, create the file `intro1.rs` in the `exercises/` directory. -The exercise needs to contain a `main` function, but it can be empty. -Adding tests is recommended. -Look at the official Rustlings exercises for inspiration. - -You can optionally add a solution file `intro1.rs` to the `solutions/` directory. - -Now, run `rustlings dev check`. -It will tell you about any issues with your exercises. -For example, it will tell you to run `rustlings dev update` to update the `Cargo.toml` file to include the new exercise `intro1`. - -`rustlings dev check` will also run your solutions (if you have any) to make sure that they run successfully. - -That's it! -You finished your first exercise 🎉 - -## Publish - -Now, add more exercises and publish them as a Git repository. - -Users just have to clone that repository and run `rustlings` in it to start working on your set of exercises just like the official ones. - -One difference to the official exercises is that the solution files will not be hidden until the user finishes an exercise. -But you can trust the users to not look at the solution too early 😉 - -## Share - -After publishing your set of exercises, open an issue or a pull request in the official Rustlings repository to link to your project in the README 😃 From b9d1e636a46ee6bc8ffa5dd889137229d76976ce Mon Sep 17 00:00:00 2001 From: mo8it Date: Sat, 17 May 2025 12:25:32 +0200 Subject: [PATCH 069/120] Reduce the README to the website link --- README.md | 160 +----------------------------------------------------- 1 file changed, 1 insertion(+), 159 deletions(-) diff --git a/README.md b/README.md index 8480b1a3..bb3fe212 100644 --- a/README.md +++ b/README.md @@ -1,161 +1,3 @@ # Rustlings 🦀❤️ -Greetings and welcome to Rustlings. -This project contains small exercises to get you used to reading and writing Rust code. -This includes reading and responding to compiler messages! - -It is recommended to do the Rustlings exercises in parallel to reading [the official Rust book](https://doc.rust-lang.org/book/), the most comprehensive resource for learning Rust 📚️ - -[Rust By Example](https://doc.rust-lang.org/rust-by-example/) is another recommended resource that you might find helpful. -It contains code examples and exercises similar to Rustlings, but online. - -## Getting Started - -### Installing Rust - -Before installing Rustlings, you need to have the **latest version of Rust** installed. -Visit [www.rust-lang.org/tools/install](https://www.rust-lang.org/tools/install) for further instructions on installing Rust. -This will also install _Cargo_, Rust's package/project manager. - -> 🐧 If you are on Linux, make sure you have installed `gcc` (for a linker). -> -> Deb: `sudo apt install gcc` -> -> Dnf: `sudo dnf install gcc` - -> 🍎 If you are on MacOS, make sure you have installed Xcode and its developer tools by running `xcode-select --install`. - -### Installing Rustlings - -The following command will download and compile Rustlings: - -```bash -cargo install rustlings -``` - -
-If the installation fails… (click to expand) - -- Make sure you have the latest Rust version by running `rustup update` -- Try adding the `--locked` flag: `cargo install rustlings --locked` -- Otherwise, please [report the issue](https://github.com/rust-lang/rustlings/issues/new) - -
- -### Initialization - -After installing Rustlings, run the following command to initialize the `rustlings/` directory: - -```bash -rustlings init -``` - -
-If the command rustlings can't be found… (click to expand) - -You are probably using Linux and installed Rust using your package manager. - -Cargo installs binaries to the directory `~/.cargo/bin`. -Sadly, package managers often don't add `~/.cargo/bin` to your `PATH` environment variable. - -The solution is to … - -- either add `~/.cargo/bin` manually to `PATH` -- or to uninstall Rust from the package manager and install it using the official way with `rustup`: https://www.rust-lang.org/tools/install - -
- -Now, go into the newly initialized directory and launch Rustlings for further instructions on getting started with the exercises: - -```bash -cd rustlings/ -rustlings -``` - -## Working environment - -### Editor - -Our general recommendation is [VS Code](https://code.visualstudio.com/) with the [rust-analyzer plugin](https://marketplace.visualstudio.com/items?itemName=rust-lang.rust-analyzer). -But any editor that supports [rust-analyzer](https://rust-analyzer.github.io/) should be enough for working on the exercises. - -### Terminal - -While working with Rustlings, please use a modern terminal for the best user experience. -The default terminal on Linux and Mac should be sufficient. -On Windows, we recommend the [Windows Terminal](https://aka.ms/terminal). - -## Doing exercises - -The exercises are sorted by topic and can be found in the subdirectory `exercises/`. -For every topic, there is an additional `README.md` file with some resources to get you started on the topic. -We highly recommend that you have a look at them before you start 📚️ - -Most exercises contain an error that keeps them from compiling, and it's up to you to fix it! -Some exercises contain tests that need to pass for the exercise to be done ✅ - -Search for `TODO` and `todo!()` to find out what you need to change. -Ask for hints by entering `h` in the _watch mode_ 💡 - -### Watch Mode - -After the [initialization](#initialization), Rustlings can be launched by simply running the command `rustlings`. - -This will start the _watch mode_ which walks you through the exercises in a predefined order (what we think is best for newcomers). -It will rerun the current exercise automatically every time you change the exercise's file in the `exercises/` directory. - -
-If detecting file changes in the exercises/ directory fails… (click to expand) - -> You can add the **`--manual-run`** flag (`rustlings --manual-run`) to manually rerun the current exercise by entering `r` in the watch mode. -> -> Please [report the issue](https://github.com/rust-lang/rustlings/issues/new) with some information about your operating system and whether you run Rustlings in a container or virtual machine (e.g. WSL). - -
- -### Exercise List - -In the [watch mode](#watch-mode) (after launching `rustlings`), you can enter `l` to open the interactive exercise list. - -The list allows you to… - -- See the status of all exercises (done or pending) -- `c`: Continue at another exercise (temporarily skip some exercises or go back to a previous one) -- `r`: Reset status and file of the selected exercise (you need to _reload/reopen_ its file in your editor afterwards) - -See the footer of the list for all possible keys. - -## Questions? - -If you need any help while doing the exercises and the builtin-hints aren't helpful, feel free to ask in the [_Q&A_ category of the discussions](https://github.com/rust-lang/rustlings/discussions/categories/q-a?discussions_q=) if your question wasn't asked yet 💡 - -## Third-Party Exercises - -Third-party exercises are a set of exercises maintained by the community. -You can use the same `rustlings` program that you installed with `cargo install rustlings` to run them: - -- 🇯🇵 [Japanese Rustlings](https://github.com/sotanengel/rustlings-jp):A Japanese translation of the Rustlings exercises. -- 🇨🇳 [Simplified Chinese Rustlings](https://github.com/SandmeyerX/rustlings-zh-cn): A simplified Chinese translation of the Rustlings exercises. - -Do you want to create your own set of Rustlings exercises to focus on some specific topic? -Or do you want to translate the original Rustlings exercises? -Then follow the the guide about [third-party exercises](https://github.com/rust-lang/rustlings/blob/main/THIRD_PARTY_EXERCISES.md)! - -## Continuing On - -Once you've completed Rustlings, put your new knowledge to good use! -Continue practicing your Rust skills by building your own projects, contributing to Rustlings, or finding other open-source projects to contribute to. - -## Uninstalling Rustlings - -If you want to remove Rustlings from your system, run the following command: - -```bash -cargo uninstall rustlings -``` - -## Contributing - -See [CONTRIBUTING.md](https://github.com/rust-lang/rustlings/blob/main/CONTRIBUTING.md) 🔗 - -Thanks to [all the wonderful contributors](https://github.com/rust-lang/rustlings/graphs/contributors) ✨ +➡️ [**rustlings.rust-lang.org**](https://rustlings.rust-lang.org) ⬅️ From 6d5369d4d02092757e0a75ef55cf1ea87bfe2182 Mon Sep 17 00:00:00 2001 From: mo8it Date: Sat, 17 May 2025 12:25:55 +0200 Subject: [PATCH 070/120] Add more menu and footer items --- website/config.toml | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/website/config.toml b/website/config.toml index 906bb8bc..5a360fba 100644 --- a/website/config.toml +++ b/website/config.toml @@ -18,9 +18,24 @@ logo_path = "images/happy_ferris.svg" name = "Home" url = "/" [[extra.menu_items]] +name = "Setup" +url = "/setup" +[[extra.menu_items]] +name = "Usage" +url = "/usage" +[[extra.menu_items]] +name = "Q/A" +url = "https://github.com/rust-lang/rustlings/discussions/categories/q-a?discussions_q=" +[[extra.menu_items]] name = "Custom Exercises" url = "/custom-exercises" [[extra.footer_items]] name = "Repository" url = "https://github.com/rust-lang/rustlings" +[[extra.footer_items]] +name = "Changelog" +url = "https://github.com/rust-lang/rustlings/blob/main/CHANGELOG.md" +[[extra.footer_items]] +name = "MIT License" +url = "https://github.com/rust-lang/rustlings/blob/main/LICENSE" From 2673177b17eac262e70a0ac8f376346fecb636b5 Mon Sep 17 00:00:00 2001 From: mo8it Date: Sat, 17 May 2025 13:02:34 +0200 Subject: [PATCH 071/120] Update header and footer --- website/config.toml | 2 +- website/static/images/rust_logo.svg | 61 +++++++++++++++++++++++++++++ website/templates/base.html | 19 +++++---- 3 files changed, 73 insertions(+), 9 deletions(-) create mode 100644 website/static/images/rust_logo.svg diff --git a/website/config.toml b/website/config.toml index 5a360fba..031e0288 100644 --- a/website/config.toml +++ b/website/config.toml @@ -15,7 +15,7 @@ insert_anchor_links = "heading" logo_path = "images/happy_ferris.svg" [[extra.menu_items]] -name = "Home" +name = "Rustlings" url = "/" [[extra.menu_items]] name = "Setup" diff --git a/website/static/images/rust_logo.svg b/website/static/images/rust_logo.svg new file mode 100644 index 00000000..3b42cfe0 --- /dev/null +++ b/website/static/images/rust_logo.svg @@ -0,0 +1,61 @@ + + + diff --git a/website/templates/base.html b/website/templates/base.html index 64beaab3..afe8d891 100644 --- a/website/templates/base.html +++ b/website/templates/base.html @@ -48,16 +48,16 @@ -
+
-
From 69a9e9cafc36cc73c196e462aa7fb7d812ab1012 Mon Sep 17 00:00:00 2001 From: mo8it Date: Sat, 17 May 2025 22:05:48 +0200 Subject: [PATCH 088/120] Less top margin for blockquotes --- website/input.css | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/website/input.css b/website/input.css index b2536753..af0675d8 100644 --- a/website/input.css +++ b/website/input.css @@ -41,7 +41,7 @@ @apply md:w-3/4 lg:w-3/5; } blockquote { - @apply px-3 pt-2 pb-0.5 my-4 border-s-4 border-white/80 bg-white/7 rounded-sm; + @apply px-3 pt-2 pb-0.5 mb-4 mt-2 border-s-4 border-white/80 bg-white/7 rounded-sm; } pre { From 512ded81c4e6075e1bcfdf4f2675814d556588bc Mon Sep 17 00:00:00 2001 From: mo8it Date: Sat, 17 May 2025 22:05:57 +0200 Subject: [PATCH 089/120] Done community exercises page --- website/content/community-exercises/index.md | 40 ++++++++++++-------- 1 file changed, 24 insertions(+), 16 deletions(-) diff --git a/website/content/community-exercises/index.md b/website/content/community-exercises/index.md index 1c8cd577..0f713d7c 100644 --- a/website/content/community-exercises/index.md +++ b/website/content/community-exercises/index.md @@ -2,37 +2,36 @@ title = "Community Exercises" +++ -Do you want to create your own set of Rustlings exercises to focus on some specific topic? -Or do you want to translate the original Rustlings exercises? - ## List of Community Exercises - 🇯🇵 [Japanese Rustlings](https://github.com/sotanengel/rustlings-jp):A Japanese translation of the Rustlings exercises. - 🇨🇳 [Simplified Chinese Rustlings](https://github.com/SandmeyerX/rustlings-zh-cn): A simplified Chinese translation of the Rustlings exercises. -You can use the same `rustlings` program that you installed with `cargo install rustlings` to run them +> You can use the same `rustlings` program that you installed with `cargo install rustlings` to run community exercises. -The support of Rustlings for community exercises allows you to create your own set of Rustlings exercises to focus on some specific topic. +## Creating Community Exercises + +Rustling's support for community exercises allows you to create your own exercises to focus on some specific topic. You could also offer a translation of the original Rustlings exercises as community exercises. -## Getting started +### Getting Started To create community exercises, install Rustlings and run `rustlings dev new PROJECT_NAME`. -This command will, similar to `cargo new PROJECT_NAME`, create a template directory called `PROJECT_NAME` with all what you need to get started. +This command will, similar to `cargo new PROJECT_NAME`, create the template directory `PROJECT_NAME` with all what you need to get started. -Read the comments in the generated `info.toml` file to understand its format. +_Read the comments_ in the generated `info.toml` file to understand its format. It allows you to set a custom welcome and final message and specify the metadata of every exercise. -## Create an exercise +### Creating an Exercise -Here is an example of the metadata of one file: +Here is an example of the metadata of one exercise: ```toml [[exercises]] name = "intro1" hint = """ To finish this exercise, you need to … -This link might help you …""" +These links might help you …""" ``` After entering this in `info.toml`, create the file `intro1.rs` in the `exercises/` directory. @@ -51,15 +50,24 @@ For example, it will tell you to run `rustlings dev update` to update the `Cargo That's it! You finished your first exercise 🎉 -## Publish +### Cargo.toml + +Except of the `bin` list, you can modify the `Cargo.toml` file as you want. + +> The `bin` list is automatically updated by running `rustlings dev update` + +- You can add dependencies in the `[dependencies]` table. +- You might want to [configure some lints](https://doc.rust-lang.org/cargo/reference/manifest.html#the-lints-section) for all exercises. You can do so in the `[lints.rust]` and `[lints.clippy]` tables. + +### Publishing Now, add more exercises and publish them as a Git repository. -Users just have to clone that repository and run `rustlings` in it to start working on your set of exercises just like the official ones. +Users just have to clone that repository and run `rustlings` in it to start working on your exercises (just like the official ones). One difference to the official exercises is that the solution files will not be hidden until the user finishes an exercise. -But you can trust the users to not look at the solution too early 😉 +But you can trust your users to not open the solution too early 😉 -## Share +### Sharing -After publishing your set of exercises, open an issue or a pull request in the official Rustlings repository to link to your project in the README 😃 +After publishing your community exercises, open an issue or a pull request in the [official Rustlings repository](https://github.com/rust-lang/rustlings) to add your project to the [list of community exercises](#list-of-community-exercises) 😃 From 596e7f36cc0fc8b6b755d444b7f054da19734b8e Mon Sep 17 00:00:00 2001 From: mo8it Date: Sat, 17 May 2025 22:33:00 +0200 Subject: [PATCH 090/120] Add website CI --- .github/workflows/website.yml | 46 +++++++++++++++++++++++++++++++++++ website/package.json | 7 +++--- 2 files changed, 50 insertions(+), 3 deletions(-) create mode 100644 .github/workflows/website.yml diff --git a/.github/workflows/website.yml b/.github/workflows/website.yml new file mode 100644 index 00000000..355d40bd --- /dev/null +++ b/.github/workflows/website.yml @@ -0,0 +1,46 @@ +name: Website + +on: + push: + branches: [main] + +jobs: + # Build & upload the static files as an artifact + build: + defaults: + run: + working-directory: website + + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Install Zola + run: sudo snap install zola + - name: Install TailwindCSS + run: npm install @tailwindcss/cli + - name: Build CSS + - run: npx @tailwindcss/cli -m -i input.css -o static/main.css + - name: Build site + run: zola build + - name: Upload static files as artifact + uses: actions/upload-pages-artifact@v3 + with: + path: public/ + + deploy: + needs: build + + # Grant GITHUB_TOKEN the permissions required to make a Pages deployment + permissions: + pages: write # to deploy to Pages + id-token: write # to verify the deployment originates from an appropriate source + + # Deploy to the github-pages environment + environment: + name: github-pages + url: ${{ steps.deployment.outputs.page_url }} + + runs-on: ubuntu-latest + steps: + - name: Deploy to GitHub Pages + uses: actions/deploy-pages@v4 diff --git a/website/package.json b/website/package.json index ee8a1c88..f5024317 100644 --- a/website/package.json +++ b/website/package.json @@ -1,7 +1,8 @@ { - "devDependencies": { - "rustywind": "^0.24", - "tailwindcss": "^4.1", + "dependencies": { "@tailwindcss/cli": "^4.1" + }, + "devDependencies": { + "rustywind": "^0.24" } } From 47e490a997c37cb28ab4022c04155049b0b26f32 Mon Sep 17 00:00:00 2001 From: mo8it Date: Sat, 17 May 2025 22:33:17 +0200 Subject: [PATCH 091/120] Run rustywind --- website/templates/404.html | 2 +- website/templates/base.html | 10 +++++----- website/templates/page.html | 2 +- website/templates/shortcodes/details.html | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/website/templates/404.html b/website/templates/404.html index 234eb46f..eb9d4691 100644 --- a/website/templates/404.html +++ b/website/templates/404.html @@ -5,7 +5,7 @@

DON'T PANIC!

404: Page not found!

- diff --git a/website/templates/base.html b/website/templates/base.html index 91b6cee8..1a55aebf 100644 --- a/website/templates/base.html +++ b/website/templates/base.html @@ -47,8 +47,8 @@ {% if permalink %}{% endif %} - -
+ +