1
0
mirror of https://github.com/google/comprehensive-rust.git synced 2025-04-21 23:45:42 +02:00

Use exerciser for day 4 exercises too.

This commit is contained in:
Andrew Walbran 2023-04-03 16:59:13 +01:00
parent 5cdb73387f
commit bf18b33e39
2 changed files with 24 additions and 2 deletions

View File

@ -11,8 +11,10 @@ The dining philosophers problem is a classic problem in concurrency:
> an individual philosopher finishes eating, they will put down both forks. > an individual philosopher finishes eating, they will put down both forks.
You will need a local [Cargo installation](../../cargo/running-locally.md) for You will need a local [Cargo installation](../../cargo/running-locally.md) for
this exercise. Copy the code below to `src/main.rs` file, fill out the blanks, this exercise. Copy the code below to a file called `src/main.rs`, fill out the
and test that `cargo run` does not deadlock: blanks, and test that `cargo run` does not deadlock:
<!-- File src/main.rs -->
```rust,compile_fail ```rust,compile_fail
{{#include dining-philosophers.rs:Philosopher}} {{#include dining-philosophers.rs:Philosopher}}
@ -35,3 +37,14 @@ and test that `cargo run` does not deadlock:
// Output their thoughts // Output their thoughts
} }
``` ```
You can use the following `Cargo.toml`:
<!-- File Cargo.toml -->
```toml
[package]
name = "dining-philosophers"
version = "0.1.0"
edition = "2021"
```

View File

@ -32,7 +32,14 @@ $ cargo add thiserror
The `cargo add` calls will update the `Cargo.toml` file to look like this: The `cargo add` calls will update the `Cargo.toml` file to look like this:
<!-- File Cargo.toml -->
```toml ```toml
[package]
name = "link-checker"
version = "0.1.0"
edition = "2021"
[dependencies] [dependencies]
reqwest = { version = "0.11.12", features = ["blocking", "rustls-tls"] } reqwest = { version = "0.11.12", features = ["blocking", "rustls-tls"] }
scraper = "0.13.0" scraper = "0.13.0"
@ -44,6 +51,8 @@ You can now download the start page. Try with a small site such as
Your `src/main.rs` file should look something like this: Your `src/main.rs` file should look something like this:
<!-- File src/main.rs -->
```rust,compile_fail ```rust,compile_fail
{{#include link-checker.rs:setup}} {{#include link-checker.rs:setup}}