mirror of
https://github.com/rust-lang/rustlings.git
synced 2025-01-11 00:00:04 +03:00
Compare commits
3 commits
0338b1cbdf
...
5bf8d1fa1b
Author | SHA1 | Date | |
---|---|---|---|
5bf8d1fa1b | |||
2ff1813746 | |||
98db579014 |
24
Cargo.lock
generated
24
Cargo.lock
generated
|
@ -151,9 +151,9 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "clap"
|
name = "clap"
|
||||||
version = "4.5.6"
|
version = "4.5.7"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "a9689a29b593160de5bc4aacab7b5d54fb52231de70122626c178e6a368994c7"
|
checksum = "5db83dced34638ad474f39f250d7fea9598bdd239eaced1bdf45d597da0f433f"
|
||||||
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.6"
|
version = "4.5.7"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "2e5387378c84f6faa26890ebf9f0a92989f8873d4d380467bcd0d8d8620424df"
|
checksum = "f7e204572485eb3fbf28f871612191521df159bc3e15a9f5064c66dba3a8c05f"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anstream",
|
"anstream",
|
||||||
"anstyle",
|
"anstyle",
|
||||||
|
@ -422,9 +422,9 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "memchr"
|
name = "memchr"
|
||||||
version = "2.7.2"
|
version = "2.7.4"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "6c8640c5d730cb13ebd907d8d04b52f55ac9a2eec55b440c8892f40d56c76c1d"
|
checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "mio"
|
name = "mio"
|
||||||
|
@ -615,9 +615,9 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "regex"
|
name = "regex"
|
||||||
version = "1.10.4"
|
version = "1.10.5"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "c117dbdfde9c8308975b6a18d71f3f385c89461f7b3fb054288ecf2a2058ba4c"
|
checksum = "b91213439dad192326a0d7c6ee3955910425f441d7038e0d6933b0aec5c4517f"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"aho-corasick",
|
"aho-corasick",
|
||||||
"memchr",
|
"memchr",
|
||||||
|
@ -627,9 +627,9 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "regex-automata"
|
name = "regex-automata"
|
||||||
version = "0.4.6"
|
version = "0.4.7"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "86b83b8b9847f9bf95ef68afb0b8e6cdb80f498442f5179a29fad448fcc1eaea"
|
checksum = "38caf58cc5ef2fed281f89292ef23f6365465ed9a41b7a7754eb4e26496c92df"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"aho-corasick",
|
"aho-corasick",
|
||||||
"memchr",
|
"memchr",
|
||||||
|
@ -638,9 +638,9 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "regex-syntax"
|
name = "regex-syntax"
|
||||||
version = "0.8.3"
|
version = "0.8.4"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "adad44e29e4c806119491a7f06f03de4d1af22c3a680dd47f1e6e179439d1f56"
|
checksum = "7a66a03ae7c801facd77a29370b4faec201768915ac14a721ba36f20bc9c209b"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rustlings"
|
name = "rustlings"
|
||||||
|
|
|
@ -47,7 +47,7 @@ include = [
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
anyhow = "1.0.86"
|
anyhow = "1.0.86"
|
||||||
clap = { version = "4.5.6", features = ["derive"] }
|
clap = { version = "4.5.7", 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 }
|
||||||
|
|
|
@ -2,7 +2,7 @@ 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);
|
||||||
|
|
||||||
// TODO: Fix the compiler error by changing the line below without renaming the the variable.
|
// TODO: Fix the compiler error by changing the line below without renaming the variable.
|
||||||
number = 3;
|
number = 3;
|
||||||
println!("Number plus two is: {}", number + 2);
|
println!("Number plus two is: {}", number + 2);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
fn main() {
|
fn main() {
|
||||||
// TODO: Create an array with at least 100 elements in it where the ??? is.
|
// TODO: Create an array called `a` with at least 100 elements in it.
|
||||||
// let a = ???
|
// let a = ???
|
||||||
|
|
||||||
if a.len() >= 100 {
|
if a.len() >= 100 {
|
||||||
|
|
|
@ -1,18 +1,15 @@
|
||||||
// Get a slice out of Array a where the ??? is so that the test passes.
|
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
// You can optionally experiment here.
|
// You can optionally experiment here.
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn slice_out_of_array() {
|
fn slice_out_of_array() {
|
||||||
let a = [1, 2, 3, 4, 5];
|
let a = [1, 2, 3, 4, 5];
|
||||||
|
|
||||||
let nice_slice = ???
|
// TODO: Get a slice called `nice_slice` out of the array `a` so that the test passes.
|
||||||
|
// let nice_slice = ???
|
||||||
|
|
||||||
assert_eq!([2, 3, 4], nice_slice);
|
assert_eq!([2, 3, 4], nice_slice);
|
||||||
}
|
}
|
||||||
|
|
|
@ -267,8 +267,8 @@ dir = "04_primitive_types"
|
||||||
hint = """
|
hint = """
|
||||||
Take a look at the 'Understanding Ownership -> Slices -> Other Slices' section
|
Take a look at the 'Understanding Ownership -> Slices -> Other Slices' section
|
||||||
of the book: https://doc.rust-lang.org/book/ch04-03-slices.html and use the
|
of the book: https://doc.rust-lang.org/book/ch04-03-slices.html and use the
|
||||||
starting and ending (plus one) indices of the items in the `Array` that you
|
starting and ending (plus one) indices of the items in the array that you want
|
||||||
want to end up in the slice.
|
to end up in the slice.
|
||||||
|
|
||||||
If you're curious why the first argument of `assert_eq!` does not have an
|
If you're curious why the first argument of `assert_eq!` does not have an
|
||||||
ampersand for a reference since the second argument is a reference, take a look
|
ampersand for a reference since the second argument is a reference, take a look
|
||||||
|
|
|
@ -1 +1,23 @@
|
||||||
// Solutions will be available before the stable release. Thank you for testing the beta version 🥰
|
fn main() {
|
||||||
|
// You can optionally experiment here.
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod tests {
|
||||||
|
#[test]
|
||||||
|
fn slice_out_of_array() {
|
||||||
|
let a = [1, 2, 3, 4, 5];
|
||||||
|
// 0 1 2 3 4 <- indices
|
||||||
|
// -------
|
||||||
|
// |
|
||||||
|
// +--- slice
|
||||||
|
|
||||||
|
// Note that the upper index 4 is excluded.
|
||||||
|
let nice_slice = &a[1..4];
|
||||||
|
assert_eq!([2, 3, 4], nice_slice);
|
||||||
|
|
||||||
|
// The upper index can be included by using the syntax `..=` (with `=` sign)
|
||||||
|
let nice_slice = &a[1..=3];
|
||||||
|
assert_eq!([2, 3, 4], nice_slice);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -151,7 +151,7 @@ fn main() -> Result<()> {
|
||||||
let notify_exercise_names = if args.manual_run {
|
let notify_exercise_names = if args.manual_run {
|
||||||
None
|
None
|
||||||
} else {
|
} else {
|
||||||
// For the the notify event handler thread.
|
// For the notify event handler thread.
|
||||||
// Leaking is not a problem because the slice lives until the end of the program.
|
// Leaking is not a problem because the slice lives until the end of the program.
|
||||||
Some(
|
Some(
|
||||||
&*app_state
|
&*app_state
|
||||||
|
|
Loading…
Reference in a new issue