Skip to content

Commit

Permalink
rebuild GitHub Pages from generated-book
Browse files Browse the repository at this point in the history
  • Loading branch information
chriskrycho committed Oct 9, 2024
1 parent a92b897 commit de2ee83
Show file tree
Hide file tree
Showing 37 changed files with 1,292 additions and 1,008 deletions.
2 changes: 1 addition & 1 deletion appendix-03-derivable-traits.html
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ <h2 id="appendix-c-derivable-traits"><a class="header" href="#appendix-c-derivab
libraries can implement <code>derive</code> for their own traits, making the list of
traits you can use <code>derive</code> with truly open-ended. Implementing <code>derive</code>
involves using a procedural macro, which is covered in the
<a href="ch20-06-macros.html#macros">“Macros”</a><!-- ignore --> section of Chapter 19.</p>
<a href="ch20-06-macros.html#macros">“Macros”</a><!-- ignore --> section of Chapter 20.</p>
<h3 id="debug-for-programmer-output"><a class="header" href="#debug-for-programmer-output"><code>Debug</code> for Programmer Output</a></h3>
<p>The <code>Debug</code> trait enables debug formatting in format strings, which you
indicate by adding <code>:?</code> within <code>{}</code> placeholders.</p>
Expand Down
14 changes: 8 additions & 6 deletions ch00-00-introduction.html
Original file line number Diff line number Diff line change
Expand Up @@ -295,15 +295,17 @@ <h2 id="how-to-use-this-book"><a class="header" href="#how-to-use-this-book">How
depth and talk about best practices for sharing your libraries with others.
Chapter 15 discusses smart pointers that the standard library provides and the
traits that enable their functionality.</p>
<p>In Chapter 16, we’ll walk through different models of concurrent programming
and talk about how Rust helps you to program in multiple threads fearlessly.
Chapter 17 looks at how Rust idioms compare to object-oriented programming
<p>In Chapter 16, we’ll walk through different models of concurrent programming and
talk about how Rust helps you to program in multiple threads fearlessly. In
Chapter 17, we will build on that by exploring Rust’s async and await syntax and
the lightweight concurrency model they support.</p>
<p>Chapter 18 looks at how Rust idioms compare to object-oriented programming
principles you might be familiar with.</p>
<p>Chapter 18 is a reference on patterns and pattern matching, which are powerful
ways of expressing ideas throughout Rust programs. Chapter 19 contains a
<p>Chapter 19 is a reference on patterns and pattern matching, which are powerful
ways of expressing ideas throughout Rust programs. Chapter 20 contains a
smorgasbord of advanced topics of interest, including unsafe Rust, macros, and
more about lifetimes, traits, types, functions, and closures.</p>
<p>In Chapter 20, we’ll complete a project in which we’ll implement a low-level
<p>In Chapter 21, we’ll complete a project in which we’ll implement a low-level
multithreaded web server!</p>
<p>Finally, some appendices contain useful information about the language in a
more reference-like format. Appendix A covers Rust’s keywords, Appendix B
Expand Down
2 changes: 1 addition & 1 deletion ch01-02-hello-world.html
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ <h3 id="anatomy-of-a-rust-program"><a class="header" href="#anatomy-of-a-rust-pr
<p>First, Rust style is to indent with four spaces, not a tab.</p>
<p>Second, <code>println!</code> calls a Rust macro. If it had called a function instead, it
would be entered as <code>println</code> (without the <code>!</code>). We’ll discuss Rust macros in
more detail in Chapter 19. For now, you just need to know that using a <code>!</code>
more detail in Chapter 20. For now, you just need to know that using a <code>!</code>
means that you’re calling a macro instead of a normal function and that macros
don’t always follow the same rules as functions.</p>
<p>Third, you see the <code>"Hello, world!"</code> string. We pass this string as an argument
Expand Down
4 changes: 2 additions & 2 deletions ch02-00-guessing-game-tutorial.html
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ <h2 id="processing-a-guess"><a class="header" href="#processing-a-guess">Process
println!("You guessed: {}", guess);
}</code></pre>
<figcaption>Listing 2-1: Code that gets a guess from the user and prints it</figcaption>
</figure>
</figure>
<p>This code contains a lot of information, so let’s go over it line by line. To
obtain user input and then print the result as output, we need to bring the
<code>io</code> input/output library into scope. The <code>io</code> library comes from the standard
Expand Down Expand Up @@ -824,7 +824,7 @@ <h2 id="comparing-the-guess-to-the-secret-number"><a class="header" href="#compa
through each arm’s pattern in turn. Patterns and the <code>match</code> construct are
powerful Rust features: they let you express a variety of situations your code
might encounter and they make sure you handle them all. These features will be
covered in detail in Chapter 6 and Chapter 18, respectively.</p>
covered in detail in Chapter 6 and Chapter 19, respectively.</p>
<p>Let’s walk through an example with the <code>match</code> expression we use here. Say that
the user has guessed 50 and the randomly generated secret number this time is
38.</p>
Expand Down
4 changes: 3 additions & 1 deletion ch05-01-defining-structs.html
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,9 @@ <h3 id="using-tuple-structs-without-named-fields-to-create-different-types"><a c
<code>Point</code> as an argument, even though both types are made up of three <code>i32</code>
values. Otherwise, tuple struct instances are similar to tuples in that you can
destructure them into their individual pieces, and you can use a <code>.</code> followed
by the index to access an individual value.</p>
by the index to access an individual value. Unlike tuples, tuple structs
require you to name the type of the struct when you destructure them. For
example, we would write <code>let Point(x, y, z) = point</code>.</p>
<h3 id="unit-like-structs-without-any-fields"><a class="header" href="#unit-like-structs-without-any-fields">Unit-Like Structs Without Any Fields</a></h3>
<p>You can also define structs that don’t have any fields! These are called
<em>unit-like structs</em> because they behave similarly to <code>()</code>, the unit type that
Expand Down
2 changes: 1 addition & 1 deletion ch08-01-vectors.html
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,7 @@ <h3 id="using-an-enum-to-store-multiple-types"><a class="header" href="#using-an
at compile time that every possible case is handled, as discussed in Chapter 6.</p>
<p>If you don’t know the exhaustive set of types a program will get at runtime to
store in a vector, the enum technique won’t work. Instead, you can use a trait
object, which we’ll cover in Chapter 17.</p>
object, which we’ll cover in Chapter 18.</p>
<p>Now that we’ve discussed some of the most common ways to use vectors, be sure
to review <a href="../std/vec/struct.Vec.html">the API documentation</a><!-- ignore --> for all of the many
useful methods defined on <code>Vec&lt;T&gt;</code> by the standard library. For example, in
Expand Down
2 changes: 1 addition & 1 deletion ch09-02-recoverable-errors-with-result.html
Original file line number Diff line number Diff line change
Expand Up @@ -699,7 +699,7 @@ <h4 id="where-the--operator-can-be-used"><a class="header" href="#where-the--ope
allows the use of the <code>?</code> operator on <code>Result</code> values.</span></p>
<p>The <code>Box&lt;dyn Error&gt;</code> type is a <em>trait object</em>, which we’ll talk about in the
<a href="ch18-02-trait-objects.html#using-trait-objects-that-allow-for-values-of-different-types">“Using Trait Objects that Allow for Values of Different
Types”</a><!-- ignore --> section in Chapter 17. For now, you can
Types”</a><!-- ignore --> section in Chapter 18. For now, you can
read <code>Box&lt;dyn Error&gt;</code> to mean “any kind of error.” Using <code>?</code> on a <code>Result</code>
value in a <code>main</code> function with the error type <code>Box&lt;dyn Error&gt;</code> is allowed
because it allows any <code>Err</code> value to be returned early. Even though the body of
Expand Down
2 changes: 1 addition & 1 deletion ch09-03-to-panic-or-not-to-panic.html
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ <h3 id="guidelines-for-error-handling"><a class="header" href="#guidelines-for-e
rather than checking for the problem at every step.</li>
<li>There’s not a good way to encode this information in the types you use. We’ll
work through an example of what we mean in the <a href="ch18-03-oo-design-patterns.html#encoding-states-and-behavior-as-types">“Encoding States and Behavior
as Types”</a><!-- ignore --> section of Chapter 17.</li>
as Types”</a><!-- ignore --> section of Chapter 18.</li>
</ul>
<p>If someone calls your code and passes in values that don’t make sense, it’s
best to return an error if you can so the user of the library can decide what
Expand Down
2 changes: 1 addition & 1 deletion ch10-02-traits.html
Original file line number Diff line number Diff line change
Expand Up @@ -660,7 +660,7 @@ <h3 id="returning-types-that-implement-traits"><a class="header" href="#returnin
how to write a function with this behavior in the <a href="ch18-02-trait-objects.html#using-trait-objects-that-allow-for-values-of-different-types">“Using Trait Objects That
Allow for Values of Different
Types”</a><!--
ignore --> section of Chapter 17.</p>
ignore --> section of Chapter 18.</p>
<h3 id="using-trait-bounds-to-conditionally-implement-methods"><a class="header" href="#using-trait-bounds-to-conditionally-implement-methods">Using Trait Bounds to Conditionally Implement Methods</a></h3>
<p>By using a trait bound with an <code>impl</code> block that uses generic type parameters,
we can implement methods conditionally for types that implement the specified
Expand Down
2 changes: 1 addition & 1 deletion ch10-03-lifetime-syntax.html
Original file line number Diff line number Diff line change
Expand Up @@ -886,7 +886,7 @@ <h2 id="summary"><a class="header" href="#summary">Summary</a></h2>
that this flexible code won’t have any dangling references. And all of this
analysis happens at compile time, which doesn’t affect runtime performance!</p>
<p>Believe it or not, there is much more to learn on the topics we discussed in
this chapter: Chapter 17 discusses trait objects, which are another way to use
this chapter: Chapter 18 discusses trait objects, which are another way to use
traits. There are also more complex scenarios involving lifetime annotations
that you will only need in very advanced scenarios; for those, you should read
the <a href="../reference/index.html">Rust Reference</a>. But next, you’ll learn how to write tests in
Expand Down
2 changes: 1 addition & 1 deletion ch12-00-an-io-project.html
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ <h1 id="an-io-project-building-a-command-line-program"><a class="header" href="#
<li>Writing tests (<a href="ch11-00-testing.html">Chapter 11</a><!-- ignore -->)</li>
</ul>
<p>We’ll also briefly introduce closures, iterators, and trait objects, which
<a href="ch13-00-functional-features.html">Chapter 13</a><!-- ignore --> and <a href="ch18-00-oop.html">Chapter 17</a><!-- ignore --> will
<a href="ch13-00-functional-features.html">Chapter 13</a><!-- ignore --> and <a href="ch18-00-oop.html">Chapter 18</a><!-- ignore --> will
cover in detail.</p>

</main>
Expand Down
2 changes: 1 addition & 1 deletion ch12-03-improving-error-handling-and-modularity.html
Original file line number Diff line number Diff line change
Expand Up @@ -779,7 +779,7 @@ <h4 id="returning-errors-from-the-run-function"><a class="header" href="#returni
<code>Ok</code> case.</p>
<p>For the error type, we used the <em>trait object</em> <code>Box&lt;dyn Error&gt;</code> (and we’ve
brought <code>std::error::Error</code> into scope with a <code>use</code> statement at the top).
We’ll cover trait objects in <a href="ch18-00-oop.html">Chapter 17</a><!-- ignore -->. For now, just
We’ll cover trait objects in <a href="ch18-00-oop.html">Chapter 18</a><!-- ignore -->. For now, just
know that <code>Box&lt;dyn Error&gt;</code> means the function will return a type that
implements the <code>Error</code> trait, but we don’t have to specify what particular type
the return value will be. This gives us flexibility to return error values that
Expand Down
2 changes: 1 addition & 1 deletion ch13-02-iterators.html
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ <h3 id="the-iterator-trait-and-the-next-method"><a class="header" href="#the-ite
<span class="boring">}</span></code></pre></pre>
<p>Notice this definition uses some new syntax: <code>type Item</code> and <code>Self::Item</code>,
which are defining an <em>associated type</em> with this trait. We’ll talk about
associated types in depth in Chapter 19. For now, all you need to know is that
associated types in depth in Chapter 20. For now, all you need to know is that
this code says implementing the <code>Iterator</code> trait requires that you also define
an <code>Item</code> type, and this <code>Item</code> type is used in the return type of the <code>next</code>
method. In other words, the <code>Item</code> type will be the type returned from the
Expand Down
2 changes: 1 addition & 1 deletion ch14-02-publishing-to-crates-io.html
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ <h4 id="commonly-used-sections"><a class="header" href="#commonly-used-sections"
returned can be helpful to callers so they can write code to handle the
different kinds of errors in different ways.</li>
<li><strong>Safety</strong>: If the function is <code>unsafe</code> to call (we discuss unsafety in
Chapter 19), there should be a section explaining why the function is unsafe
Chapter 20), there should be a section explaining why the function is unsafe
and covering the invariants that the function expects callers to uphold.</li>
</ul>
<p>Most documentation comments don’t need all of these sections, but this is a
Expand Down
6 changes: 3 additions & 3 deletions ch15-01-box.html
Original file line number Diff line number Diff line change
Expand Up @@ -203,10 +203,10 @@ <h2 id="using-boxt-to-point-to-data-on-the-heap"><a class="header" href="#using-
this situation, we can store the large amount of data on the heap in a box.
Then, only the small amount of pointer data is copied around on the stack,
while the data it references stays in one place on the heap. The third case is
known as a <em>trait object</em>, and Chapter 17 devotes an entire section, <a href="ch18-02-trait-objects.html#using-trait-objects-that-allow-for-values-of-different-types">“Using
known as a <em>trait object</em>, and Chapter 18 devotes an entire section, <a href="ch18-02-trait-objects.html#using-trait-objects-that-allow-for-values-of-different-types">“Using
Trait Objects That Allow for Values of Different Types,”</a><!--
ignore --> just to that topic. So what you learn here you’ll apply again in
Chapter 17!</p>
Chapter 18!</p>
<h3 id="using-a-boxt-to-store-data-on-the-heap"><a class="header" href="#using-a-boxt-to-store-data-on-the-heap">Using a <code>Box&lt;T&gt;</code> to Store Data on the Heap</a></h3>
<p>Before we discuss the heap storage use case for <code>Box&lt;T&gt;</code>, we’ll cover the
syntax and how to interact with values stored within a <code>Box&lt;T&gt;</code>.</p>
Expand Down Expand Up @@ -418,7 +418,7 @@ <h4 id="using-boxt-to-get-a-recursive-type-with-a-known-size"><a class="header"
types. They also don’t have the performance overhead that these special
capabilities incur, so they can be useful in cases like the cons list where the
indirection is the only feature we need. We’ll look at more use cases for boxes
in Chapter 17, too.</p>
in Chapter 18, too.</p>
<p>The <code>Box&lt;T&gt;</code> type is a smart pointer because it implements the <code>Deref</code> trait,
which allows <code>Box&lt;T&gt;</code> values to be treated like references. When a <code>Box&lt;T&gt;</code>
value goes out of scope, the heap data that the box is pointing to is cleaned
Expand Down
2 changes: 1 addition & 1 deletion ch15-02-deref.html
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@ <h3 id="treating-a-type-like-a-reference-by-implementing-the-deref-trait"><a cla
<p>The <code>type Target = T;</code> syntax defines an associated type for the <code>Deref</code>
trait to use. Associated types are a slightly different way of declaring a
generic parameter, but you don’t need to worry about them for now; we’ll cover
them in more detail in Chapter 19.</p>
them in more detail in Chapter 20.</p>
<p>We fill in the body of the <code>deref</code> method with <code>&amp;self.0</code> so <code>deref</code> returns a
reference to the value we want to access with the <code>*</code> operator; recall from the
<a href="ch05-01-defining-structs.html#using-tuple-structs-without-named-fields-to-create-different-types">“Using Tuple Structs without Named Fields to Create Different
Expand Down
2 changes: 1 addition & 1 deletion ch15-05-interior-mutability.html
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ <h2 id="refcellt-and-the-interior-mutability-pattern"><a class="header" href="#r
<code>unsafe</code> code inside a data structure to bend Rust’s usual rules that govern
mutation and borrowing. Unsafe code indicates to the compiler that we’re
checking the rules manually instead of relying on the compiler to check them
for us; we will discuss unsafe code more in Chapter 19.</p>
for us; we will discuss unsafe code more in Chapter 20.</p>
<p>We can use types that use the interior mutability pattern only when we can
ensure that the borrowing rules will be followed at runtime, even though the
compiler can’t guarantee that. The <code>unsafe</code> code involved is then wrapped in a
Expand Down
2 changes: 1 addition & 1 deletion ch16-02-message-passing.html
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ <h2 id="using-message-passing-to-transfer-data-between-threads"><a class="header
for <em>transmitter</em> and <em>receiver</em> respectively, so we name our variables as such
to indicate each end. We’re using a <code>let</code> statement with a pattern that
destructures the tuples; we’ll discuss the use of patterns in <code>let</code> statements
and destructuring in Chapter 18. For now, know that using a <code>let</code> statement
and destructuring in Chapter 19. For now, know that using a <code>let</code> statement
this way is a convenient approach to extract the pieces of the tuple returned
by <code>mpsc::channel</code>.</p>
<p>Let’s move the transmitting end into a spawned thread and have it send one
Expand Down
6 changes: 3 additions & 3 deletions ch16-04-extensible-concurrency-sync-and-send.html
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ <h3 id="allowing-transference-of-ownership-between-threads-with-send"><a class="
compiled.</p>
<p>Any type composed entirely of <code>Send</code> types is automatically marked as <code>Send</code> as
well. Almost all primitive types are <code>Send</code>, aside from raw pointers, which
we’ll discuss in Chapter 19.</p>
we’ll discuss in Chapter 20.</p>
<h3 id="allowing-access-from-multiple-threads-with-sync"><a class="header" href="#allowing-access-from-multiple-threads-with-sync">Allowing Access from Multiple Threads with <code>Sync</code></a></h3>
<p>The <code>Sync</code> marker trait indicates that it is safe for the type implementing
<code>Sync</code> to be referenced from multiple threads. In other words, any type <code>T</code> is
Expand All @@ -223,14 +223,14 @@ <h3 id="implementing-send-and-sync-manually-is-unsafe"><a class="header" href="#
marker traits, they don’t even have any methods to implement. They’re just
useful for enforcing invariants related to concurrency.</p>
<p>Manually implementing these traits involves implementing unsafe Rust code.
We’ll talk about using unsafe Rust code in Chapter 19; for now, the important
We’ll talk about using unsafe Rust code in Chapter 20; for now, the important
information is that building new concurrent types not made up of <code>Send</code> and
<code>Sync</code> parts requires careful thought to uphold the safety guarantees. <a href="../nomicon/index.html">“The
Rustonomicon”</a> has more information about these guarantees and how to
uphold them.</p>
<h2 id="summary"><a class="header" href="#summary">Summary</a></h2>
<p>This isn’t the last you’ll see of concurrency in this book: the whole next
chapter focuses on async programming, and the project in Chapter 20 will use the
chapter focuses on async programming, and the project in Chapter 21 will use the
concepts in this chapter in a more realistic situation than the smaller examples
discussed here.</p>
<p>As mentioned earlier, because very little of how Rust handles concurrency is
Expand Down
Loading

0 comments on commit de2ee83

Please sign in to comment.