diff --git a/book.toml b/book.toml index 0d84c17318..5b86f6808a 100644 --- a/book.toml +++ b/book.toml @@ -3,6 +3,9 @@ title = "Rust By Example" description = "Rust by Example (RBE) is a collection of runnable examples that illustrate various Rust concepts and standard libraries." author = "The Rust Community" +[rust] +edition = "2021" + [output.html.playpen] editable = true editor = "ace" diff --git a/src/error/result/enter_question_mark.md b/src/error/result/enter_question_mark.md index 8101e3efd7..ca954b1ac2 100644 --- a/src/error/result/enter_question_mark.md +++ b/src/error/result/enter_question_mark.md @@ -43,7 +43,7 @@ The `?` operator is now recommended, but you may still find `try!` when looking at older code. The same `multiply` function from the previous example would look like this using `try!`: -```rust,editable +```rust,editable,edition2015 // To compile and run this example without errors, while using Cargo, change the value // of the `edition` field, in the `[package]` section of the `Cargo.toml` file, to "2015". diff --git a/src/fn/closures/closure_examples/iter_any.md b/src/fn/closures/closure_examples/iter_any.md index 1fb64e9707..3c11f43c9b 100644 --- a/src/fn/closures/closure_examples/iter_any.md +++ b/src/fn/closures/closure_examples/iter_any.md @@ -35,7 +35,7 @@ fn main() { // `iter()` for arrays yields `&i32`. println!("2 in array1: {}", array1.iter() .any(|&x| x == 2)); // `into_iter()` for arrays unusually yields `&i32`. - println!("2 in array2: {}", array2.into_iter().any(|&x| x == 2)); + println!("2 in array2: {}", array2.into_iter().any(| x| x == 2)); } ``` diff --git a/src/generics/assoc_items/types.md b/src/generics/assoc_items/types.md index 0358fcebca..dbf6d789b4 100644 --- a/src/generics/assoc_items/types.md +++ b/src/generics/assoc_items/types.md @@ -1,6 +1,6 @@ # Associated types -The use of "Associated types" improves the overall readability of code +The use of "Associated types" improves the overall readability of code by moving inner types locally into a trait as *output* types. Syntax for the `trait` definition is as follows: @@ -13,7 +13,7 @@ trait Contains { type B; // Updated syntax to refer to these new types generically. - fn contains(&self, &Self::A, &Self::B) -> bool; + fn contains(&self, _: &Self::A, _: &Self::B) -> bool; } ```