mirror of
https://github.com/rust-lang/rustlings.git
synced 2024-12-31 00:00:03 +03:00
Compare commits
No commits in common. "0847b3a4bfeebd0d18578de8f45b7e4571fc6e77" and "c793416495b3e015cbd4fb5ea23070aad8611614" have entirely different histories.
0847b3a4bf
...
c793416495
21
CHANGELOG.md
21
CHANGELOG.md
|
@ -1,22 +1,3 @@
|
||||||
<a name="6.1.0"></a>
|
|
||||||
|
|
||||||
## 6.1.0 (2024-07-10)
|
|
||||||
|
|
||||||
#### Added
|
|
||||||
|
|
||||||
- `dev check`: Check that all exercises (including third-party ones) include at least one `TODO` comment.
|
|
||||||
- `dev check`: Check that all exercises actually fail to run (not already solved).
|
|
||||||
|
|
||||||
#### Changed
|
|
||||||
|
|
||||||
- Make enum variants more consistent between enum exercises.
|
|
||||||
- `iterators3`: Teach about the possible case of integer overflow during division.
|
|
||||||
|
|
||||||
#### Fixed
|
|
||||||
|
|
||||||
- Exit with a helpful error message on missing/unsupported terminal/TTY.
|
|
||||||
- Mark the last exercise as done.
|
|
||||||
|
|
||||||
<a name="6.0.1"></a>
|
<a name="6.0.1"></a>
|
||||||
|
|
||||||
## 6.0.1 (2024-07-04)
|
## 6.0.1 (2024-07-04)
|
||||||
|
@ -83,7 +64,7 @@ This should avoid issues related to the language server or to running exercises,
|
||||||
Clippy lints are now shown on all exercises, not only the Clippy exercises 📎
|
Clippy lints are now shown on all exercises, not only the Clippy exercises 📎
|
||||||
Make Clippy your friend from early on 🥰
|
Make Clippy your friend from early on 🥰
|
||||||
|
|
||||||
### Third-party exercises
|
### Third party exercises
|
||||||
|
|
||||||
Rustlings now supports third-party exercises!
|
Rustlings now supports third-party exercises!
|
||||||
|
|
||||||
|
|
50
Cargo.lock
generated
50
Cargo.lock
generated
|
@ -151,9 +151,9 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "clap"
|
name = "clap"
|
||||||
version = "4.5.9"
|
version = "4.5.8"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "64acc1846d54c1fe936a78dc189c34e28d3f5afc348403f28ecf53660b9b8462"
|
checksum = "84b3edb18336f4df585bc9aa31dd99c036dfa5dc5e9a2939a722a188f3a8970d"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"clap_builder",
|
"clap_builder",
|
||||||
"clap_derive",
|
"clap_derive",
|
||||||
|
@ -161,9 +161,9 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "clap_builder"
|
name = "clap_builder"
|
||||||
version = "4.5.9"
|
version = "4.5.8"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "6fb8393d67ba2e7bfaf28a23458e4e2b543cc73a99595511eb207fdb8aede942"
|
checksum = "c1c09dd5ada6c6c78075d6fd0da3f90d8080651e2d6cc8eb2f1aaa4034ced708"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anstream",
|
"anstream",
|
||||||
"anstyle",
|
"anstyle",
|
||||||
|
@ -354,6 +354,15 @@ version = "1.70.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "f8478577c03552c21db0e2724ffb8986a5ce7af88107e6be5d2ee6e158c12800"
|
checksum = "f8478577c03552c21db0e2724ffb8986a5ce7af88107e6be5d2ee6e158c12800"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "itertools"
|
||||||
|
version = "0.12.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "ba291022dbbd398a455acf126c1e341954079855bc60dfdda641363bd6922569"
|
||||||
|
dependencies = [
|
||||||
|
"either",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "itertools"
|
name = "itertools"
|
||||||
version = "0.13.0"
|
version = "0.13.0"
|
||||||
|
@ -585,7 +594,7 @@ dependencies = [
|
||||||
"cassowary",
|
"cassowary",
|
||||||
"compact_str",
|
"compact_str",
|
||||||
"crossterm",
|
"crossterm",
|
||||||
"itertools",
|
"itertools 0.13.0",
|
||||||
"lru",
|
"lru",
|
||||||
"paste",
|
"paste",
|
||||||
"stability",
|
"stability",
|
||||||
|
@ -645,7 +654,7 @@ checksum = "7a66a03ae7c801facd77a29370b4faec201768915ac14a721ba36f20bc9c209b"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rustlings"
|
name = "rustlings"
|
||||||
version = "6.1.0"
|
version = "6.0.1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"assert_cmd",
|
"assert_cmd",
|
||||||
|
@ -664,7 +673,7 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rustlings-macros"
|
name = "rustlings-macros"
|
||||||
version = "6.1.0"
|
version = "6.0.1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"quote",
|
"quote",
|
||||||
"serde",
|
"serde",
|
||||||
|
@ -700,18 +709,18 @@ checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "serde"
|
name = "serde"
|
||||||
version = "1.0.204"
|
version = "1.0.203"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "bc76f558e0cbb2a839d37354c575f1dc3fdc6546b5be373ba43d95f231bf7c12"
|
checksum = "7253ab4de971e72fb7be983802300c30b5a7f0c2e56fab8abfc6a214307c0094"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"serde_derive",
|
"serde_derive",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "serde_derive"
|
name = "serde_derive"
|
||||||
version = "1.0.204"
|
version = "1.0.203"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "e0cd7e117be63d3c3678776753929474f3b04a43a080c744d6b0ae2a8c28e222"
|
checksum = "500cbc0ebeb6f46627f50f3f5811ccf6bf00643be300b4c3eabc0ef55dc5b5ba"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
|
@ -776,9 +785,9 @@ checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "stability"
|
name = "stability"
|
||||||
version = "0.2.1"
|
version = "0.2.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "d904e7009df136af5297832a3ace3370cd14ff1546a232f4f185036c2736fcac"
|
checksum = "2ff9eaf853dec4c8802325d8b6d3dffa86cc707fd7a1a4cdbf416e13b061787a"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"quote",
|
"quote",
|
||||||
"syn",
|
"syn",
|
||||||
|
@ -820,9 +829,9 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "syn"
|
name = "syn"
|
||||||
version = "2.0.70"
|
version = "2.0.68"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "2f0209b68b3613b093e0ec905354eccaedcfe83b8cb37cbdeae64026c3064c16"
|
checksum = "901fa70d88b9d6c98022e23b4136f9f3e54e4662c3bc1bd1d84a42a9a0f0c1e9"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
|
@ -846,9 +855,9 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "toml_edit"
|
name = "toml_edit"
|
||||||
version = "0.22.15"
|
version = "0.22.14"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "d59a3a72298453f564e2b111fa896f8d07fabb36f51f06d7e875fc5e0b5a3ef1"
|
checksum = "f21c7aaf97f1bd9ca9d4f9e73b0a6c74bd5afef56f2bc931943a6e1c37e04e38"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"indexmap",
|
"indexmap",
|
||||||
"serde",
|
"serde",
|
||||||
|
@ -871,12 +880,11 @@ checksum = "d4c87d22b6e3f4a18d4d40ef354e97c90fcb14dd91d7dc0aa9d8a1172ebf7202"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "unicode-truncate"
|
name = "unicode-truncate"
|
||||||
version = "1.1.0"
|
version = "1.0.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "b3644627a5af5fa321c95b9b235a72fd24cd29c648c2c379431e6628655627bf"
|
checksum = "5a5fbabedabe362c618c714dbefda9927b5afc8e2a8102f47f081089a9019226"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"itertools",
|
"itertools 0.12.1",
|
||||||
"unicode-segmentation",
|
|
||||||
"unicode-width",
|
"unicode-width",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
10
Cargo.toml
10
Cargo.toml
|
@ -8,7 +8,7 @@ exclude = [
|
||||||
]
|
]
|
||||||
|
|
||||||
[workspace.package]
|
[workspace.package]
|
||||||
version = "6.1.0"
|
version = "6.0.1"
|
||||||
authors = [
|
authors = [
|
||||||
"Liv <mokou@fastmail.com>",
|
"Liv <mokou@fastmail.com>",
|
||||||
"Mo Bitar <mo8it@proton.me>",
|
"Mo Bitar <mo8it@proton.me>",
|
||||||
|
@ -20,8 +20,8 @@ license = "MIT"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|
||||||
[workspace.dependencies]
|
[workspace.dependencies]
|
||||||
serde = { version = "1.0.204", features = ["derive"] }
|
serde = { version = "1.0.203", features = ["derive"] }
|
||||||
toml_edit = { version = "0.22.15", default-features = false, features = ["parse", "serde"] }
|
toml_edit = { version = "0.22.14", default-features = false, features = ["parse", "serde"] }
|
||||||
|
|
||||||
[package]
|
[package]
|
||||||
name = "rustlings"
|
name = "rustlings"
|
||||||
|
@ -47,13 +47,13 @@ include = [
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
anyhow = "1.0.86"
|
anyhow = "1.0.86"
|
||||||
clap = { version = "4.5.9", features = ["derive"] }
|
clap = { version = "4.5.8", 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.2.0"
|
os_pipe = "1.2.0"
|
||||||
ratatui = { version = "0.27.0", default-features = false, features = ["crossterm"] }
|
ratatui = { version = "0.27.0", default-features = false, features = ["crossterm"] }
|
||||||
rustlings-macros = { path = "rustlings-macros", version = "=6.1.0" }
|
rustlings-macros = { path = "rustlings-macros", version = "=6.0.1" }
|
||||||
serde_json = "1.0.120"
|
serde_json = "1.0.120"
|
||||||
serde.workspace = true
|
serde.workspace = true
|
||||||
toml_edit.workspace = true
|
toml_edit.workspace = true
|
||||||
|
|
|
@ -8,11 +8,11 @@ mod tests {
|
||||||
// Don't add, change or remove any line.
|
// Don't add, change or remove any line.
|
||||||
#[test]
|
#[test]
|
||||||
fn move_semantics4() {
|
fn move_semantics4() {
|
||||||
let mut x = Vec::new();
|
let mut x = 100;
|
||||||
let y = &mut x;
|
let y = &mut x;
|
||||||
let z = &mut x;
|
let z = &mut x;
|
||||||
y.push(42);
|
*y += 100;
|
||||||
z.push(13);
|
*z += 1000;
|
||||||
assert_eq!(x, [42, 13]);
|
assert_eq!(x, 1200);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,14 @@
|
||||||
// TODO: Fix the compiler errors without changing anything except adding or
|
// TODO: Fix the compiler errors without changing anything except adding or
|
||||||
// removing references (the character `&`).
|
// removing references (the character `&`).
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
let data = "Rust is great!".to_string();
|
||||||
|
|
||||||
|
get_char(data);
|
||||||
|
|
||||||
|
string_uppercase(&data);
|
||||||
|
}
|
||||||
|
|
||||||
// Shouldn't take ownership
|
// Shouldn't take ownership
|
||||||
fn get_char(data: String) -> char {
|
fn get_char(data: String) -> char {
|
||||||
data.chars().last().unwrap()
|
data.chars().last().unwrap()
|
||||||
|
@ -14,11 +22,3 @@ fn string_uppercase(mut data: &String) {
|
||||||
|
|
||||||
println!("{data}");
|
println!("{data}");
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() {
|
|
||||||
let data = "Rust is great!".to_string();
|
|
||||||
|
|
||||||
get_char(data);
|
|
||||||
|
|
||||||
string_uppercase(&data);
|
|
||||||
}
|
|
||||||
|
|
|
@ -351,7 +351,7 @@ We call this "moving" a variable. When we pass `vec0` into `fill_vec`, it's
|
||||||
being "moved" into `vec1`, meaning we can't access `vec0` anymore.
|
being "moved" into `vec1`, meaning we can't access `vec0` anymore.
|
||||||
|
|
||||||
You could make another, separate version of the data that's in `vec0` and
|
You could make another, separate version of the data that's in `vec0` and
|
||||||
pass it to `fill_vec` instead. This is called cloning in Rust."""
|
pass it to `fill_vec` instead."""
|
||||||
|
|
||||||
[[exercises]]
|
[[exercises]]
|
||||||
name = "move_semantics3"
|
name = "move_semantics3"
|
||||||
|
@ -890,9 +890,9 @@ hint = """
|
||||||
`capitalize_first`:
|
`capitalize_first`:
|
||||||
|
|
||||||
The variable `first` is a `char`. It needs to be capitalized and added to the
|
The variable `first` is a `char`. It needs to be capitalized and added to the
|
||||||
remaining characters in `chars` in order to return the correct `String`.
|
remaining characters in `c` in order to return the correct `String`.
|
||||||
|
|
||||||
The remaining characters in `chars` can be viewed as a string slice using the
|
The remaining characters in `c` can be viewed as a string slice using the
|
||||||
`as_str` method.
|
`as_str` method.
|
||||||
|
|
||||||
The documentation for `char` contains many useful methods.
|
The documentation for `char` contains many useful methods.
|
||||||
|
@ -1145,11 +1145,7 @@ test = false
|
||||||
strict_clippy = true
|
strict_clippy = true
|
||||||
hint = """
|
hint = """
|
||||||
`for` loops over `Option` values are more clearly expressed as an `if-let`
|
`for` loops over `Option` values are more clearly expressed as an `if-let`
|
||||||
statement.
|
statement."""
|
||||||
|
|
||||||
Not required to solve this exercise, but if you are interested in when iterating
|
|
||||||
over `Option` can be useful, read the following section in the documentation:
|
|
||||||
https://doc.rust-lang.org/std/option/#iterating-over-option"""
|
|
||||||
|
|
||||||
[[exercises]]
|
[[exercises]]
|
||||||
name = "clippy3"
|
name = "clippy3"
|
||||||
|
|
|
@ -7,15 +7,15 @@ mod tests {
|
||||||
// TODO: Fix the compiler errors only by reordering the lines in the test.
|
// TODO: Fix the compiler errors only by reordering the lines in the test.
|
||||||
// Don't add, change or remove any line.
|
// Don't add, change or remove any line.
|
||||||
#[test]
|
#[test]
|
||||||
fn move_semantics4() {
|
fn move_semantics5() {
|
||||||
let mut x = Vec::new();
|
let mut x = 100;
|
||||||
let y = &mut x;
|
let y = &mut x;
|
||||||
// `y` used here.
|
// `y` used here.
|
||||||
y.push(42);
|
*y += 100;
|
||||||
// The mutable reference `y` is not used anymore,
|
// The mutable reference `y` is not used anymore,
|
||||||
// therefore a new reference can be created.
|
// therefore a new reference can be created.
|
||||||
let z = &mut x;
|
let z = &mut x;
|
||||||
z.push(13);
|
*z += 1000;
|
||||||
assert_eq!(x, [42, 13]);
|
assert_eq!(x, 1200);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,13 @@
|
||||||
#![allow(clippy::ptr_arg)]
|
#![allow(clippy::ptr_arg)]
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
let data = "Rust is great!".to_string();
|
||||||
|
|
||||||
|
get_char(&data);
|
||||||
|
|
||||||
|
string_uppercase(data);
|
||||||
|
}
|
||||||
|
|
||||||
// Borrows instead of taking ownership.
|
// Borrows instead of taking ownership.
|
||||||
// It is recommended to use `&str` instead of `&String` here. But this is
|
// It is recommended to use `&str` instead of `&String` here. But this is
|
||||||
// enough for now because we didn't handle strings yet.
|
// enough for now because we didn't handle strings yet.
|
||||||
|
@ -13,11 +21,3 @@ fn string_uppercase(mut data: String) {
|
||||||
|
|
||||||
println!("{data}");
|
println!("{data}");
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() {
|
|
||||||
let data = "Rust is great!".to_string();
|
|
||||||
|
|
||||||
get_char(&data);
|
|
||||||
|
|
||||||
string_uppercase(data);
|
|
||||||
}
|
|
||||||
|
|
Loading…
Reference in a new issue