Skip to content

Commit

Permalink
Chapter 6 - Wrap all <Listing>s to comply with the virtual 80 chara…
Browse files Browse the repository at this point in the history
…cter limit (READ DESC.)

I'm unsure whether wrapping the text may cause the listing text to be wrapped too as the newlines are found within quotation marks. If it causes issues, feel free to revert this commit. Another odd thing is that my editor uncolored the closing `</Listing>` tag when I split the lines. Maybe the newline characters need to be escaped with a backslash?
  • Loading branch information
SpectralPixel committed Jul 17, 2024
1 parent 0b339ad commit b1bb69f
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
6 changes: 4 additions & 2 deletions src/ch06-01-defining-an-enum.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ only know what *kind* it is. Given that you just learned about structs in
Chapter 5, you might be tempted to tackle this problem with structs as shown in
Listing 6-1.

<Listing number="6-1" caption="Storing the data and `IpAddrKind` variant of an IP address using a `struct`">
<Listing number="6-1" caption="Storing the data and `IpAddrKind` variant of an
IP address using a `struct`">

```rust
{{#rustdoc_include ../listings/ch06-enums-and-pattern-matching/listing-06-01/src/main.rs:here}}
Expand Down Expand Up @@ -141,7 +142,8 @@ more about bringing types into scope in Chapter 7.
Let’s look at another example of an enum in Listing 6-2: this one has a wide
variety of types embedded in its variants.

<Listing number="6-2" caption="A `Message` enum whose variants each store different amounts and types of values">
<Listing number="6-2" caption="A `Message` enum whose variants each store
different amounts and types of values">

```rust
{{#rustdoc_include ../listings/ch06-enums-and-pattern-matching/listing-06-02/src/main.rs:here}}
Expand Down
9 changes: 6 additions & 3 deletions src/ch06-02-match.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ function that takes an unknown US coin and, in a similar way as the counting
machine, determines which coin it is and returns its value in cents, as shown
in Listing 6-3.

<Listing number="6-3" caption="An enum and a `match` expression that has the variants of the enum as its patterns">
<Listing number="6-3" caption="An enum and a `match` expression that has the
variants of the enum as its patterns">

```rust
{{#rustdoc_include ../listings/ch06-enums-and-pattern-matching/listing-06-03/src/main.rs:here}}
Expand Down Expand Up @@ -76,7 +77,8 @@ designs, so only quarters have this extra value. We can add this information to
our `enum` by changing the `Quarter` variant to include a `UsState` value
stored inside it, which we’ve done in Listing 6-4.

<Listing number="6-4" caption="A `Coin` enum in which the `Quarter` variant also holds a `UsState` value">
<Listing number="6-4" caption="A `Coin` enum in which the `Quarter` variant
also holds a `UsState` value">

```rust
{{#rustdoc_include ../listings/ch06-enums-and-pattern-matching/listing-06-04/src/main.rs:here}}
Expand Down Expand Up @@ -121,7 +123,8 @@ operations.
This function is very easy to write, thanks to `match`, and will look like
Listing 6-5.

<Listing number="6-5" caption="A function that uses a `match` expression on an `Option<i32>`">
<Listing number="6-5" caption="A function that uses a `match` expression on an
`Option<i32>`">

```rust
{{#rustdoc_include ../listings/ch06-enums-and-pattern-matching/listing-06-05/src/main.rs:here}}
Expand Down
3 changes: 2 additions & 1 deletion src/ch06-03-if-let.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ program in Listing 6-6 that matches on an `Option<u8>` value in the
`config_max` variable but only wants to execute code if the value is the `Some`
variant.

<Listing number="6-6" caption="A `match` that only cares about executing code when the value is `Some`">
<Listing number="6-6" caption="A `match` that only cares about executing code
when the value is `Some`">

```rust
{{#rustdoc_include ../listings/ch06-enums-and-pattern-matching/listing-06-06/src/main.rs:here}}
Expand Down

0 comments on commit b1bb69f

Please sign in to comment.