mirror of
https://github.com/rust-lang/rustlings.git
synced 2025-01-09 20:03:24 +03:00
Compare commits
No commits in common. "0f4c42d54ea7322a4ee0ae7036c058c3061e80e9" and "cf3f6fd6a16e81905bb44676d623502aeb8e5d01" have entirely different histories.
0f4c42d54e
...
cf3f6fd6a1
74
Cargo.lock
generated
74
Cargo.lock
generated
|
@ -80,9 +80,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "anyhow"
|
||||
version = "1.0.86"
|
||||
version = "1.0.83"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b3d1d046238990b9cf5bcde22a3fb3584ee5cf65fb2765f454ed428c7a0063da"
|
||||
checksum = "25bdb32cbbdce2b519a9cd7df3a678443100e265d5e25ca763b7572a5104f5f3"
|
||||
|
||||
[[package]]
|
||||
name = "assert_cmd"
|
||||
|
@ -210,18 +210,18 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "crossbeam-channel"
|
||||
version = "0.5.13"
|
||||
version = "0.5.12"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "33480d6946193aa8033910124896ca395333cae7e2d1113d1fef6c3272217df2"
|
||||
checksum = "ab3db02a9c5b5121e1e42fbdb1aeb65f5e02624cc58c43f2884c6ccac0b82f95"
|
||||
dependencies = [
|
||||
"crossbeam-utils",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "crossbeam-utils"
|
||||
version = "0.8.20"
|
||||
version = "0.8.19"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "22ec99545bb0ed0ea7bb9b8e1e9122ea386ff8a48c0922e43f36d45ab09e0e80"
|
||||
checksum = "248e3bacc7dc6baa3b21e405ee045c3047101a49145e7e9eca583ab4c2ca5345"
|
||||
|
||||
[[package]]
|
||||
name = "crossterm"
|
||||
|
@ -262,9 +262,9 @@ checksum = "fea41bba32d969b513997752735605054bc0dfa92b4c56bf1189f2e174be7a10"
|
|||
|
||||
[[package]]
|
||||
name = "either"
|
||||
version = "1.12.0"
|
||||
version = "1.11.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3dca9240753cf90908d7e4aac30f630662b02aebaa1b58a3cadabdb23385b58b"
|
||||
checksum = "a47c1c47d2f5964e29c61246e81db715514cd532db6b5116a25ea3c03d6780a2"
|
||||
|
||||
[[package]]
|
||||
name = "equivalent"
|
||||
|
@ -334,6 +334,12 @@ dependencies = [
|
|||
"hashbrown",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "indoc"
|
||||
version = "2.0.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b248f5224d1d606005e02c97f5aa4e88eeb230488bcc03bc9ca4d7991399f2b5"
|
||||
|
||||
[[package]]
|
||||
name = "inotify"
|
||||
version = "0.9.6"
|
||||
|
@ -397,9 +403,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "libc"
|
||||
version = "0.2.155"
|
||||
version = "0.2.154"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "97b3888a4aecf77e811145cadf6eef5901f4782c53886191b2f693f24761847c"
|
||||
checksum = "ae743338b92ff9146ce83992f766a31066a91a8c84a45e0e9f21e7cf6de6d346"
|
||||
|
||||
[[package]]
|
||||
name = "lock_api"
|
||||
|
@ -565,9 +571,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "proc-macro2"
|
||||
version = "1.0.83"
|
||||
version = "1.0.82"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0b33eb56c327dec362a9e55b3ad14f9d2f0904fb5a5b03b513ab5465399e9f43"
|
||||
checksum = "8ad3d49ab951a01fbaafe34f2ec74122942fe18a3f9814c3268f1bb72042131b"
|
||||
dependencies = [
|
||||
"unicode-ident",
|
||||
]
|
||||
|
@ -583,21 +589,21 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "ratatui"
|
||||
version = "0.26.3"
|
||||
version = "0.26.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f44c9e68fd46eda15c646fbb85e1040b657a58cdc8c98db1d97a55930d991eef"
|
||||
checksum = "a564a852040e82671dc50a37d88f3aa83bbc690dfc6844cfe7a2591620206a80"
|
||||
dependencies = [
|
||||
"bitflags 2.5.0",
|
||||
"cassowary",
|
||||
"compact_str",
|
||||
"crossterm",
|
||||
"indoc",
|
||||
"itertools",
|
||||
"lru",
|
||||
"paste",
|
||||
"stability",
|
||||
"strum",
|
||||
"unicode-segmentation",
|
||||
"unicode-truncate",
|
||||
"unicode-width",
|
||||
]
|
||||
|
||||
|
@ -678,9 +684,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "rustversion"
|
||||
version = "1.0.17"
|
||||
version = "1.0.16"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "955d28af4278de8121b7ebeb796b6a45735dc01436d898801014aced2773a3d6"
|
||||
checksum = "092474d1a01ea8278f69e6a358998405fae5b8b963ddaeb2b0b04a128bf1dfb0"
|
||||
|
||||
[[package]]
|
||||
name = "ryu"
|
||||
|
@ -705,18 +711,18 @@ checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49"
|
|||
|
||||
[[package]]
|
||||
name = "serde"
|
||||
version = "1.0.202"
|
||||
version = "1.0.201"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "226b61a0d411b2ba5ff6d7f73a476ac4f8bb900373459cd00fab8512828ba395"
|
||||
checksum = "780f1cebed1629e4753a1a38a3c72d30b97ec044f0aef68cb26650a3c5cf363c"
|
||||
dependencies = [
|
||||
"serde_derive",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "serde_derive"
|
||||
version = "1.0.202"
|
||||
version = "1.0.201"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6048858004bcff69094cd972ed40a32500f153bd3be9f716b2eed2e8217c4838"
|
||||
checksum = "c5e405930b9796f1c00bee880d03fc7e0bb4b9a11afc776885ffe84320da2865"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
|
@ -736,9 +742,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "serde_spanned"
|
||||
version = "0.6.6"
|
||||
version = "0.6.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "79e674e01f999af37c49f70a6ede167a8a60b2503e56c5599532a65baa5969a0"
|
||||
checksum = "eb3622f419d1296904700073ea6cc23ad690adbd66f13ea683df73298736f0c1"
|
||||
dependencies = [
|
||||
"serde",
|
||||
]
|
||||
|
@ -825,9 +831,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "syn"
|
||||
version = "2.0.65"
|
||||
version = "2.0.63"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d2863d96a84c6439701d7a38f9de935ec562c8832cc55d1dde0f513b52fad106"
|
||||
checksum = "bf5be731623ca1a1fb7d8be6f261a3be6d3e2337b8a1f97be944d020c8fcb704"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
|
@ -842,18 +848,18 @@ checksum = "3369f5ac52d5eb6ab48c6b4ffdc8efbcad6b89c765749064ba298f2c68a16a76"
|
|||
|
||||
[[package]]
|
||||
name = "toml_datetime"
|
||||
version = "0.6.6"
|
||||
version = "0.6.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4badfd56924ae69bcc9039335b2e017639ce3f9b001c393c1b2d1ef846ce2cbf"
|
||||
checksum = "3550f4e9685620ac18a50ed434eb3aec30db8ba93b0287467bca5826ea25baf1"
|
||||
dependencies = [
|
||||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "toml_edit"
|
||||
version = "0.22.13"
|
||||
version = "0.22.12"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c127785850e8c20836d49732ae6abfa47616e60bf9d9f57c43c250361a9db96c"
|
||||
checksum = "d3328d4f68a705b2a4498da1d580585d39a6510f98318a2cec3018a7ec61ddef"
|
||||
dependencies = [
|
||||
"indexmap",
|
||||
"serde",
|
||||
|
@ -874,16 +880,6 @@ version = "1.11.0"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
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]]
|
||||
name = "unicode-width"
|
||||
version = "0.1.12"
|
||||
|
|
|
@ -20,8 +20,8 @@ license = "MIT"
|
|||
edition = "2021"
|
||||
|
||||
[workspace.dependencies]
|
||||
serde = { version = "1.0.202", features = ["derive"] }
|
||||
toml_edit = { version = "0.22.13", default-features = false, features = ["parse", "serde"] }
|
||||
serde = { version = "1.0.199", features = ["derive"] }
|
||||
toml_edit = { version = "0.22.12", default-features = false, features = ["parse", "serde"] }
|
||||
|
||||
[package]
|
||||
name = "rustlings"
|
||||
|
@ -46,13 +46,13 @@ include = [
|
|||
]
|
||||
|
||||
[dependencies]
|
||||
anyhow = "1.0.86"
|
||||
anyhow = "1.0.83"
|
||||
clap = { version = "4.5.4", features = ["derive"] }
|
||||
crossterm = "0.27.0"
|
||||
hashbrown = "0.14.5"
|
||||
notify-debouncer-mini = { version = "0.4.1", default-features = false }
|
||||
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" }
|
||||
serde_json = "1.0.117"
|
||||
serde.workspace = true
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
// TODO: Fix the code to print "Hello world!".
|
||||
// Make the code print a greeting to the world.
|
||||
|
||||
fn main() {
|
||||
printline!("Hello world!");
|
||||
printline!("Hello there!")
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
fn main() {
|
||||
// TODO: Add missing keyword.
|
||||
x = 5;
|
||||
// Make me compile!
|
||||
|
||||
println!("x has the value {x}");
|
||||
fn main() {
|
||||
x = 5;
|
||||
println!("x has the value {}", x);
|
||||
}
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
fn main() {
|
||||
// TODO: Change the line below to fix the compiler error.
|
||||
let x;
|
||||
|
||||
if x == 10 {
|
||||
println!("x is ten!");
|
||||
} else {
|
||||
|
|
|
@ -1,6 +1,4 @@
|
|||
fn main() {
|
||||
// TODO: Change the line below to fix the compiler error.
|
||||
let x: i32;
|
||||
|
||||
println!("Number {x}");
|
||||
println!("Number {}", x);
|
||||
}
|
||||
|
|
|
@ -1,9 +1,6 @@
|
|||
// TODO: Fix the compiler error.
|
||||
|
||||
fn main() {
|
||||
let x = 3;
|
||||
println!("Number {x}");
|
||||
|
||||
x = 5; // Don't change this line
|
||||
println!("Number {x}");
|
||||
println!("Number {}", x);
|
||||
x = 5; // don't change this line
|
||||
println!("Number {}", x);
|
||||
}
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
fn main() {
|
||||
let number = "T-H-R-E-E"; // Don't change this line
|
||||
println!("Spell a number: {}", number);
|
||||
|
||||
// TODO: Fix the compiler error by changing the line below without renaming the the variable.
|
||||
number = 3;
|
||||
println!("Number plus two is: {}", number + 2);
|
||||
let number = "T-H-R-E-E"; // don't change this line
|
||||
println!("Spell a Number : {}", number);
|
||||
number = 3; // don't rename this variable
|
||||
println!("Number plus two is : {}", number + 2);
|
||||
}
|
||||
|
|
|
@ -1,6 +1,4 @@
|
|||
// TODO: Change the line below to fix the compiler error.
|
||||
const NUMBER = 3;
|
||||
|
||||
fn main() {
|
||||
println!("Number: {NUMBER}");
|
||||
println!("Number {}", NUMBER);
|
||||
}
|
||||
|
|
|
@ -29,21 +29,20 @@ https://github.com/rust-lang/rustlings/blob/main/CONTRIBUTING.md
|
|||
|
||||
# INTRO
|
||||
|
||||
# TODO: Update exercise
|
||||
[[exercises]]
|
||||
name = "intro1"
|
||||
dir = "00_intro"
|
||||
test = false
|
||||
hint = """
|
||||
Enter `n` to move on to the next exercise.
|
||||
You might need to press ENTER after typing `n`."""
|
||||
# TODO: Fix hint
|
||||
hint = """Enter `n` to move on to the next exercise. You might need to press ENTER after typing `n`."""
|
||||
|
||||
[[exercises]]
|
||||
name = "intro2"
|
||||
dir = "00_intro"
|
||||
test = false
|
||||
hint = """
|
||||
The compiler is informing us that we've got the name of the print macro wrong.
|
||||
It also suggests an alternative."""
|
||||
The compiler is informing us that we've got the name of the print macro wrong, and has suggested an alternative."""
|
||||
|
||||
# VARIABLES
|
||||
|
||||
|
@ -52,18 +51,18 @@ name = "variables1"
|
|||
dir = "01_variables"
|
||||
test = false
|
||||
hint = """
|
||||
The declaration in the `main` function is missing a keyword that is needed
|
||||
in Rust to create a new variable binding."""
|
||||
The declaration in the first line in the main function is missing a keyword
|
||||
that is needed in Rust to create a new variable binding."""
|
||||
|
||||
[[exercises]]
|
||||
name = "variables2"
|
||||
dir = "01_variables"
|
||||
test = false
|
||||
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.
|
||||
|
||||
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?
|
||||
|
||||
What if you give `x` a value?
|
||||
|
@ -79,9 +78,9 @@ name = "variables3"
|
|||
dir = "01_variables"
|
||||
test = false
|
||||
hint = """
|
||||
In this exercise, we have a variable binding that we've created in the `main`
|
||||
function, and we're trying to use it in the next line, but we haven't given it
|
||||
a value.
|
||||
Oops! In this exercise, we have a variable binding that we've created on in the
|
||||
first line in the `main` function, and we're trying to use it in the next line,
|
||||
but we haven't given it 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"
|
||||
test = false
|
||||
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
|
||||
a variable binding mutable instead."""
|
||||
|
||||
|
@ -121,12 +120,12 @@ dir = "01_variables"
|
|||
test = false
|
||||
hint = """
|
||||
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
|
||||
of `let`.
|
||||
Constants are always immutable and they are declared with keyword `const` rather
|
||||
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
|
||||
under 'Constants' in the book's section 'Variables and Mutability':
|
||||
|
@ -140,7 +139,7 @@ name = "functions1"
|
|||
dir = "02_functions"
|
||||
test = false
|
||||
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`.
|
||||
It expects this function to not take any arguments and not return a value.
|
||||
Sounds a lot like `main`, doesn't it?"""
|
||||
|
@ -689,7 +688,7 @@ test = false
|
|||
hint = """
|
||||
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
|
||||
`main` function.
|
||||
main function.
|
||||
|
||||
The unit (`()`) type is there because nothing is really needed in terms of
|
||||
positive results."""
|
||||
|
|
|
@ -1,2 +1 @@
|
|||
// The exercise `intro1` only requires entering `n` in the terminal to go to the next exercise.
|
||||
// It is just an introduction to how Rustlings works.
|
||||
// Solutions will be available before the stable release. Thank you for testing the beta version 🥰
|
||||
|
|
|
@ -1,4 +1 @@
|
|||
fn main() {
|
||||
// `println!` instead of `printline!`.
|
||||
println!("Hello world!");
|
||||
}
|
||||
// Solutions will be available before the stable release. Thank you for testing the beta version 🥰
|
||||
|
|
|
@ -1,6 +1 @@
|
|||
fn main() {
|
||||
// Declaring variables requires the `let` keyword.
|
||||
let x = 5;
|
||||
|
||||
println!("x has the value {x}");
|
||||
}
|
||||
// Solutions will be available before the stable release. Thank you for testing the beta version 🥰
|
||||
|
|
|
@ -1,16 +1 @@
|
|||
fn main() {
|
||||
// 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!");
|
||||
}
|
||||
}
|
||||
// Solutions will be available before the stable release. Thank you for testing the beta version 🥰
|
||||
|
|
|
@ -1,13 +1 @@
|
|||
fn main() {
|
||||
// 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}");
|
||||
}
|
||||
// Solutions will be available before the stable release. Thank you for testing the beta version 🥰
|
||||
|
|
|
@ -1,9 +1 @@
|
|||
fn main() {
|
||||
// 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}");
|
||||
}
|
||||
// Solutions will be available before the stable release. Thank you for testing the beta version 🥰
|
||||
|
|
|
@ -1,9 +1 @@
|
|||
fn main() {
|
||||
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);
|
||||
}
|
||||
// Solutions will be available before the stable release. Thank you for testing the beta version 🥰
|
||||
|
|
|
@ -1,6 +1 @@
|
|||
// The type of constants must always be annotated.
|
||||
const NUMBER: u64 = 3;
|
||||
|
||||
fn main() {
|
||||
println!("Number: {NUMBER}");
|
||||
}
|
||||
// Solutions will be available before the stable release. Thank you for testing the beta version 🥰
|
||||
|
|
Loading…
Reference in a new issue