diff --git a/src/crates/lib.md b/src/crates/lib.md index a46c50936f..24a51b1b2a 100644 --- a/src/crates/lib.md +++ b/src/crates/lib.md @@ -2,7 +2,7 @@ Let's create a library, and then see how to link it to another crate. -```rust,editable +```rust,ignore pub fn public_function() { println!("called rary's `public_function()`"); } diff --git a/src/custom_types/enum.md b/src/custom_types/enum.md index c605dc988f..6756789dd4 100644 --- a/src/custom_types/enum.md +++ b/src/custom_types/enum.md @@ -5,9 +5,6 @@ different variants. Any variant which is valid as a `struct` is also valid as an `enum`. ```rust,editable -// An attribute to hide warnings for unused code. -#![allow(dead_code)] - // Create an `enum` to classify a web event. Note how both // names and type information together specify the variant: // `PageLoad != PageUnload` and `KeyPress(char) != Paste(String)`. @@ -58,9 +55,8 @@ fn main() { ### See also: -[`attributes`][attributes], [`match`][match], [`fn`][fn], and [`String`][str] +[`match`][match], [`fn`][fn], and [`String`][str] -[attributes]: attribute.html [c_struct]: https://en.wikipedia.org/wiki/Struct_(C_programming_language) [match]: flow_control/match.html [fn]: fn.html diff --git a/src/flow_control/match/destructuring/destructure_structures.md b/src/flow_control/match/destructuring/destructure_structures.md index d641c669b6..bf35ab1897 100644 --- a/src/flow_control/match/destructuring/destructure_structures.md +++ b/src/flow_control/match/destructuring/destructure_structures.md @@ -4,26 +4,26 @@ Similarly, a `struct` can be destructured as shown: ```rust,editable fn main() { - struct Foo { x: (u32, u32), y: u32 } + struct Foo { + x: (u32, u32), + y: u32, + } - // destructure members of the struct + // Try changing the values in the struct to see what happens let foo = Foo { x: (1, 2), y: 3 }; - let Foo { x: (a, b), y } = foo; - println!("a = {}, b = {}, y = {} ", a, b, y); + match foo { + Foo { x: (1, b), y } => println!("First of x is 1, b = {}, y = {} ", b, y), - // you can destructure structs and rename the variables, - // the order is not important + // you can destructure structs and rename the variables, + // the order is not important + Foo { y: 2, x: i } => println!("y is 2, i = {:?}", i), - let Foo { y: i, x: j } = foo; - println!("i = {:?}, j = {:?}", i, j); - - // and you can also ignore some variables: - let Foo { y, .. } = foo; - println!("y = {}", y); - - // this will give an error: pattern does not mention field `x` - // let Foo { y } = foo; + // and you can also ignore some variables: + Foo { y, .. } => println!("y = {}, we don't care about x", y), + // this will give an error: pattern does not mention field `x` + //Foo { y } => println!("y = {}", y); + } } ``` diff --git a/src/meta/doc.md b/src/meta/doc.md index 4a49c2f160..f32f6a522a 100644 --- a/src/meta/doc.md +++ b/src/meta/doc.md @@ -4,7 +4,7 @@ Doc comments are very useful for big projects that require documentation. When running [Rustdoc][1], these are the comments that get compiled into documentation. They are denoted by a `///`, and support [Markdown][2]. -```rust,editable,ignore,mdbook-runnable +```rust,editable,ignore #![crate_name = "doc"] /// A human being is represented here