diff --git a/src/ch07-03-paths-for-referring-to-an-item-in-the-module-tree.md b/src/ch07-03-paths-for-referring-to-an-item-in-the-module-tree.md index 20bb9b43df..fc3980e468 100644 --- a/src/ch07-03-paths-for-referring-to-an-item-in-the-module-tree.md +++ b/src/ch07-03-paths-for-referring-to-an-item-in-the-module-tree.md @@ -215,7 +215,7 @@ or even see which fruit they’ll get. Filename: src/lib.rs -```rust +```rust,noplayground {{#rustdoc_include ../listings/ch07-managing-growing-projects/listing-07-09/src/lib.rs}} ``` @@ -240,7 +240,7 @@ only need the `pub` before the `enum` keyword, as shown in Listing 7-10. Filename: src/lib.rs -```rust +```rust,noplayground {{#rustdoc_include ../listings/ch07-managing-growing-projects/listing-07-10/src/lib.rs}} ``` diff --git a/src/ch07-04-bringing-paths-into-scope-with-the-use-keyword.md b/src/ch07-04-bringing-paths-into-scope-with-the-use-keyword.md index 01f2dfcaf1..3e4f1aa69b 100644 --- a/src/ch07-04-bringing-paths-into-scope-with-the-use-keyword.md +++ b/src/ch07-04-bringing-paths-into-scope-with-the-use-keyword.md @@ -88,7 +88,7 @@ different parent modules and how to refer to them. Filename: src/lib.rs -```rust +```rust,noplayground {{#rustdoc_include ../listings/ch07-managing-growing-projects/listing-07-15/src/lib.rs:here}} ``` @@ -109,7 +109,7 @@ code in Listing 7-15 by renaming one of the two `Result` types using `as`. Filename: src/lib.rs -```rust +```rust,noplayground {{#rustdoc_include ../listings/ch07-managing-growing-projects/listing-07-16/src/lib.rs:here}} ``` @@ -244,7 +244,7 @@ two `use` statements that share a subpath. For example, Listing 7-19 shows two Filename: src/lib.rs -```rust +```rust,noplayground {{#rustdoc_include ../listings/ch07-managing-growing-projects/listing-07-19/src/lib.rs}} ``` @@ -257,7 +257,7 @@ the nested path, as shown in Listing 7-20. Filename: src/lib.rs -```rust +```rust,noplayground {{#rustdoc_include ../listings/ch07-managing-growing-projects/listing-07-20/src/lib.rs}} ``` diff --git a/src/ch10-02-traits.md b/src/ch10-02-traits.md index 79f941581c..55f22cfb13 100644 --- a/src/ch10-02-traits.md +++ b/src/ch10-02-traits.md @@ -29,7 +29,7 @@ need a summary from each type, and we need to request that summary by calling a Filename: src/lib.rs -```rust +```rust,noplayground {{#rustdoc_include ../listings/ch10-generic-types-traits-and-lifetimes/listing-10-12/src/lib.rs}} ``` @@ -62,7 +62,7 @@ already limited to 280 characters. Filename: src/lib.rs -```rust +```rust,noplayground {{#rustdoc_include ../listings/ch10-generic-types-traits-and-lifetimes/listing-10-13/src/lib.rs:here}} ``` @@ -130,7 +130,7 @@ in Listing 10-12. Filename: src/lib.rs -```rust +```rust,noplayground {{#rustdoc_include ../listings/ch10-generic-types-traits-and-lifetimes/listing-10-14/src/lib.rs:here}} ``` @@ -166,7 +166,7 @@ a small part of it. For example, we could define the `Summary` trait to have a `summarize` method that has a default implementation that calls the `summarize_author` method: -```rust +```rust,noplayground {{#rustdoc_include ../listings/ch10-generic-types-traits-and-lifetimes/no-listing-03-default-impl-calls-other-methods/src/lib.rs:here}} ``` @@ -416,7 +416,7 @@ the `Display` trait that enables printing. Filename: src/lib.rs -```rust +```rust,noplayground {{#rustdoc_include ../listings/ch10-generic-types-traits-and-lifetimes/listing-10-16/src/lib.rs}} ``` diff --git a/src/ch11-02-running-tests.md b/src/ch11-02-running-tests.md index 880d1b38b2..c33280e349 100644 --- a/src/ch11-02-running-tests.md +++ b/src/ch11-02-running-tests.md @@ -105,7 +105,7 @@ To demonstrate how to run a subset of tests, we’ll create three tests for our Filename: src/lib.rs -```rust +```rust,noplayground {{#rustdoc_include ../listings/ch11-writing-automated-tests/listing-11-11/src/lib.rs}} ``` diff --git a/src/ch11-03-test-organization.md b/src/ch11-03-test-organization.md index a6adb65a28..0057e8c472 100644 --- a/src/ch11-03-test-organization.md +++ b/src/ch11-03-test-organization.md @@ -37,7 +37,7 @@ this chapter, Cargo generated this code for us: Filename: src/lib.rs -```rust +```rust,noplayground {{#rustdoc_include ../listings/ch11-writing-automated-tests/listing-11-01/src/lib.rs:here}} ``` diff --git a/src/ch14-03-cargo-workspaces.md b/src/ch14-03-cargo-workspaces.md index 3801742cd8..c376fa57b8 100644 --- a/src/ch14-03-cargo-workspaces.md +++ b/src/ch14-03-cargo-workspaces.md @@ -122,7 +122,7 @@ In the *add-one/src/lib.rs* file, let’s add an `add_one` function: Filename: add-one/src/lib.rs -```rust +```rust,noplayground {{#rustdoc_include ../listings/ch14-more-about-cargo/no-listing-02-workspace-with-two-crates/add/add-one/src/lib.rs}} ``` @@ -285,7 +285,7 @@ within the `add_one` crate: Filename: add-one/src/lib.rs -```rust +```rust,noplayground {{#rustdoc_include ../listings/ch14-more-about-cargo/no-listing-04-workspace-with-tests/add/add-one/src/lib.rs}} ``` diff --git a/src/ch15-05-interior-mutability.md b/src/ch15-05-interior-mutability.md index a1849025f5..4b1f414732 100644 --- a/src/ch15-05-interior-mutability.md +++ b/src/ch15-05-interior-mutability.md @@ -124,7 +124,7 @@ called `Messenger`. Listing 15-20 shows the library code: Filename: src/lib.rs -```rust +```rust,noplayground {{#rustdoc_include ../listings/ch15-smart-pointers/listing-15-20/src/lib.rs}} ``` diff --git a/src/ch17-01-what-is-oo.md b/src/ch17-01-what-is-oo.md index e197cbfa84..86bf467a8c 100644 --- a/src/ch17-01-what-is-oo.md +++ b/src/ch17-01-what-is-oo.md @@ -46,7 +46,7 @@ cache the calculated average for us. Listing 17-1 has the definition of the Filename: src/lib.rs -```rust +```rust,noplayground {{#rustdoc_include ../listings/ch17-oop/listing-17-01/src/lib.rs}} ``` @@ -62,7 +62,7 @@ on the struct, as shown in Listing 17-2: Filename: src/lib.rs -```rust +```rust,noplayground {{#rustdoc_include ../listings/ch17-oop/listing-17-02/src/lib.rs:here}} ``` diff --git a/src/ch17-02-trait-objects.md b/src/ch17-02-trait-objects.md index 52a3371bd0..90535ddfa7 100644 --- a/src/ch17-02-trait-objects.md +++ b/src/ch17-02-trait-objects.md @@ -68,7 +68,7 @@ Listing 17-3 shows how to define a trait named `Draw` with one method named Filename: src/lib.rs -```rust +```rust,noplayground {{#rustdoc_include ../listings/ch17-oop/listing-17-03/src/lib.rs}} ``` @@ -82,7 +82,7 @@ a `Box` that implements the `Draw` trait. Filename: src/lib.rs -```rust +```rust,noplayground {{#rustdoc_include ../listings/ch17-oop/listing-17-04/src/lib.rs:here}} ``` @@ -95,7 +95,7 @@ On the `Screen` struct, we’ll define a method named `run` that will call the Filename: src/lib.rs -```rust +```rust,noplayground {{#rustdoc_include ../listings/ch17-oop/listing-17-05/src/lib.rs:here}} ``` @@ -111,7 +111,7 @@ as in Listing 17-6: Filename: src/lib.rs -```rust +```rust,noplayground {{#rustdoc_include ../listings/ch17-oop/listing-17-06/src/lib.rs:here}} ``` diff --git a/src/ch17-03-oo-design-patterns.md b/src/ch17-03-oo-design-patterns.md index 876f9c02b2..4944e96079 100644 --- a/src/ch17-03-oo-design-patterns.md +++ b/src/ch17-03-oo-design-patterns.md @@ -75,7 +75,7 @@ inside an `Option` in a private field named `state`. You’ll see why the Filename: src/lib.rs -```rust +```rust,noplayground {{#rustdoc_include ../listings/ch17-oop/listing-17-12/src/lib.rs}} ``` @@ -209,7 +209,7 @@ state is approved, as shown in Listing 17-16: Filename: src/lib.rs -```rust +```rust,noplayground {{#rustdoc_include ../listings/ch17-oop/listing-17-16/src/lib.rs:here}} ``` @@ -267,7 +267,7 @@ Listing 17-18: Filename: src/lib.rs -```rust +```rust,noplayground {{#rustdoc_include ../listings/ch17-oop/listing-17-18/src/lib.rs:here}} ``` @@ -375,7 +375,7 @@ as well as methods on each: Filename: src/lib.rs -```rust +```rust,noplayground {{#rustdoc_include ../listings/ch17-oop/listing-17-19/src/lib.rs}} ``` @@ -411,7 +411,7 @@ shown in Listing 17-20: Filename: src/lib.rs -```rust +```rust,noplayground {{#rustdoc_include ../listings/ch17-oop/listing-17-20/src/lib.rs:here}} ``` diff --git a/src/ch19-03-advanced-traits.md b/src/ch19-03-advanced-traits.md index d527bb67a5..1d396463ec 100644 --- a/src/ch19-03-advanced-traits.md +++ b/src/ch19-03-advanced-traits.md @@ -27,7 +27,7 @@ Method”][the-iterator-trait-and-the-next-method] section of Chapter 13, we mentioned that the definition of the `Iterator` trait is as shown in Listing 19-12. -```rust +```rust,noplayground {{#rustdoc_include ../listings/ch19-advanced-features/listing-19-12/src/lib.rs}} ``` @@ -56,7 +56,7 @@ Listing 13-21, we specified that the `Item` type was `u32`: This syntax seems comparable to that of generics. So why not just define the `Iterator` trait with generics, as shown in Listing 19-13? -```rust +```rust,noplayground {{#rustdoc_include ../listings/ch19-advanced-features/listing-19-13/src/lib.rs}} ``` @@ -143,7 +143,7 @@ implementation of `Add` do the conversion correctly. We can implement `Add` for Filename: src/lib.rs -```rust +```rust,noplayground {{#rustdoc_include ../listings/ch19-advanced-features/listing-19-15/src/lib.rs}} ``` diff --git a/src/ch19-04-advanced-types.md b/src/ch19-04-advanced-types.md index b10b4cbb41..c30a847372 100644 --- a/src/ch19-04-advanced-types.md +++ b/src/ch19-04-advanced-types.md @@ -101,7 +101,7 @@ possible I/O errors. Many of the functions in `std::io` will be returning `Result` where the `E` is `std::io::Error`, such as these functions in the `Write` trait: -```rust +```rust,noplayground {{#rustdoc_include ../listings/ch19-advanced-features/no-listing-05-write-trait/src/lib.rs}} ``` diff --git a/src/ch19-05-advanced-functions-and-closures.md b/src/ch19-05-advanced-functions-and-closures.md index 876c18e0c3..51866ab2ea 100644 --- a/src/ch19-05-advanced-functions-and-closures.md +++ b/src/ch19-05-advanced-functions-and-closures.md @@ -105,7 +105,7 @@ The error references the `Sized` trait again! Rust doesn’t know how much space it will need to store the closure. We saw a solution to this problem earlier. We can use a trait object: -```rust +```rust,noplayground {{#rustdoc_include ../listings/ch19-advanced-features/no-listing-19-returns-closure-trait-object/src/lib.rs}} ``` diff --git a/src/ch19-06-macros.md b/src/ch19-06-macros.md index 3d1af7444a..a714413b6f 100644 --- a/src/ch19-06-macros.md +++ b/src/ch19-06-macros.md @@ -77,7 +77,7 @@ Listing 19-28 shows a slightly simplified definition of the `vec!` macro. Filename: src/lib.rs -```rust +```rust,noplayground {{#rustdoc_include ../listings/ch19-advanced-features/listing-19-28/src/lib.rs}} ``` @@ -230,7 +230,7 @@ Next, we’ll define the `HelloMacro` trait and its associated function: Filename: src/lib.rs -```rust +```rust,noplayground {{#rustdoc_include ../listings/ch19-advanced-features/no-listing-20-impl-hellomacro-for-pancakes/hello_macro/src/lib.rs}} ``` diff --git a/src/ch20-02-multithreaded.md b/src/ch20-02-multithreaded.md index 7c9e758a5a..24c7206979 100644 --- a/src/ch20-02-multithreaded.md +++ b/src/ch20-02-multithreaded.md @@ -157,7 +157,7 @@ definition of a `ThreadPool` struct that we can have for now: Filename: src/lib.rs -```rust +```rust,noplayground {{#rustdoc_include ../listings/ch20-web-server/no-listing-01-define-threadpool-struct/src/lib.rs}} ``` @@ -559,7 +559,7 @@ shown in Listing 20-20 to `Worker::new`. Filename: src/lib.rs -```rust +```rust,noplayground {{#rustdoc_include ../listings/ch20-web-server/listing-20-20/src/lib.rs:here}} ```