Skip to content

Commit

Permalink
rebuild pages from generated-book
Browse files Browse the repository at this point in the history
  • Loading branch information
chriskrycho committed Jul 31, 2024
1 parent 1b06411 commit fa569cf
Show file tree
Hide file tree
Showing 73 changed files with 1,447 additions and 1,180 deletions.
Binary file modified .DS_Store
Binary file not shown.
2 changes: 1 addition & 1 deletion appendix-01-keywords.html
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ <h3 id="raw-identifiers"><a class="header" href="#raw-identifiers">Raw Identifie
identifier. To use <code>match</code> as a function name, you need to use the raw
identifier syntax, like this:</p>
<p><span class="filename">Filename: src/main.rs</span></p>
<pre><pre class="playground"><code class="language-rust">fn r#match(needle: &amp;str, haystack: &amp;str) -&gt; bool {
<pre><pre class="playground"><code class="language-rust edition2021">fn r#match(needle: &amp;str, haystack: &amp;str) -&gt; bool {
haystack.contains(needle)
}

Expand Down
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="ch19-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 19.</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
8 changes: 4 additions & 4 deletions appendix-04-useful-development-tools.html
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ <h3 id="fix-your-code-with-rustfix"><a class="header" href="#fix-your-code-with-
what you want. It’s likely you’ve seen compiler warnings before. For example,
consider this code:</p>
<p><span class="filename">Filename: src/main.rs</span></p>
<pre><pre class="playground"><code class="language-rust">fn do_something() {}
<pre><pre class="playground"><code class="language-rust edition2021">fn do_something() {}

fn main() {
for i in 0..100 {
Expand Down Expand Up @@ -236,7 +236,7 @@ <h3 id="fix-your-code-with-rustfix"><a class="header" href="#fix-your-code-with-
<p>When we look at <em>src/main.rs</em> again, we’ll see that <code>cargo fix</code> has changed the
code:</p>
<p><span class="filename">Filename: src/main.rs</span></p>
<pre><pre class="playground"><code class="language-rust">fn do_something() {}
<pre><pre class="playground"><code class="language-rust edition2021">fn do_something() {}

fn main() {
for _i in 0..100 {
Expand All @@ -258,7 +258,7 @@ <h3 id="more-lints-with-clippy"><a class="header" href="#more-lints-with-clippy"
<p>For example, say you write a program that uses an approximation of a
mathematical constant, such as pi, as this program does:</p>
<p><span class="filename">Filename: src/main.rs</span></p>
<pre><pre class="playground"><code class="language-rust">fn main() {
<pre><pre class="playground"><code class="language-rust edition2021">fn main() {
let x = 3.1415;
let r = 8.0;
println!("the area of the circle is {}", x * r * r);
Expand All @@ -279,7 +279,7 @@ <h3 id="more-lints-with-clippy"><a class="header" href="#more-lints-with-clippy"
instead. You would then change your code to use the <code>PI</code> constant. The
following code doesn’t result in any errors or warnings from Clippy:</p>
<p><span class="filename">Filename: src/main.rs</span></p>
<pre><pre class="playground"><code class="language-rust">fn main() {
<pre><pre class="playground"><code class="language-rust edition2021">fn main() {
let x = std::f64::consts::PI;
let r = 8.0;
println!("the area of the circle is {}", x * r * r);
Expand Down
6 changes: 3 additions & 3 deletions ch01-02-hello-world.html
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ <h3 id="writing-and-running-a-rust-program"><a class="header" href="#writing-and
<p>Now open the <em>main.rs</em> file you just created and enter the code in Listing 1-1.</p>
<figure class="listing">
<span class="file-name">Filename: main.rs</span>
<pre><pre class="playground"><code class="language-rust">fn main() {
<pre><pre class="playground"><code class="language-rust edition2021">fn main() {
println!("Hello, world!");
}</code></pre></pre>
<figcaption>Listing 1-1: A program that prints <code>Hello, world!</code></figcaption>
Expand All @@ -246,7 +246,7 @@ <h3 id="writing-and-running-a-rust-program"><a class="header" href="#writing-and
<h3 id="anatomy-of-a-rust-program"><a class="header" href="#anatomy-of-a-rust-program">Anatomy of a Rust Program</a></h3>
<p>Let’s review this “Hello, world!” program in detail. Here’s the first piece of
the puzzle:</p>
<pre><pre class="playground"><code class="language-rust">fn main() {
<pre><pre class="playground"><code class="language-rust edition2021">fn main() {

}</code></pre></pre>
<p>These lines define a function named <code>main</code>. The <code>main</code> function is special: it
Expand All @@ -265,7 +265,7 @@ <h3 id="anatomy-of-a-rust-program"><a class="header" href="#anatomy-of-a-rust-pr
installed on your computer!</p>
</section>
<p>The body of the <code>main</code> function holds the following code:</p>
<pre><pre class="playground"><code class="language-rust"><span class="boring">#![allow(unused)]
<pre><pre class="playground"><code class="language-rust edition2021"><span class="boring">#![allow(unused)]
</span><span class="boring">fn main() {
</span> println!("Hello, world!");
<span class="boring">}</span></code></pre></pre>
Expand Down
2 changes: 1 addition & 1 deletion ch01-03-hello-cargo.html
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ <h3 id="creating-a-project-with-cargo"><a class="header" href="#creating-a-proje
first project in Chapter 2, so we’ll use this dependencies section then.</p>
<p>Now open <em>src/main.rs</em> and take a look:</p>
<p><span class="filename">Filename: src/main.rs</span></p>
<pre><pre class="playground"><code class="language-rust">fn main() {
<pre><pre class="playground"><code class="language-rust edition2021">fn main() {
println!("Hello, world!");
}</code></pre></pre>
<p>Cargo has generated a “Hello, world!” program for you, just like the one we
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 @@ -223,7 +223,7 @@ <h2 id="setting-up-a-new-project"><a class="header" href="#setting-up-a-new-proj
<p>As you saw in Chapter 1, <code>cargo new</code> generates a “Hello, world!” program for
you. Check out the <em>src/main.rs</em> file:</p>
<p><span class="filename">Filename: src/main.rs</span></p>
<pre><pre class="playground"><code class="language-rust">fn main() {
<pre><pre class="playground"><code class="language-rust edition2021">fn main() {
println!("Hello, world!");
}</code></pre></pre>
<p>Now let’s compile this “Hello, world!” program and run it in the same step
Expand Down Expand Up @@ -513,7 +513,7 @@ <h3 id="printing-values-with-println-placeholders"><a class="header" href="#prin
format string with a comma-separated list of expressions to print in each empty
curly bracket placeholder in the same order. Printing a variable and the result
of an expression in one call to <code>println!</code> would look like this:</p>
<pre><pre class="playground"><code class="language-rust"><span class="boring">#![allow(unused)]
<pre><pre class="playground"><code class="language-rust edition2021"><span class="boring">#![allow(unused)]
</span><span class="boring">fn main() {
</span>let x = 5;
let y = 10;
Expand Down
8 changes: 4 additions & 4 deletions ch03-01-variables-and-mutability.html
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ <h2 id="variables-and-mutability"><a class="header" href="#variables-and-mutabil
will be changing this variable’s value.</p>
<p>For example, let’s change <em>src/main.rs</em> to the following:</p>
<p><span class="filename">Filename: src/main.rs</span></p>
<pre><pre class="playground"><code class="language-rust">fn main() {
<pre><pre class="playground"><code class="language-rust edition2021">fn main() {
let mut x = 5;
println!("The value of x is: {x}");
x = 6;
Expand Down Expand Up @@ -274,7 +274,7 @@ <h3 id="constants"><a class="header" href="#constants">Constants</a></h3>
<p>The last difference is that constants may be set only to a constant expression,
not the result of a value that could only be computed at runtime.</p>
<p>Here’s an example of a constant declaration:</p>
<pre><pre class="playground"><code class="language-rust"><span class="boring">#![allow(unused)]
<pre><pre class="playground"><code class="language-rust edition2021"><span class="boring">#![allow(unused)]
</span><span class="boring">fn main() {
</span>const THREE_HOURS_IN_SECONDS: u32 = 60 * 60 * 3;
<span class="boring">}</span></code></pre></pre>
Expand Down Expand Up @@ -308,7 +308,7 @@ <h3 id="shadowing"><a class="header" href="#shadowing">Shadowing</a></h3>
We can shadow a variable by using the same variable’s name and repeating the
use of the <code>let</code> keyword as follows:</p>
<p><span class="filename">Filename: src/main.rs</span></p>
<pre><pre class="playground"><code class="language-rust">fn main() {
<pre><pre class="playground"><code class="language-rust edition2021">fn main() {
let x = 5;

let x = x + 1;
Expand Down Expand Up @@ -344,7 +344,7 @@ <h3 id="shadowing"><a class="header" href="#shadowing">Shadowing</a></h3>
change the type of the value but reuse the same name. For example, say our
program asks a user to show how many spaces they want between some text by
inputting space characters, and then we want to store that input as a number:</p>
<pre><pre class="playground"><code class="language-rust"><span class="boring">fn main() {
<pre><pre class="playground"><code class="language-rust edition2021"><span class="boring">fn main() {
</span> let spaces = " ";
let spaces = spaces.len();
<span class="boring">}</span></code></pre></pre>
Expand Down
26 changes: 13 additions & 13 deletions ch03-02-data-types.html
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ <h2 id="data-types"><a class="header" href="#data-types">Data Types</a></h2>
type using <code>parse</code> in the <a href="ch02-00-guessing-game-tutorial.html#comparing-the-guess-to-the-secret-number">“Comparing the Guess to the Secret
Number”</a><!-- ignore --> section in
Chapter 2, we must add a type annotation, like this:</p>
<pre><pre class="playground"><code class="language-rust"><span class="boring">#![allow(unused)]
<pre><pre class="playground"><code class="language-rust edition2021"><span class="boring">#![allow(unused)]
</span><span class="boring">fn main() {
</span>let guess: u32 = "42".parse().expect("Not a number!");
<span class="boring">}</span></code></pre></pre>
Expand Down Expand Up @@ -311,7 +311,7 @@ <h4 id="floating-point-types"><a class="header" href="#floating-point-types">Flo
more precision. All floating-point types are signed.</p>
<p>Here’s an example that shows floating-point numbers in action:</p>
<p><span class="filename">Filename: src/main.rs</span></p>
<pre><pre class="playground"><code class="language-rust">fn main() {
<pre><pre class="playground"><code class="language-rust edition2021">fn main() {
let x = 2.0; // f64

let y: f32 = 3.0; // f32
Expand All @@ -324,7 +324,7 @@ <h4 id="numeric-operations"><a class="header" href="#numeric-operations">Numeric
division truncates toward zero to the nearest integer. The following code shows
how you’d use each numeric operation in a <code>let</code> statement:</p>
<p><span class="filename">Filename: src/main.rs</span></p>
<pre><pre class="playground"><code class="language-rust">fn main() {
<pre><pre class="playground"><code class="language-rust edition2021">fn main() {
// addition
let sum = 5 + 10;

Expand All @@ -350,7 +350,7 @@ <h4 id="the-boolean-type"><a class="header" href="#the-boolean-type">The Boolean
values: <code>true</code> and <code>false</code>. Booleans are one byte in size. The Boolean type in
Rust is specified using <code>bool</code>. For example:</p>
<p><span class="filename">Filename: src/main.rs</span></p>
<pre><pre class="playground"><code class="language-rust">fn main() {
<pre><pre class="playground"><code class="language-rust edition2021">fn main() {
let t = true;

let f: bool = false; // with explicit type annotation
Expand All @@ -362,7 +362,7 @@ <h4 id="the-character-type"><a class="header" href="#the-character-type">The Cha
<p>Rust’s <code>char</code> type is the language’s most primitive alphabetic type. Here are
some examples of declaring <code>char</code> values:</p>
<p><span class="filename">Filename: src/main.rs</span></p>
<pre><pre class="playground"><code class="language-rust">fn main() {
<pre><pre class="playground"><code class="language-rust edition2021">fn main() {
let c = 'z';
let z: char = 'ℤ'; // with explicit type annotation
let heart_eyed_cat = '😻';
Expand All @@ -389,14 +389,14 @@ <h4 id="the-tuple-type"><a class="header" href="#the-tuple-type">The Tuple Type<
different values in the tuple don’t have to be the same. We’ve added optional
type annotations in this example:</p>
<p><span class="filename">Filename: src/main.rs</span></p>
<pre><pre class="playground"><code class="language-rust">fn main() {
<pre><pre class="playground"><code class="language-rust edition2021">fn main() {
let tup: (i32, f64, u8) = (500, 6.4, 1);
}</code></pre></pre>
<p>The variable <code>tup</code> binds to the entire tuple because a tuple is considered a
single compound element. To get the individual values out of a tuple, we can
use pattern matching to destructure a tuple value, like this:</p>
<p><span class="filename">Filename: src/main.rs</span></p>
<pre><pre class="playground"><code class="language-rust">fn main() {
<pre><pre class="playground"><code class="language-rust edition2021">fn main() {
let tup = (500, 6.4, 1);

let (x, y, z) = tup;
Expand All @@ -411,7 +411,7 @@ <h4 id="the-tuple-type"><a class="header" href="#the-tuple-type">The Tuple Type<
<p>We can also access a tuple element directly by using a period (<code>.</code>) followed by
the index of the value we want to access. For example:</p>
<p><span class="filename">Filename: src/main.rs</span></p>
<pre><pre class="playground"><code class="language-rust">fn main() {
<pre><pre class="playground"><code class="language-rust edition2021">fn main() {
let x: (i32, f64, u8) = (500, 6.4, 1);

let five_hundred = x.0;
Expand All @@ -434,7 +434,7 @@ <h4 id="the-array-type"><a class="header" href="#the-array-type">The Array Type<
<p>We write the values in an array as a comma-separated list inside square
brackets:</p>
<p><span class="filename">Filename: src/main.rs</span></p>
<pre><pre class="playground"><code class="language-rust">fn main() {
<pre><pre class="playground"><code class="language-rust edition2021">fn main() {
let a = [1, 2, 3, 4, 5];
}</code></pre></pre>
<p>Arrays are useful when you want your data allocated on the stack rather than
Expand All @@ -449,14 +449,14 @@ <h4 id="the-array-type"><a class="header" href="#the-array-type">The Array Type<
need to change. For example, if you were using the names of the month in a
program, you would probably use an array rather than a vector because you know
it will always contain 12 elements:</p>
<pre><pre class="playground"><code class="language-rust"><span class="boring">#![allow(unused)]
<pre><pre class="playground"><code class="language-rust edition2021"><span class="boring">#![allow(unused)]
</span><span class="boring">fn main() {
</span>let months = ["January", "February", "March", "April", "May", "June", "July",
"August", "September", "October", "November", "December"];
<span class="boring">}</span></code></pre></pre>
<p>You write an array’s type using square brackets with the type of each element,
a semicolon, and then the number of elements in the array, like so:</p>
<pre><pre class="playground"><code class="language-rust"><span class="boring">#![allow(unused)]
<pre><pre class="playground"><code class="language-rust edition2021"><span class="boring">#![allow(unused)]
</span><span class="boring">fn main() {
</span>let a: [i32; 5] = [1, 2, 3, 4, 5];
<span class="boring">}</span></code></pre></pre>
Expand All @@ -465,7 +465,7 @@ <h4 id="the-array-type"><a class="header" href="#the-array-type">The Array Type<
<p>You can also initialize an array to contain the same value for each element by
specifying the initial value, followed by a semicolon, and then the length of
the array in square brackets, as shown here:</p>
<pre><pre class="playground"><code class="language-rust"><span class="boring">#![allow(unused)]
<pre><pre class="playground"><code class="language-rust edition2021"><span class="boring">#![allow(unused)]
</span><span class="boring">fn main() {
</span>let a = [3; 5];
<span class="boring">}</span></code></pre></pre>
Expand All @@ -477,7 +477,7 @@ <h5 id="accessing-array-elements"><a class="header" href="#accessing-array-eleme
allocated on the stack. You can access elements of an array using indexing,
like this:</p>
<p><span class="filename">Filename: src/main.rs</span></p>
<pre><pre class="playground"><code class="language-rust">fn main() {
<pre><pre class="playground"><code class="language-rust edition2021">fn main() {
let a = [1, 2, 3, 4, 5];

let first = a[0];
Expand Down
Loading

0 comments on commit fa569cf

Please sign in to comment.