Skip to content

Commit

Permalink
Merge pull request #1173 from alexander-clarke/small-fixes
Browse files Browse the repository at this point in the history
Small improvements to various files
  • Loading branch information
marioidival authored Apr 22, 2019
2 parents d7c5489 + aaddc14 commit a18c3c4
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 22 deletions.
2 changes: 1 addition & 1 deletion src/crates/lib.md
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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

0 comments on commit a18c3c4

Please sign in to comment.