Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Small improvements to various files #1173

Merged
merged 4 commits into from Apr 22, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/crates/lib.md
Expand Up @@ -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()`");
}
Expand Down
6 changes: 1 addition & 5 deletions src/custom_types/enum.md
Expand Up @@ -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)`.
Expand Down Expand Up @@ -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
Expand Down
30 changes: 15 additions & 15 deletions src/flow_control/match/destructuring/destructure_structures.md
Expand Up @@ -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);
}
}
```

Expand Down
2 changes: 1 addition & 1 deletion src/meta/doc.md
Expand Up @@ -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
Expand Down