Compare commits

..

No commits in common. "0f4c42d54ea7322a4ee0ae7036c058c3061e80e9" and "cf3f6fd6a16e81905bb44676d623502aeb8e5d01" have entirely different histories.

18 changed files with 80 additions and 153 deletions

74
Cargo.lock generated
View file

@ -80,9 +80,9 @@ dependencies = [
[[package]] [[package]]
name = "anyhow" name = "anyhow"
version = "1.0.86" version = "1.0.83"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b3d1d046238990b9cf5bcde22a3fb3584ee5cf65fb2765f454ed428c7a0063da" checksum = "25bdb32cbbdce2b519a9cd7df3a678443100e265d5e25ca763b7572a5104f5f3"
[[package]] [[package]]
name = "assert_cmd" name = "assert_cmd"
@ -210,18 +210,18 @@ dependencies = [
[[package]] [[package]]
name = "crossbeam-channel" name = "crossbeam-channel"
version = "0.5.13" version = "0.5.12"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "33480d6946193aa8033910124896ca395333cae7e2d1113d1fef6c3272217df2" checksum = "ab3db02a9c5b5121e1e42fbdb1aeb65f5e02624cc58c43f2884c6ccac0b82f95"
dependencies = [ dependencies = [
"crossbeam-utils", "crossbeam-utils",
] ]
[[package]] [[package]]
name = "crossbeam-utils" name = "crossbeam-utils"
version = "0.8.20" version = "0.8.19"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "22ec99545bb0ed0ea7bb9b8e1e9122ea386ff8a48c0922e43f36d45ab09e0e80" checksum = "248e3bacc7dc6baa3b21e405ee045c3047101a49145e7e9eca583ab4c2ca5345"
[[package]] [[package]]
name = "crossterm" name = "crossterm"
@ -262,9 +262,9 @@ checksum = "fea41bba32d969b513997752735605054bc0dfa92b4c56bf1189f2e174be7a10"
[[package]] [[package]]
name = "either" name = "either"
version = "1.12.0" version = "1.11.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3dca9240753cf90908d7e4aac30f630662b02aebaa1b58a3cadabdb23385b58b" checksum = "a47c1c47d2f5964e29c61246e81db715514cd532db6b5116a25ea3c03d6780a2"
[[package]] [[package]]
name = "equivalent" name = "equivalent"
@ -334,6 +334,12 @@ dependencies = [
"hashbrown", "hashbrown",
] ]
[[package]]
name = "indoc"
version = "2.0.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b248f5224d1d606005e02c97f5aa4e88eeb230488bcc03bc9ca4d7991399f2b5"
[[package]] [[package]]
name = "inotify" name = "inotify"
version = "0.9.6" version = "0.9.6"
@ -397,9 +403,9 @@ dependencies = [
[[package]] [[package]]
name = "libc" name = "libc"
version = "0.2.155" version = "0.2.154"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "97b3888a4aecf77e811145cadf6eef5901f4782c53886191b2f693f24761847c" checksum = "ae743338b92ff9146ce83992f766a31066a91a8c84a45e0e9f21e7cf6de6d346"
[[package]] [[package]]
name = "lock_api" name = "lock_api"
@ -565,9 +571,9 @@ dependencies = [
[[package]] [[package]]
name = "proc-macro2" name = "proc-macro2"
version = "1.0.83" version = "1.0.82"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0b33eb56c327dec362a9e55b3ad14f9d2f0904fb5a5b03b513ab5465399e9f43" checksum = "8ad3d49ab951a01fbaafe34f2ec74122942fe18a3f9814c3268f1bb72042131b"
dependencies = [ dependencies = [
"unicode-ident", "unicode-ident",
] ]
@ -583,21 +589,21 @@ dependencies = [
[[package]] [[package]]
name = "ratatui" name = "ratatui"
version = "0.26.3" version = "0.26.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f44c9e68fd46eda15c646fbb85e1040b657a58cdc8c98db1d97a55930d991eef" checksum = "a564a852040e82671dc50a37d88f3aa83bbc690dfc6844cfe7a2591620206a80"
dependencies = [ dependencies = [
"bitflags 2.5.0", "bitflags 2.5.0",
"cassowary", "cassowary",
"compact_str", "compact_str",
"crossterm", "crossterm",
"indoc",
"itertools", "itertools",
"lru", "lru",
"paste", "paste",
"stability", "stability",
"strum", "strum",
"unicode-segmentation", "unicode-segmentation",
"unicode-truncate",
"unicode-width", "unicode-width",
] ]
@ -678,9 +684,9 @@ dependencies = [
[[package]] [[package]]
name = "rustversion" name = "rustversion"
version = "1.0.17" version = "1.0.16"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "955d28af4278de8121b7ebeb796b6a45735dc01436d898801014aced2773a3d6" checksum = "092474d1a01ea8278f69e6a358998405fae5b8b963ddaeb2b0b04a128bf1dfb0"
[[package]] [[package]]
name = "ryu" name = "ryu"
@ -705,18 +711,18 @@ checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49"
[[package]] [[package]]
name = "serde" name = "serde"
version = "1.0.202" version = "1.0.201"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "226b61a0d411b2ba5ff6d7f73a476ac4f8bb900373459cd00fab8512828ba395" checksum = "780f1cebed1629e4753a1a38a3c72d30b97ec044f0aef68cb26650a3c5cf363c"
dependencies = [ dependencies = [
"serde_derive", "serde_derive",
] ]
[[package]] [[package]]
name = "serde_derive" name = "serde_derive"
version = "1.0.202" version = "1.0.201"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6048858004bcff69094cd972ed40a32500f153bd3be9f716b2eed2e8217c4838" checksum = "c5e405930b9796f1c00bee880d03fc7e0bb4b9a11afc776885ffe84320da2865"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
@ -736,9 +742,9 @@ dependencies = [
[[package]] [[package]]
name = "serde_spanned" name = "serde_spanned"
version = "0.6.6" version = "0.6.5"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "79e674e01f999af37c49f70a6ede167a8a60b2503e56c5599532a65baa5969a0" checksum = "eb3622f419d1296904700073ea6cc23ad690adbd66f13ea683df73298736f0c1"
dependencies = [ dependencies = [
"serde", "serde",
] ]
@ -825,9 +831,9 @@ dependencies = [
[[package]] [[package]]
name = "syn" name = "syn"
version = "2.0.65" version = "2.0.63"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d2863d96a84c6439701d7a38f9de935ec562c8832cc55d1dde0f513b52fad106" checksum = "bf5be731623ca1a1fb7d8be6f261a3be6d3e2337b8a1f97be944d020c8fcb704"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
@ -842,18 +848,18 @@ checksum = "3369f5ac52d5eb6ab48c6b4ffdc8efbcad6b89c765749064ba298f2c68a16a76"
[[package]] [[package]]
name = "toml_datetime" name = "toml_datetime"
version = "0.6.6" version = "0.6.5"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4badfd56924ae69bcc9039335b2e017639ce3f9b001c393c1b2d1ef846ce2cbf" checksum = "3550f4e9685620ac18a50ed434eb3aec30db8ba93b0287467bca5826ea25baf1"
dependencies = [ dependencies = [
"serde", "serde",
] ]
[[package]] [[package]]
name = "toml_edit" name = "toml_edit"
version = "0.22.13" version = "0.22.12"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c127785850e8c20836d49732ae6abfa47616e60bf9d9f57c43c250361a9db96c" checksum = "d3328d4f68a705b2a4498da1d580585d39a6510f98318a2cec3018a7ec61ddef"
dependencies = [ dependencies = [
"indexmap", "indexmap",
"serde", "serde",
@ -874,16 +880,6 @@ version = "1.11.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d4c87d22b6e3f4a18d4d40ef354e97c90fcb14dd91d7dc0aa9d8a1172ebf7202" checksum = "d4c87d22b6e3f4a18d4d40ef354e97c90fcb14dd91d7dc0aa9d8a1172ebf7202"
[[package]]
name = "unicode-truncate"
version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5a5fbabedabe362c618c714dbefda9927b5afc8e2a8102f47f081089a9019226"
dependencies = [
"itertools",
"unicode-width",
]
[[package]] [[package]]
name = "unicode-width" name = "unicode-width"
version = "0.1.12" version = "0.1.12"

View file

@ -20,8 +20,8 @@ license = "MIT"
edition = "2021" edition = "2021"
[workspace.dependencies] [workspace.dependencies]
serde = { version = "1.0.202", features = ["derive"] } serde = { version = "1.0.199", features = ["derive"] }
toml_edit = { version = "0.22.13", default-features = false, features = ["parse", "serde"] } toml_edit = { version = "0.22.12", default-features = false, features = ["parse", "serde"] }
[package] [package]
name = "rustlings" name = "rustlings"
@ -46,13 +46,13 @@ include = [
] ]
[dependencies] [dependencies]
anyhow = "1.0.86" anyhow = "1.0.83"
clap = { version = "4.5.4", features = ["derive"] } clap = { version = "4.5.4", features = ["derive"] }
crossterm = "0.27.0" crossterm = "0.27.0"
hashbrown = "0.14.5" hashbrown = "0.14.5"
notify-debouncer-mini = { version = "0.4.1", default-features = false } notify-debouncer-mini = { version = "0.4.1", default-features = false }
os_pipe = "1.1.5" os_pipe = "1.1.5"
ratatui = { version = "0.26.3", default-features = false, features = ["crossterm"] } ratatui = { version = "0.26.2", default-features = false, features = ["crossterm"] }
rustlings-macros = { path = "rustlings-macros", version = "=6.0.0-beta.9" } rustlings-macros = { path = "rustlings-macros", version = "=6.0.0-beta.9" }
serde_json = "1.0.117" serde_json = "1.0.117"
serde.workspace = true serde.workspace = true

View file

@ -1,5 +1,5 @@
// TODO: Fix the code to print "Hello world!". // Make the code print a greeting to the world.
fn main() { fn main() {
printline!("Hello world!"); printline!("Hello there!")
} }

View file

@ -1,6 +1,6 @@
fn main() { // Make me compile!
// TODO: Add missing keyword.
x = 5;
println!("x has the value {x}"); fn main() {
x = 5;
println!("x has the value {}", x);
} }

View file

@ -1,7 +1,5 @@
fn main() { fn main() {
// TODO: Change the line below to fix the compiler error.
let x; let x;
if x == 10 { if x == 10 {
println!("x is ten!"); println!("x is ten!");
} else { } else {

View file

@ -1,6 +1,4 @@
fn main() { fn main() {
// TODO: Change the line below to fix the compiler error.
let x: i32; let x: i32;
println!("Number {}", x);
println!("Number {x}");
} }

View file

@ -1,9 +1,6 @@
// TODO: Fix the compiler error.
fn main() { fn main() {
let x = 3; let x = 3;
println!("Number {x}"); println!("Number {}", x);
x = 5; // don't change this line
x = 5; // Don't change this line println!("Number {}", x);
println!("Number {x}");
} }

View file

@ -1,8 +1,6 @@
fn main() { fn main() {
let number = "T-H-R-E-E"; // Don't change this line let number = "T-H-R-E-E"; // don't change this line
println!("Spell a number: {}", number); println!("Spell a Number : {}", number);
number = 3; // don't rename this variable
// TODO: Fix the compiler error by changing the line below without renaming the the variable.
number = 3;
println!("Number plus two is : {}", number + 2); println!("Number plus two is : {}", number + 2);
} }

View file

@ -1,6 +1,4 @@
// TODO: Change the line below to fix the compiler error.
const NUMBER = 3; const NUMBER = 3;
fn main() { fn main() {
println!("Number: {NUMBER}"); println!("Number {}", NUMBER);
} }

View file

@ -29,21 +29,20 @@ https://github.com/rust-lang/rustlings/blob/main/CONTRIBUTING.md
# INTRO # INTRO
# TODO: Update exercise
[[exercises]] [[exercises]]
name = "intro1" name = "intro1"
dir = "00_intro" dir = "00_intro"
test = false test = false
hint = """ # TODO: Fix hint
Enter `n` to move on to the next exercise. hint = """Enter `n` to move on to the next exercise. You might need to press ENTER after typing `n`."""
You might need to press ENTER after typing `n`."""
[[exercises]] [[exercises]]
name = "intro2" name = "intro2"
dir = "00_intro" dir = "00_intro"
test = false test = false
hint = """ hint = """
The compiler is informing us that we've got the name of the print macro wrong. The compiler is informing us that we've got the name of the print macro wrong, and has suggested an alternative."""
It also suggests an alternative."""
# VARIABLES # VARIABLES
@ -52,18 +51,18 @@ name = "variables1"
dir = "01_variables" dir = "01_variables"
test = false test = false
hint = """ hint = """
The declaration in the `main` function is missing a keyword that is needed The declaration in the first line in the main function is missing a keyword
in Rust to create a new variable binding.""" that is needed in Rust to create a new variable binding."""
[[exercises]] [[exercises]]
name = "variables2" name = "variables2"
dir = "01_variables" dir = "01_variables"
test = false test = false
hint = """ hint = """
The compiler message is saying that Rust can't infer the type that the The compiler message is saying that Rust cannot infer the type that the
variable binding `x` has with what is given here. variable binding `x` has with what is given here.
What happens if you annotate the first line in the `main` function with a type What happens if you annotate the first line in the main function with a type
annotation? annotation?
What if you give `x` a value? What if you give `x` a value?
@ -79,9 +78,9 @@ name = "variables3"
dir = "01_variables" dir = "01_variables"
test = false test = false
hint = """ hint = """
In this exercise, we have a variable binding that we've created in the `main` Oops! In this exercise, we have a variable binding that we've created on in the
function, and we're trying to use it in the next line, but we haven't given it first line in the `main` function, and we're trying to use it in the next line,
a value. but we haven't given it a value.
We can't print out something that isn't there; try giving `x` a value! We can't print out something that isn't there; try giving `x` a value!
@ -93,7 +92,7 @@ name = "variables4"
dir = "01_variables" dir = "01_variables"
test = false test = false
hint = """ hint = """
In Rust, variable bindings are immutable by default. But here, we're trying In Rust, variable bindings are immutable by default. But here we're trying
to reassign a different value to `x`! There's a keyword we can use to make to reassign a different value to `x`! There's a keyword we can use to make
a variable binding mutable instead.""" a variable binding mutable instead."""
@ -121,12 +120,12 @@ dir = "01_variables"
test = false test = false
hint = """ hint = """
We know about variables and mutability, but there is another important type of We know about variables and mutability, but there is another important type of
variables available: constants. variable available: constants.
Constants are always immutable. They are declared with the keyword `const` instead Constants are always immutable and they are declared with keyword `const` rather
of `let`. than keyword `let`.
The type of Constants must always be annotated. Constants types must also always be annotated.
Read more about constants and the differences between variables and constants Read more about constants and the differences between variables and constants
under 'Constants' in the book's section 'Variables and Mutability': under 'Constants' in the book's section 'Variables and Mutability':
@ -140,7 +139,7 @@ name = "functions1"
dir = "02_functions" dir = "02_functions"
test = false test = false
hint = """ hint = """
This `main` function is calling a function that it expects to exist, but the This main function is calling a function that it expects to exist, but the
function doesn't exist. It expects this function to have the name `call_me`. function doesn't exist. It expects this function to have the name `call_me`.
It expects this function to not take any arguments and not return a value. It expects this function to not take any arguments and not return a value.
Sounds a lot like `main`, doesn't it?""" Sounds a lot like `main`, doesn't it?"""
@ -689,7 +688,7 @@ test = false
hint = """ hint = """
If other functions can return a `Result`, why shouldn't `main`? It's a fairly If other functions can return a `Result`, why shouldn't `main`? It's a fairly
common convention to return something like `Result<(), ErrorType>` from your common convention to return something like `Result<(), ErrorType>` from your
`main` function. main function.
The unit (`()`) type is there because nothing is really needed in terms of The unit (`()`) type is there because nothing is really needed in terms of
positive results.""" positive results."""

View file

@ -1,2 +1 @@
// The exercise `intro1` only requires entering `n` in the terminal to go to the next exercise. // Solutions will be available before the stable release. Thank you for testing the beta version 🥰
// It is just an introduction to how Rustlings works.

View file

@ -1,4 +1 @@
fn main() { // Solutions will be available before the stable release. Thank you for testing the beta version 🥰
// `println!` instead of `printline!`.
println!("Hello world!");
}

View file

@ -1,6 +1 @@
fn main() { // Solutions will be available before the stable release. Thank you for testing the beta version 🥰
// Declaring variables requires the `let` keyword.
let x = 5;
println!("x has the value {x}");
}

View file

@ -1,16 +1 @@
fn main() { // Solutions will be available before the stable release. Thank you for testing the beta version 🥰
// The easiest way to fix the compiler error is to initialize the
// variable `x`. By setting its value to an integer, Rust infers its type
// as `i32` which is the default type for integers.
let x = 42;
// But we can enforce a type different from the default `i32` by adding
// a type annotation:
// let x: u8 = 42;
if x == 10 {
println!("x is ten!");
} else {
println!("x is not ten!");
}
}

View file

@ -1,13 +1 @@
fn main() { // Solutions will be available before the stable release. Thank you for testing the beta version 🥰
// Reading uninitialized variables isn't allowed in Rust!
// Therefore, we need to assign a value first.
let x: i32 = 42;
println!("Number {x}");
// It possible to declare a variable and initialize it later.
// But it can't be used before initialization.
let y: i32;
y = 42;
println!("Number {y}");
}

View file

@ -1,9 +1 @@
fn main() { // Solutions will be available before the stable release. Thank you for testing the beta version 🥰
// In Rust, variables are immutable by default.
// Adding the `mut` keyword after `let` makes the declared variable mutable.
let mut x = 3;
println!("Number {x}");
x = 5; // Don't change this line
println!("Number {x}");
}

View file

@ -1,9 +1 @@
fn main() { // Solutions will be available before the stable release. Thank you for testing the beta version 🥰
let number = "T-H-R-E-E"; // Don't change this line
println!("Spell a number: {}", number);
// Using variable shadowing
// https://doc.rust-lang.org/book/ch03-01-variables-and-mutability.html#shadowing
let number = 3;
println!("Number plus two is: {}", number + 2);
}

View file

@ -1,6 +1 @@
// The type of constants must always be annotated. // Solutions will be available before the stable release. Thank you for testing the beta version 🥰
const NUMBER: u64 = 3;
fn main() {
println!("Number: {NUMBER}");
}