diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml
index 1737bce009..b460baa601 100644
--- a/.github/workflows/main.yml
+++ b/.github/workflows/main.yml
@@ -1,6 +1,10 @@
name: CI
on: [push, pull_request]
+env:
+ # Update the language picker in index.hbs to link new languages.
+ LANGUAGES:
+
jobs:
test:
name: Run tests
@@ -17,7 +21,7 @@ jobs:
- name: Install mdbook
run: |
mkdir bin
- curl -sSL https://github.com/rust-lang/mdBook/releases/download/v0.4.21/mdbook-v0.4.21-x86_64-unknown-linux-gnu.tar.gz | tar -xz --directory=bin
+ curl -sSL https://github.com/rust-lang/mdBook/releases/download/v0.4.37/mdbook-v0.4.37-x86_64-unknown-linux-gnu.tar.gz | tar -xz --directory=bin
echo "$(pwd)/bin" >> "${GITHUB_PATH}"
- name: Report versions
run: |
@@ -64,8 +68,10 @@ jobs:
- name: Install mdbook
run: |
mkdir bin
- curl -sSL https://github.com/rust-lang/mdBook/releases/download/v0.4.21/mdbook-v0.4.21-x86_64-unknown-linux-gnu.tar.gz | tar -xz --directory=bin
+ curl -sSL https://github.com/rust-lang/mdBook/releases/download/v0.4.37/mdbook-v0.4.37-x86_64-unknown-linux-gnu.tar.gz | tar -xz --directory=bin
echo "$(pwd)/bin" >> "${GITHUB_PATH}"
+ - name: Install mdbook-i18n-helpers
+ run: cargo install mdbook-i18n-helpers --locked --version 0.3.3
- name: Install mdbook-trpl-note
run: cargo install --path packages/mdbook-trpl-note
- name: Install mdbook-trpl-listing
@@ -97,3 +103,17 @@ jobs:
https://raw.githubusercontent.com/rust-lang/rust/master/src/tools/linkchecker/linkcheck.sh
# Cannot use --all here because of the generated redirect pages aren't available.
sh linkcheck.sh book
+ - name: Build all translations
+ run: |
+ for po_lang in ${{ env.LANGUAGES }}; do
+ echo "::group::Building $po_lang translation"
+ MDBOOK_BOOK__LANGUAGE=$po_lang \
+ mdbook build -d book/$po_lang
+ echo "::endgroup::"
+ done
+ - name: Check all translations for broken links
+ run: |
+ for po_lang in ${{ env.LANGUAGES }}; do
+ MDBOOK_BOOK__LANGUAGE=$po_lang \
+ sh linkcheck.sh --all rust-by-example
+ done
diff --git a/.gitignore b/.gitignore
index 17127d1142..2cbfc24112 100644
--- a/.gitignore
+++ b/.gitignore
@@ -4,5 +4,6 @@ book/
.DS_Store
target
tmp
+po/messages.pot
.nova
diff --git a/README.md b/README.md
index 8befc1b31e..3be0610240 100644
--- a/README.md
+++ b/README.md
@@ -66,6 +66,21 @@ To run the tests:
$ mdbook test
```
+The following warnings can be ignored safely if you don't build a translated version.
+
+```
+[WARN] (mdbook::preprocess::cmd): The command wasn't found, is the "gettext" preprocessor installed?
+[WARN] (mdbook::preprocess::cmd): Command: mdbook-gettext
+```
+
+### Building translated version
+
+If there is a translated resource in `po/` directory, it can be specified through `MDBOOK_BOOK__LANGUAGE` like below:
+
+```bash
+MDBOOK_BOOK__LANGUAGE=ja mdbook build
+```
+
## Contributing
We'd love your help! Please see [CONTRIBUTING.md][contrib] to learn about the
@@ -85,6 +100,12 @@ isn't strictly fixing an error, it might sit until the next time that we're
working on a large revision: expect on the order of months or years. Thank you
for your patience!
+## Translating
+
+Please see the [TRANSLATING.md] file for more details.
+
+[TRANSLATING.md]: https://github.com/rust-lang/book/blob/main/TRANSLATING.md
+
### Translations
We'd love help translating the book! See the [Translations] label to join in
diff --git a/TRANSLATING.md b/TRANSLATING.md
new file mode 100644
index 0000000000..bf1c2969da
--- /dev/null
+++ b/TRANSLATING.md
@@ -0,0 +1,98 @@
+# Translation guidelines
+
+Please see the [CONTRIBUTING.md] file for general contribution guidelines.
+This file describes about the translation workflow.
+
+[CONTRIBUTING.md]: https://github.com/rust-lang/book/blob/main/CONTRIBUTING.md
+
+## Translation workflow
+
+### Preparation
+
+The book uses [mdbook-i18n-helpers](https://github.com/google/mdbook-i18n-helpers) as a translation framework.
+The following tools are required.
+
+* GNU gettext utilities ( `msgmerge` and `msgcat` )
+* mdbook-i18n-helpers ( `cargo install mdbook-i18n-helpers` )
+
+### Creating and Updating Translations
+
+Please see the [mdbook-i18n-helpers USAGE](https://github.com/google/mdbook-i18n-helpers/blob/main/i18n-helpers/USAGE.md) file for the detailed usage of mdbook-i18n-helpers.
+The summarized command list is below:
+
+#### Generating a message template
+
+The generated message templete `po/messages.pot` is required to create or update translations.
+
+```bash
+MDBOOK_OUTPUT='{"xgettext": {"pot-file": "messages.pot"}}' \
+ mdbook build -d po
+```
+
+#### Creating a new translation resource
+
+`xx` is [ISO 639](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes) language code.
+
+```bash
+msginit -i po/messages.pot -l xx -o po/xx.po
+```
+
+#### Updating the exising translation resource
+
+```bash
+msgmerge --update po/xx.po po/messages.pot
+```
+
+### Editing translation resources
+
+After generating a translation resource `po/xx.po`, you can write translation messages in `msgstr` entry of `po/xx.po`.
+To build a translated book, the following command can be used.
+
+```bash
+MDBOOK_BOOK__LANGUAGE=xx mdbook build
+MDBOOK_BOOK__LANGUAGE=xx mdbook serve
+```
+
+### Add a language entry
+
+Please add a language entry in `.github/workflows/main.yml`, `theme/index.hbs`, and `src/bootstrap/src/core/build_steps/doc.rs` in [rust-lang/rust](https://github.com/rust-lang/rust) like below:
+
+* `main.yml`
+
+```yml
+env:
+ # Update the language picker in index.hbs to link new languages.
+ LANGUAGES: xx yy zz
+```
+
+* `index.hbs`
+
+```html
+
+
+
+
+
+
+```
+
+* `src/bootstrap/src/core/build_steps/doc.rs` in [rust-lang/rust](https://github.com/rust-lang/rust)
+
+```rust
+// build book
+builder.ensure(RustbookSrc {
+ target,
+ name: "book".to_owned(),
+ src: absolute_path.clone(),
+ parent: Some(self),
+ languages: vec!["xx", "yy", "zz"],
+});
+```
diff --git a/book.toml b/book.toml
index 800adcf0f5..158b699687 100644
--- a/book.toml
+++ b/book.toml
@@ -6,7 +6,7 @@ title = "The Rust Programming Language"
authors = ["Steve Klabnik", "Carol Nichols", "Contributions from the Rust Community"]
[output.html]
-additional-css = ["ferris.css", "theme/2018-edition.css", "theme/semantic-notes.css", "theme/listing.css"]
+additional-css = ["ferris.css", "theme/css/2018-edition.css", "theme/css/semantic-notes.css", "theme/css/listing.css", "theme/css/language-picker.css"]
additional-js = ["ferris.js"]
git-repository-url = "https://github.com/rust-lang/book"
@@ -18,3 +18,9 @@ output-mode = "default"
[rust]
edition = "2021"
+
+[build]
+extra-watch-dirs = ["po"]
+
+[preprocessor.gettext]
+after = ["links"]
diff --git a/po/ja.po b/po/ja.po
new file mode 100644
index 0000000000..c8953d609e
--- /dev/null
+++ b/po/ja.po
@@ -0,0 +1,36512 @@
+msgid ""
+msgstr ""
+"Project-Id-Version: The Rust Programming Language\n"
+"POT-Creation-Date: 2024-10-02T09:25:03+09:00\n"
+"PO-Revision-Date: 2024-06-06 09:50+0900\n"
+"Last-Translator: Naoya Hatta \n"
+"Language-Team: Japanese\n"
+"Language: ja\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+"Plural-Forms: nplurals=1; plural=0;\n"
+
+#: src/SUMMARY.md:1 src/SUMMARY.md:3 src/title-page.md:1
+msgid "The Rust Programming Language"
+msgstr "The Rust Programming Language 日本語版"
+
+#: src/SUMMARY.md:4 src/foreword.md:1
+msgid "Foreword"
+msgstr ""
+
+#: src/SUMMARY.md:5 src/ch00-00-introduction.md:1
+msgid "Introduction"
+msgstr ""
+
+#: src/SUMMARY.md:7
+msgid "Getting started"
+msgstr ""
+
+#: src/SUMMARY.md:9 src/ch01-00-getting-started.md:1
+msgid "Getting Started"
+msgstr ""
+
+#: src/SUMMARY.md:10 src/ch01-01-installation.md:1
+msgid "Installation"
+msgstr ""
+
+#: src/SUMMARY.md:11 src/ch01-02-hello-world.md:1
+msgid "Hello, World!"
+msgstr ""
+
+#: src/SUMMARY.md:12 src/ch01-03-hello-cargo.md:1
+msgid "Hello, Cargo!"
+msgstr ""
+
+#: src/SUMMARY.md:14 src/ch02-00-guessing-game-tutorial.md:1
+msgid "Programming a Guessing Game"
+msgstr ""
+
+#: src/SUMMARY.md:16 src/ch03-00-common-programming-concepts.md:1
+msgid "Common Programming Concepts"
+msgstr ""
+
+#: src/SUMMARY.md:17 src/ch03-01-variables-and-mutability.md:1
+msgid "Variables and Mutability"
+msgstr ""
+
+#: src/SUMMARY.md:18 src/ch03-02-data-types.md:1
+msgid "Data Types"
+msgstr ""
+
+#: src/SUMMARY.md:19 src/ch03-03-how-functions-work.md:1
+msgid "Functions"
+msgstr ""
+
+#: src/SUMMARY.md:20 src/ch03-04-comments.md:1
+msgid "Comments"
+msgstr ""
+
+#: src/SUMMARY.md:21 src/ch03-05-control-flow.md:1
+msgid "Control Flow"
+msgstr ""
+
+#: src/SUMMARY.md:23 src/ch04-00-understanding-ownership.md:1
+msgid "Understanding Ownership"
+msgstr ""
+
+#: src/SUMMARY.md:24
+msgid "What is Ownership?"
+msgstr ""
+
+#: src/SUMMARY.md:25 src/ch04-02-references-and-borrowing.md:1
+msgid "References and Borrowing"
+msgstr ""
+
+#: src/SUMMARY.md:26 src/ch04-03-slices.md:1
+msgid "The Slice Type"
+msgstr ""
+
+#: src/SUMMARY.md:28 src/ch05-00-structs.md:1
+msgid "Using Structs to Structure Related Data"
+msgstr ""
+
+#: src/SUMMARY.md:29 src/ch05-01-defining-structs.md:1
+msgid "Defining and Instantiating Structs"
+msgstr ""
+
+#: src/SUMMARY.md:30 src/ch05-02-example-structs.md:1
+msgid "An Example Program Using Structs"
+msgstr ""
+
+#: src/SUMMARY.md:31 src/ch05-03-method-syntax.md:1
+msgid "Method Syntax"
+msgstr ""
+
+#: src/SUMMARY.md:33 src/ch06-00-enums.md:1
+msgid "Enums and Pattern Matching"
+msgstr ""
+
+#: src/SUMMARY.md:34 src/ch06-01-defining-an-enum.md:1
+msgid "Defining an Enum"
+msgstr ""
+
+#: src/SUMMARY.md:35 src/ch06-02-match.md:3
+msgid "The `match` Control Flow Construct"
+msgstr ""
+
+#: src/SUMMARY.md:36 src/ch06-03-if-let.md:1
+msgid "Concise Control Flow with `if let`"
+msgstr ""
+
+#: src/SUMMARY.md:38
+msgid "Basic Rust Literacy"
+msgstr ""
+
+#: src/SUMMARY.md:40
+#: src/ch07-00-managing-growing-projects-with-packages-crates-and-modules.md:1
+msgid "Managing Growing Projects with Packages, Crates, and Modules"
+msgstr ""
+
+#: src/SUMMARY.md:41 src/ch07-01-packages-and-crates.md:1
+msgid "Packages and Crates"
+msgstr ""
+
+#: src/SUMMARY.md:42
+#: src/ch07-02-defining-modules-to-control-scope-and-privacy.md:1
+msgid "Defining Modules to Control Scope and Privacy"
+msgstr ""
+
+#: src/SUMMARY.md:43
+#: src/ch07-03-paths-for-referring-to-an-item-in-the-module-tree.md:1
+msgid "Paths for Referring to an Item in the Module Tree"
+msgstr ""
+
+#: src/SUMMARY.md:44
+msgid "Bringing Paths Into Scope with the `use` Keyword"
+msgstr ""
+
+#: src/SUMMARY.md:45 src/ch07-05-separating-modules-into-different-files.md:1
+msgid "Separating Modules into Different Files"
+msgstr ""
+
+#: src/SUMMARY.md:47 src/ch08-00-common-collections.md:1
+msgid "Common Collections"
+msgstr ""
+
+#: src/SUMMARY.md:48 src/ch08-01-vectors.md:1
+msgid "Storing Lists of Values with Vectors"
+msgstr ""
+
+#: src/SUMMARY.md:49 src/ch08-02-strings.md:1
+msgid "Storing UTF-8 Encoded Text with Strings"
+msgstr ""
+
+#: src/SUMMARY.md:50 src/ch08-03-hash-maps.md:1
+msgid "Storing Keys with Associated Values in Hash Maps"
+msgstr ""
+
+#: src/SUMMARY.md:52 src/ch09-00-error-handling.md:1
+msgid "Error Handling"
+msgstr ""
+
+#: src/SUMMARY.md:53 src/ch09-01-unrecoverable-errors-with-panic.md:1
+msgid "Unrecoverable Errors with `panic!`"
+msgstr ""
+
+#: src/SUMMARY.md:54 src/ch09-02-recoverable-errors-with-result.md:1
+msgid "Recoverable Errors with `Result`"
+msgstr ""
+
+#: src/SUMMARY.md:55 src/ch09-03-to-panic-or-not-to-panic.md:1
+msgid "To `panic!` or Not to `panic!`"
+msgstr ""
+
+#: src/SUMMARY.md:57 src/ch10-00-generics.md:1
+msgid "Generic Types, Traits, and Lifetimes"
+msgstr ""
+
+#: src/SUMMARY.md:58 src/ch10-01-syntax.md:1
+msgid "Generic Data Types"
+msgstr ""
+
+#: src/SUMMARY.md:59 src/ch10-02-traits.md:1
+msgid "Traits: Defining Shared Behavior"
+msgstr ""
+
+#: src/SUMMARY.md:60 src/ch10-03-lifetime-syntax.md:1
+msgid "Validating References with Lifetimes"
+msgstr ""
+
+#: src/SUMMARY.md:62 src/ch11-00-testing.md:1
+msgid "Writing Automated Tests"
+msgstr ""
+
+#: src/SUMMARY.md:63 src/ch11-01-writing-tests.md:1
+msgid "How to Write Tests"
+msgstr ""
+
+#: src/SUMMARY.md:64 src/ch11-02-running-tests.md:1
+msgid "Controlling How Tests Are Run"
+msgstr ""
+
+#: src/SUMMARY.md:65 src/ch11-03-test-organization.md:1
+msgid "Test Organization"
+msgstr ""
+
+#: src/SUMMARY.md:67 src/ch12-00-an-io-project.md:1
+msgid "An I/O Project: Building a Command Line Program"
+msgstr ""
+
+#: src/SUMMARY.md:68 src/ch12-01-accepting-command-line-arguments.md:1
+msgid "Accepting Command Line Arguments"
+msgstr ""
+
+#: src/SUMMARY.md:69 src/ch12-02-reading-a-file.md:1
+msgid "Reading a File"
+msgstr ""
+
+#: src/SUMMARY.md:70 src/ch12-03-improving-error-handling-and-modularity.md:1
+msgid "Refactoring to Improve Modularity and Error Handling"
+msgstr ""
+
+#: src/SUMMARY.md:71
+msgid "Developing the Library’s Functionality with Test Driven Development"
+msgstr ""
+
+#: src/SUMMARY.md:72 src/ch12-05-working-with-environment-variables.md:1
+msgid "Working with Environment Variables"
+msgstr ""
+
+#: src/SUMMARY.md:73 src/ch12-06-writing-to-stderr-instead-of-stdout.md:1
+msgid "Writing Error Messages to Standard Error Instead of Standard Output"
+msgstr ""
+
+#: src/SUMMARY.md:75
+msgid "Thinking in Rust"
+msgstr ""
+
+#: src/SUMMARY.md:77 src/ch13-00-functional-features.md:1
+msgid "Functional Language Features: Iterators and Closures"
+msgstr ""
+
+#: src/SUMMARY.md:78 src/ch13-01-closures.md:4
+msgid "Closures: Anonymous Functions that Capture Their Environment"
+msgstr ""
+
+#: src/SUMMARY.md:79 src/ch13-02-iterators.md:1
+msgid "Processing a Series of Items with Iterators"
+msgstr ""
+
+#: src/SUMMARY.md:80 src/ch13-03-improving-our-io-project.md:1
+msgid "Improving Our I/O Project"
+msgstr ""
+
+#: src/SUMMARY.md:81 src/ch13-04-performance.md:1
+msgid "Comparing Performance: Loops vs. Iterators"
+msgstr ""
+
+#: src/SUMMARY.md:83
+msgid "More about Cargo and Crates.io"
+msgstr ""
+
+#: src/SUMMARY.md:84 src/ch14-01-release-profiles.md:1
+msgid "Customizing Builds with Release Profiles"
+msgstr ""
+
+#: src/SUMMARY.md:85 src/ch14-02-publishing-to-crates-io.md:1
+msgid "Publishing a Crate to Crates.io"
+msgstr ""
+
+#: src/SUMMARY.md:86 src/ch14-03-cargo-workspaces.md:1
+msgid "Cargo Workspaces"
+msgstr ""
+
+#: src/SUMMARY.md:87
+msgid "Installing Binaries from Crates.io with `cargo install`"
+msgstr ""
+
+#: src/SUMMARY.md:88 src/ch14-05-extending-cargo.md:1
+msgid "Extending Cargo with Custom Commands"
+msgstr ""
+
+#: src/SUMMARY.md:90 src/ch15-00-smart-pointers.md:1
+msgid "Smart Pointers"
+msgstr ""
+
+#: src/SUMMARY.md:91 src/ch15-01-box.md:1
+msgid "Using `Box` to Point to Data on the Heap"
+msgstr ""
+
+#: src/SUMMARY.md:92 src/ch15-02-deref.md:1
+msgid "Treating Smart Pointers Like Regular References with the `Deref` Trait"
+msgstr ""
+
+#: src/SUMMARY.md:93 src/ch15-03-drop.md:1
+msgid "Running Code on Cleanup with the `Drop` Trait"
+msgstr ""
+
+#: src/SUMMARY.md:94 src/ch15-04-rc.md:1
+msgid "`Rc`, the Reference Counted Smart Pointer"
+msgstr ""
+
+#: src/SUMMARY.md:95 src/ch15-05-interior-mutability.md:1
+msgid "`RefCell` and the Interior Mutability Pattern"
+msgstr ""
+
+#: src/SUMMARY.md:96 src/ch15-06-reference-cycles.md:1
+msgid "Reference Cycles Can Leak Memory"
+msgstr ""
+
+#: src/SUMMARY.md:98 src/ch16-00-concurrency.md:1
+msgid "Fearless Concurrency"
+msgstr ""
+
+#: src/SUMMARY.md:99 src/ch16-01-threads.md:1
+msgid "Using Threads to Run Code Simultaneously"
+msgstr ""
+
+#: src/SUMMARY.md:100 src/ch16-02-message-passing.md:1
+msgid "Using Message Passing to Transfer Data Between Threads"
+msgstr ""
+
+#: src/SUMMARY.md:101 src/ch16-03-shared-state.md:1
+msgid "Shared-State Concurrency"
+msgstr ""
+
+#: src/SUMMARY.md:102 src/ch16-04-extensible-concurrency-sync-and-send.md:1
+msgid "Extensible Concurrency with the `Sync` and `Send` Traits"
+msgstr ""
+
+#: src/SUMMARY.md:104
+msgid "Object Oriented Programming Features of Rust"
+msgstr ""
+
+#: src/SUMMARY.md:105 src/ch17-01-what-is-oo.md:1
+msgid "Characteristics of Object-Oriented Languages"
+msgstr ""
+
+#: src/SUMMARY.md:106 src/ch17-02-trait-objects.md:1
+msgid "Using Trait Objects That Allow for Values of Different Types"
+msgstr ""
+
+#: src/SUMMARY.md:107 src/ch17-03-oo-design-patterns.md:1
+msgid "Implementing an Object-Oriented Design Pattern"
+msgstr ""
+
+#: src/SUMMARY.md:109
+msgid "Advanced Topics"
+msgstr ""
+
+#: src/SUMMARY.md:111 src/ch18-00-patterns.md:1
+msgid "Patterns and Matching"
+msgstr ""
+
+#: src/SUMMARY.md:112 src/ch18-01-all-the-places-for-patterns.md:1
+msgid "All the Places Patterns Can Be Used"
+msgstr ""
+
+#: src/SUMMARY.md:113 src/ch18-02-refutability.md:1
+msgid "Refutability: Whether a Pattern Might Fail to Match"
+msgstr ""
+
+#: src/SUMMARY.md:114 src/ch18-03-pattern-syntax.md:1
+msgid "Pattern Syntax"
+msgstr ""
+
+#: src/SUMMARY.md:116 src/ch19-00-advanced-features.md:1
+msgid "Advanced Features"
+msgstr ""
+
+#: src/SUMMARY.md:117 src/ch19-01-unsafe-rust.md:1
+msgid "Unsafe Rust"
+msgstr ""
+
+#: src/SUMMARY.md:118 src/ch19-03-advanced-traits.md:1
+msgid "Advanced Traits"
+msgstr ""
+
+#: src/SUMMARY.md:119 src/ch19-04-advanced-types.md:1
+msgid "Advanced Types"
+msgstr ""
+
+#: src/SUMMARY.md:120 src/ch19-05-advanced-functions-and-closures.md:1
+msgid "Advanced Functions and Closures"
+msgstr ""
+
+#: src/SUMMARY.md:121 src/ch19-06-macros.md:1
+msgid "Macros"
+msgstr ""
+
+#: src/SUMMARY.md:123 src/ch20-00-final-project-a-web-server.md:1
+msgid "Final Project: Building a Multithreaded Web Server"
+msgstr ""
+
+#: src/SUMMARY.md:124 src/ch20-01-single-threaded.md:1
+msgid "Building a Single-Threaded Web Server"
+msgstr ""
+
+#: src/SUMMARY.md:125 src/ch20-02-multithreaded.md:1
+msgid "Turning Our Single-Threaded Server into a Multithreaded Server"
+msgstr ""
+
+#: src/SUMMARY.md:126 src/ch20-03-graceful-shutdown-and-cleanup.md:1
+msgid "Graceful Shutdown and Cleanup"
+msgstr ""
+
+#: src/SUMMARY.md:128 src/appendix-00.md:1
+msgid "Appendix"
+msgstr ""
+
+#: src/SUMMARY.md:129
+msgid "A - Keywords"
+msgstr ""
+
+#: src/SUMMARY.md:130
+msgid "B - Operators and Symbols"
+msgstr ""
+
+#: src/SUMMARY.md:131
+msgid "C - Derivable Traits"
+msgstr ""
+
+#: src/SUMMARY.md:132
+msgid "D - Useful Development Tools"
+msgstr ""
+
+#: src/SUMMARY.md:133
+msgid "E - Editions"
+msgstr ""
+
+#: src/SUMMARY.md:134
+msgid "F - Translations of the Book"
+msgstr ""
+
+#: src/SUMMARY.md:135
+msgid "G - How Rust is Made and “Nightly Rust”"
+msgstr ""
+
+#: src/title-page.md:3
+msgid ""
+"_by Steve Klabnik and Carol Nichols, with contributions from the Rust "
+"Community_"
+msgstr ""
+
+#: src/title-page.md:5
+msgid ""
+"This version of the text assumes you’re using Rust 1.79.0 (released "
+"2024-06-13) or later. See the [“Installation” section of Chapter 1](ch01-01-"
+"installation.html) to install or update Rust."
+msgstr ""
+"このバージョンは Rust 1.79.0 (2024-06-13 リリース) 以降を想定しています。"
+"Rust をインストールしたりアップデートするには[1章の “インストール” 節](ch01-01-installation.html)を参照してください。"
+
+#: src/title-page.md:9
+msgid ""
+"The HTML format is available online at [https://doc.rust-lang.org/stable/"
+"book/](https://doc.rust-lang.org/stable/book/) and offline with "
+"installations of Rust made with `rustup`; run `rustup doc --book` to open."
+msgstr ""
+
+#: src/title-page.md:14
+msgid ""
+"Several community [translations](appendix-06-translation.html) are also "
+"available."
+msgstr ""
+
+#: src/title-page.md:16
+msgid ""
+"This text is available in [paperback and ebook format from No Starch Press]"
+"(https://nostarch.com/rust-programming-language-2nd-edition)."
+msgstr ""
+
+#: src/title-page.md:24
+msgid ""
+"**🚨 Want a more interactive learning experience? Try out a different version "
+"of the Rust Book, featuring: quizzes, highlighting, visualizations, and "
+"more**: "
+msgstr ""
+
+#: src/foreword.md:3
+msgid ""
+"It wasn’t always so clear, but the Rust programming language is "
+"fundamentally about _empowerment_: no matter what kind of code you are "
+"writing now, Rust empowers you to reach farther, to program with confidence "
+"in a wider variety of domains than you did before."
+msgstr ""
+
+#: src/foreword.md:8
+msgid ""
+"Take, for example, “systems-level” work that deals with low-level details of "
+"memory management, data representation, and concurrency. Traditionally, this "
+"realm of programming is seen as arcane, accessible only to a select few who "
+"have devoted the necessary years learning to avoid its infamous pitfalls. "
+"And even those who practice it do so with caution, lest their code be open "
+"to exploits, crashes, or corruption."
+msgstr ""
+
+#: src/foreword.md:15
+msgid ""
+"Rust breaks down these barriers by eliminating the old pitfalls and "
+"providing a friendly, polished set of tools to help you along the way. "
+"Programmers who need to “dip down” into lower-level control can do so with "
+"Rust, without taking on the customary risk of crashes or security holes, and "
+"without having to learn the fine points of a fickle toolchain. Better yet, "
+"the language is designed to guide you naturally towards reliable code that "
+"is efficient in terms of speed and memory usage."
+msgstr ""
+
+#: src/foreword.md:23
+msgid ""
+"Programmers who are already working with low-level code can use Rust to "
+"raise their ambitions. For example, introducing parallelism in Rust is a "
+"relatively low-risk operation: the compiler will catch the classical "
+"mistakes for you. And you can tackle more aggressive optimizations in your "
+"code with the confidence that you won’t accidentally introduce crashes or "
+"vulnerabilities."
+msgstr ""
+
+#: src/foreword.md:29
+msgid ""
+"But Rust isn’t limited to low-level systems programming. It’s expressive and "
+"ergonomic enough to make CLI apps, web servers, and many other kinds of code "
+"quite pleasant to write — you’ll find simple examples of both later in the "
+"book. Working with Rust allows you to build skills that transfer from one "
+"domain to another; you can learn Rust by writing a web app, then apply those "
+"same skills to target your Raspberry Pi."
+msgstr ""
+
+#: src/foreword.md:36
+msgid ""
+"This book fully embraces the potential of Rust to empower its users. It’s a "
+"friendly and approachable text intended to help you level up not just your "
+"knowledge of Rust, but also your reach and confidence as a programmer in "
+"general. So dive in, get ready to learn—and welcome to the Rust community!"
+msgstr ""
+
+#: src/foreword.md:41
+msgid "— Nicholas Matsakis and Aaron Turon"
+msgstr ""
+
+#: src/ch00-00-introduction.md:3
+msgid ""
+"Note: This edition of the book is the same as [The Rust Programming Language]"
+"(https://nostarch.com/rust-programming-language-2nd-edition) available in "
+"print and ebook format from [No Starch Press](https://nostarch.com/)."
+msgstr ""
+
+#: src/ch00-00-introduction.md:10
+msgid ""
+"Welcome to _The Rust Programming Language_, an introductory book about Rust. "
+"The Rust programming language helps you write faster, more reliable "
+"software. High-level ergonomics and low-level control are often at odds in "
+"programming language design; Rust challenges that conflict. Through "
+"balancing powerful technical capacity and a great developer experience, Rust "
+"gives you the option to control low-level details (such as memory usage) "
+"without all the hassle traditionally associated with such control."
+msgstr ""
+
+#: src/ch00-00-introduction.md:18
+msgid "Who Rust Is For"
+msgstr ""
+
+#: src/ch00-00-introduction.md:20
+msgid ""
+"Rust is ideal for many people for a variety of reasons. Let’s look at a few "
+"of the most important groups."
+msgstr ""
+
+#: src/ch00-00-introduction.md:23
+msgid "Teams of Developers"
+msgstr ""
+
+#: src/ch00-00-introduction.md:25
+msgid ""
+"Rust is proving to be a productive tool for collaborating among large teams "
+"of developers with varying levels of systems programming knowledge. Low-"
+"level code is prone to various subtle bugs, which in most other languages "
+"can be caught only through extensive testing and careful code review by "
+"experienced developers. In Rust, the compiler plays a gatekeeper role by "
+"refusing to compile code with these elusive bugs, including concurrency "
+"bugs. By working alongside the compiler, the team can spend their time "
+"focusing on the program’s logic rather than chasing down bugs."
+msgstr ""
+
+#: src/ch00-00-introduction.md:34
+msgid ""
+"Rust also brings contemporary developer tools to the systems programming "
+"world:"
+msgstr ""
+
+#: src/ch00-00-introduction.md:36
+msgid ""
+"Cargo, the included dependency manager and build tool, makes adding, "
+"compiling, and managing dependencies painless and consistent across the Rust "
+"ecosystem."
+msgstr ""
+
+#: src/ch00-00-introduction.md:39
+msgid ""
+"The Rustfmt formatting tool ensures a consistent coding style across "
+"developers."
+msgstr ""
+
+#: src/ch00-00-introduction.md:41
+msgid ""
+"The rust-analyzer powers Integrated Development Environment (IDE) "
+"integration for code completion and inline error messages."
+msgstr ""
+
+#: src/ch00-00-introduction.md:44
+msgid ""
+"By using these and other tools in the Rust ecosystem, developers can be "
+"productive while writing systems-level code."
+msgstr ""
+
+#: src/ch00-00-introduction.md:47
+msgid "Students"
+msgstr ""
+
+#: src/ch00-00-introduction.md:49
+msgid ""
+"Rust is for students and those who are interested in learning about systems "
+"concepts. Using Rust, many people have learned about topics like operating "
+"systems development. The community is very welcoming and happy to answer "
+"student questions. Through efforts such as this book, the Rust teams want to "
+"make systems concepts more accessible to more people, especially those new "
+"to programming."
+msgstr ""
+
+#: src/ch00-00-introduction.md:56
+msgid "Companies"
+msgstr ""
+
+#: src/ch00-00-introduction.md:58
+msgid ""
+"Hundreds of companies, large and small, use Rust in production for a variety "
+"of tasks, including command line tools, web services, DevOps tooling, "
+"embedded devices, audio and video analysis and transcoding, "
+"cryptocurrencies, bioinformatics, search engines, Internet of Things "
+"applications, machine learning, and even major parts of the Firefox web "
+"browser."
+msgstr ""
+
+#: src/ch00-00-introduction.md:64
+msgid "Open Source Developers"
+msgstr ""
+
+#: src/ch00-00-introduction.md:66
+msgid ""
+"Rust is for people who want to build the Rust programming language, "
+"community, developer tools, and libraries. We’d love to have you contribute "
+"to the Rust language."
+msgstr ""
+
+#: src/ch00-00-introduction.md:70
+msgid "People Who Value Speed and Stability"
+msgstr ""
+
+#: src/ch00-00-introduction.md:72
+msgid ""
+"Rust is for people who crave speed and stability in a language. By speed, we "
+"mean both how quickly Rust code can run and the speed at which Rust lets you "
+"write programs. The Rust compiler’s checks ensure stability through feature "
+"additions and refactoring. This is in contrast to the brittle legacy code in "
+"languages without these checks, which developers are often afraid to modify. "
+"By striving for zero-cost abstractions, higher-level features that compile "
+"to lower-level code as fast as code written manually, Rust endeavors to make "
+"safe code be fast code as well."
+msgstr ""
+
+#: src/ch00-00-introduction.md:81
+msgid ""
+"The Rust language hopes to support many other users as well; those mentioned "
+"here are merely some of the biggest stakeholders. Overall, Rust’s greatest "
+"ambition is to eliminate the trade-offs that programmers have accepted for "
+"decades by providing safety _and_ productivity, speed _and_ ergonomics. Give "
+"Rust a try and see if its choices work for you."
+msgstr ""
+
+#: src/ch00-00-introduction.md:87
+msgid "Who This Book Is For"
+msgstr ""
+
+#: src/ch00-00-introduction.md:89
+msgid ""
+"This book assumes that you’ve written code in another programming language "
+"but doesn’t make any assumptions about which one. We’ve tried to make the "
+"material broadly accessible to those from a wide variety of programming "
+"backgrounds. We don’t spend a lot of time talking about what programming "
+"_is_ or how to think about it. If you’re entirely new to programming, you "
+"would be better served by reading a book that specifically provides an "
+"introduction to programming."
+msgstr ""
+
+#: src/ch00-00-introduction.md:96
+msgid "How to Use This Book"
+msgstr ""
+
+#: src/ch00-00-introduction.md:98
+msgid ""
+"In general, this book assumes that you’re reading it in sequence from front "
+"to back. Later chapters build on concepts in earlier chapters, and earlier "
+"chapters might not delve into details on a particular topic but will revisit "
+"the topic in a later chapter."
+msgstr ""
+
+#: src/ch00-00-introduction.md:103
+msgid ""
+"You’ll find two kinds of chapters in this book: concept chapters and project "
+"chapters. In concept chapters, you’ll learn about an aspect of Rust. In "
+"project chapters, we’ll build small programs together, applying what you’ve "
+"learned so far. Chapters 2, 12, and 20 are project chapters; the rest are "
+"concept chapters."
+msgstr ""
+
+#: src/ch00-00-introduction.md:108
+msgid ""
+"Chapter 1 explains how to install Rust, how to write a “Hello, world!” "
+"program, and how to use Cargo, Rust’s package manager and build tool. "
+"Chapter 2 is a hands-on introduction to writing a program in Rust, having "
+"you build up a number guessing game. Here we cover concepts at a high level, "
+"and later chapters will provide additional detail. If you want to get your "
+"hands dirty right away, Chapter 2 is the place for that. Chapter 3 covers "
+"Rust features that are similar to those of other programming languages, and "
+"in Chapter 4 you’ll learn about Rust’s ownership system. If you’re a "
+"particularly meticulous learner who prefers to learn every detail before "
+"moving on to the next, you might want to skip Chapter 2 and go straight to "
+"Chapter 3, returning to Chapter 2 when you’d like to work on a project "
+"applying the details you’ve learned."
+msgstr ""
+
+#: src/ch00-00-introduction.md:120
+msgid ""
+"Chapter 5 discusses structs and methods, and Chapter 6 covers enums, `match` "
+"expressions, and the `if let` control flow construct. You’ll use structs and "
+"enums to make custom types in Rust."
+msgstr ""
+
+#: src/ch00-00-introduction.md:124
+msgid ""
+"In Chapter 7, you’ll learn about Rust’s module system and about privacy "
+"rules for organizing your code and its public Application Programming "
+"Interface (API). Chapter 8 discusses some common collection data structures "
+"that the standard library provides, such as vectors, strings, and hash maps. "
+"Chapter 9 explores Rust’s error-handling philosophy and techniques."
+msgstr ""
+
+#: src/ch00-00-introduction.md:130
+msgid ""
+"Chapter 10 digs into generics, traits, and lifetimes, which give you the "
+"power to define code that applies to multiple types. Chapter 11 is all about "
+"testing, which even with Rust’s safety guarantees is necessary to ensure "
+"your program’s logic is correct. In Chapter 12, we’ll build our own "
+"implementation of a subset of functionality from the `grep` command line "
+"tool that searches for text within files. For this, we’ll use many of the "
+"concepts we discussed in the previous chapters."
+msgstr ""
+
+#: src/ch00-00-introduction.md:138
+msgid ""
+"Chapter 13 explores closures and iterators: features of Rust that come from "
+"functional programming languages. In Chapter 14, we’ll examine Cargo in more "
+"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."
+msgstr ""
+
+#: src/ch00-00-introduction.md:144
+msgid ""
+"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 "
+"principles you might be familiar with."
+msgstr ""
+
+#: src/ch00-00-introduction.md:149
+msgid ""
+"Chapter 18 is a reference on patterns and pattern matching, which are "
+"powerful ways of expressing ideas throughout Rust programs. Chapter 19 "
+"contains a smorgasbord of advanced topics of interest, including unsafe "
+"Rust, macros, and more about lifetimes, traits, types, functions, and "
+"closures."
+msgstr ""
+
+#: src/ch00-00-introduction.md:154
+msgid ""
+"In Chapter 20, we’ll complete a project in which we’ll implement a low-level "
+"multithreaded web server!"
+msgstr ""
+
+#: src/ch00-00-introduction.md:157
+msgid ""
+"Finally, some appendices contain useful information about the language in a "
+"more reference-like format. Appendix A covers Rust’s keywords, Appendix B "
+"covers Rust’s operators and symbols, Appendix C covers derivable traits "
+"provided by the standard library, Appendix D covers some useful development "
+"tools, and Appendix E explains Rust editions. In Appendix F, you can find "
+"translations of the book, and in Appendix G we’ll cover how Rust is made and "
+"what nightly Rust is."
+msgstr ""
+
+#: src/ch00-00-introduction.md:165
+msgid ""
+"There is no wrong way to read this book: if you want to skip ahead, go for "
+"it! You might have to jump back to earlier chapters if you experience any "
+"confusion. But do whatever works for you."
+msgstr ""
+
+#: src/ch00-00-introduction.md:169
+msgid ""
+msgstr ""
+
+#: src/ch00-00-introduction.md:171
+msgid ""
+"An important part of the process of learning Rust is learning how to read "
+"the error messages the compiler displays: these will guide you toward "
+"working code. As such, we’ll provide many examples that don’t compile along "
+"with the error message the compiler will show you in each situation. Know "
+"that if you enter and run a random example, it may not compile! Make sure "
+"you read the surrounding text to see whether the example you’re trying to "
+"run is meant to error. Ferris will also help you distinguish code that isn’t "
+"meant to work:"
+msgstr ""
+
+#: src/ch00-00-introduction.md:179
+msgid "Ferris"
+msgstr ""
+
+#: src/ch00-00-introduction.md:179
+msgid "Meaning"
+msgstr ""
+
+#: src/ch00-00-introduction.md:181
+msgid ""
+""
+msgstr ""
+
+#: src/ch00-00-introduction.md:181
+msgid "This code does not compile!"
+msgstr ""
+
+#: src/ch00-00-introduction.md:182
+msgid ""
+""
+msgstr ""
+
+#: src/ch00-00-introduction.md:182
+msgid "This code panics!"
+msgstr ""
+
+#: src/ch00-00-introduction.md:183
+msgid ""
+""
+msgstr ""
+
+#: src/ch00-00-introduction.md:183
+msgid "This code does not produce the desired behavior."
+msgstr ""
+
+#: src/ch00-00-introduction.md:185
+msgid ""
+"In most situations, we’ll lead you to the correct version of any code that "
+"doesn’t compile."
+msgstr ""
+
+#: src/ch00-00-introduction.md:188
+msgid "Source Code"
+msgstr ""
+
+#: src/ch00-00-introduction.md:190
+msgid ""
+"The source files from which this book is generated can be found on [GitHub]"
+"(https://github.com/rust-lang/book/tree/main/src)."
+msgstr ""
+
+#: src/ch01-00-getting-started.md:3
+msgid ""
+"Let’s start your Rust journey! There’s a lot to learn, but every journey "
+"starts somewhere. In this chapter, we’ll discuss:"
+msgstr ""
+
+#: src/ch01-00-getting-started.md:6
+msgid "Installing Rust on Linux, macOS, and Windows"
+msgstr ""
+
+#: src/ch01-00-getting-started.md:7
+msgid "Writing a program that prints `Hello, world!`"
+msgstr ""
+
+#: src/ch01-00-getting-started.md:8
+msgid "Using `cargo`, Rust’s package manager and build system"
+msgstr ""
+
+#: src/ch01-01-installation.md:3
+msgid ""
+"The first step is to install Rust. We’ll download Rust through `rustup`, a "
+"command line tool for managing Rust versions and associated tools. You’ll "
+"need an internet connection for the download."
+msgstr ""
+
+#: src/ch01-01-installation.md:7
+msgid ""
+"Note: If you prefer not to use `rustup` for some reason, please see the "
+"[Other Rust Installation Methods page](https://forge.rust-lang.org/infra/"
+"other-installation-methods.html) for more options."
+msgstr ""
+
+#: src/ch01-01-installation.md:10
+msgid ""
+"The following steps install the latest stable version of the Rust compiler. "
+"Rust’s stability guarantees ensure that all the examples in the book that "
+"compile will continue to compile with newer Rust versions. The output might "
+"differ slightly between versions because Rust often improves error messages "
+"and warnings. In other words, any newer, stable version of Rust you install "
+"using these steps should work as expected with the content of this book."
+msgstr ""
+
+#: src/ch01-01-installation.md:17
+msgid "Command Line Notation"
+msgstr ""
+
+#: src/ch01-01-installation.md:19
+msgid ""
+"In this chapter and throughout the book, we’ll show some commands used in "
+"the terminal. Lines that you should enter in a terminal all start with `$`. "
+"You don’t need to type the `$` character; it’s the command line prompt shown "
+"to indicate the start of each command. Lines that don’t start with `$` "
+"typically show the output of the previous command. Additionally, PowerShell-"
+"specific examples will use `>` rather than `$`."
+msgstr ""
+
+#: src/ch01-01-installation.md:26
+msgid "Installing `rustup` on Linux or macOS"
+msgstr ""
+
+#: src/ch01-01-installation.md:28
+msgid ""
+"If you’re using Linux or macOS, open a terminal and enter the following "
+"command:"
+msgstr ""
+
+#: src/ch01-01-installation.md:30
+msgid ""
+"```console\n"
+"$ curl --proto '=https' --tlsv1.2 https://sh.rustup.rs -sSf | sh\n"
+"```"
+msgstr ""
+
+#: src/ch01-01-installation.md:34
+msgid ""
+"The command downloads a script and starts the installation of the `rustup` "
+"tool, which installs the latest stable version of Rust. You might be "
+"prompted for your password. If the install is successful, the following line "
+"will appear:"
+msgstr ""
+
+#: src/ch01-01-installation.md:42
+msgid ""
+"You will also need a _linker_, which is a program that Rust uses to join its "
+"compiled outputs into one file. It is likely you already have one. If you "
+"get linker errors, you should install a C compiler, which will typically "
+"include a linker. A C compiler is also useful because some common Rust "
+"packages depend on C code and will need a C compiler."
+msgstr ""
+
+#: src/ch01-01-installation.md:48
+msgid "On macOS, you can get a C compiler by running:"
+msgstr ""
+
+#: src/ch01-01-installation.md:54
+msgid ""
+"Linux users should generally install GCC or Clang, according to their "
+"distribution’s documentation. For example, if you use Ubuntu, you can "
+"install the `build-essential` package."
+msgstr ""
+
+#: src/ch01-01-installation.md:58
+msgid "Installing `rustup` on Windows"
+msgstr ""
+
+#: src/ch01-01-installation.md:60
+msgid ""
+"On Windows, go to [https://www.rust-lang.org/tools/install](https://www.rust-"
+"lang.org/tools/install) and follow the instructions for installing Rust. At "
+"some point in the installation, you’ll be prompted to install Visual Studio. "
+"This provides a linker and the native libraries needed to compile programs. "
+"If you need more help with this step, see [https://rust-lang.github.io/"
+"rustup/installation/windows-msvc.html](https://rust-lang.github.io/rustup/"
+"installation/windows-msvc.html)"
+msgstr ""
+
+#: src/ch01-01-installation.md:66
+msgid ""
+"The rest of this book uses commands that work in both _cmd.exe_ and "
+"PowerShell. If there are specific differences, we’ll explain which to use."
+msgstr ""
+
+#: src/ch01-01-installation.md:69
+msgid "Troubleshooting"
+msgstr ""
+
+#: src/ch01-01-installation.md:71
+msgid ""
+"To check whether you have Rust installed correctly, open a shell and enter "
+"this line:"
+msgstr ""
+
+#: src/ch01-01-installation.md:78
+msgid ""
+"You should see the version number, commit hash, and commit date for the "
+"latest stable version that has been released, in the following format:"
+msgstr ""
+
+#: src/ch01-01-installation.md:85
+msgid ""
+"If you see this information, you have installed Rust successfully! If you "
+"don’t see this information, check that Rust is in your `%PATH%` system "
+"variable as follows."
+msgstr ""
+
+#: src/ch01-01-installation.md:89
+msgid "In Windows CMD, use:"
+msgstr ""
+
+#: src/ch01-01-installation.md:95
+msgid "In PowerShell, use:"
+msgstr ""
+
+#: src/ch01-01-installation.md:101
+msgid "In Linux and macOS, use:"
+msgstr ""
+
+#: src/ch01-01-installation.md:107
+msgid ""
+"If that’s all correct and Rust still isn’t working, there are a number of "
+"places you can get help. Find out how to get in touch with other Rustaceans "
+"(a silly nickname we call ourselves) on [the community page](https://www."
+"rust-lang.org/community)."
+msgstr ""
+
+#: src/ch01-01-installation.md:111
+msgid "Updating and Uninstalling"
+msgstr ""
+
+#: src/ch01-01-installation.md:113
+msgid ""
+"Once Rust is installed via `rustup`, updating to a newly released version is "
+"easy. From your shell, run the following update script:"
+msgstr ""
+
+#: src/ch01-01-installation.md:120
+msgid ""
+"To uninstall Rust and `rustup`, run the following uninstall script from your "
+"shell:"
+msgstr ""
+
+#: src/ch01-01-installation.md:127
+msgid "Local Documentation"
+msgstr ""
+
+#: src/ch01-01-installation.md:129
+msgid ""
+"The installation of Rust also includes a local copy of the documentation so "
+"that you can read it offline. Run `rustup doc` to open the local "
+"documentation in your browser."
+msgstr ""
+
+#: src/ch01-01-installation.md:133
+msgid ""
+"Any time a type or function is provided by the standard library and you’re "
+"not sure what it does or how to use it, use the application programming "
+"interface (API) documentation to find out!"
+msgstr ""
+
+#: src/ch01-02-hello-world.md:3
+msgid ""
+"Now that you’ve installed Rust, it’s time to write your first Rust program. "
+"It’s traditional when learning a new language to write a little program that "
+"prints the text `Hello, world!` to the screen, so we’ll do the same here!"
+msgstr ""
+
+#: src/ch01-02-hello-world.md:7
+msgid ""
+"Note: This book assumes basic familiarity with the command line. Rust makes "
+"no specific demands about your editing or tooling or where your code lives, "
+"so if you prefer to use an integrated development environment (IDE) instead "
+"of the command line, feel free to use your favorite IDE. Many IDEs now have "
+"some degree of Rust support; check the IDE’s documentation for details. The "
+"Rust team has been focusing on enabling great IDE support via `rust-"
+"analyzer`. See [Appendix D](appendix-04-useful-development-tools.html) for more details."
+msgstr ""
+
+#: src/ch01-02-hello-world.md:15
+msgid "Creating a Project Directory"
+msgstr ""
+
+#: src/ch01-02-hello-world.md:17
+msgid ""
+"You’ll start by making a directory to store your Rust code. It doesn’t "
+"matter to Rust where your code lives, but for the exercises and projects in "
+"this book, we suggest making a _projects_ directory in your home directory "
+"and keeping all your projects there."
+msgstr ""
+
+#: src/ch01-02-hello-world.md:22
+msgid ""
+"Open a terminal and enter the following commands to make a _projects_ "
+"directory and a directory for the “Hello, world!” project within the "
+"_projects_ directory."
+msgstr ""
+
+#: src/ch01-02-hello-world.md:25
+msgid "For Linux, macOS, and PowerShell on Windows, enter this:"
+msgstr ""
+
+#: src/ch01-02-hello-world.md:34
+msgid "For Windows CMD, enter this:"
+msgstr ""
+
+#: src/ch01-02-hello-world.md:37 src/ch01-02-hello-world.md:38
+msgid "\"%USERPROFILE%\\projects\""
+msgstr ""
+
+#: src/ch01-02-hello-world.md:43
+msgid "Writing and Running a Rust Program"
+msgstr ""
+
+#: src/ch01-02-hello-world.md:45
+msgid ""
+"Next, make a new source file and call it _main.rs_. Rust files always end "
+"with the _.rs_ extension. If you’re using more than one word in your "
+"filename, the convention is to use an underscore to separate them. For "
+"example, use _hello_world.rs_ rather than _helloworld.rs_."
+msgstr ""
+
+#: src/ch01-02-hello-world.md:50
+msgid ""
+"Now open the _main.rs_ file you just created and enter the code in Listing "
+"1-1."
+msgstr ""
+
+#: src/ch01-02-hello-world.md:56 src/ch01-02-hello-world.md:118
+#: src/ch01-03-hello-cargo.md:98 src/ch02-00-guessing-game-tutorial.md:61
+#: src/ch03-03-how-functions-work.md:16 src/ch04-03-slices.md:361
+#: src/ch19-01-unsafe-rust.md:470
+msgid "\"Hello, world!\""
+msgstr ""
+
+#: src/ch01-02-hello-world.md:62
+msgid ""
+"Save the file and go back to your terminal window in the _~/projects/"
+"hello_world_ directory. On Linux or macOS, enter the following commands to "
+"compile and run the file:"
+msgstr ""
+
+#: src/ch01-02-hello-world.md:72
+msgid "On Windows, enter the command `.\\main.exe` instead of `./main`:"
+msgstr ""
+
+#: src/ch01-02-hello-world.md:80
+msgid ""
+"Regardless of your operating system, the string `Hello, world!` should print "
+"to the terminal. If you don’t see this output, refer back to the "
+"[“Troubleshooting”](ch01-01-installation.html#troubleshooting)). The Rust team has included this "
+"tool with the standard Rust distribution, as `rustc` is, so it should "
+"already be installed on your computer!"
+msgstr ""
+
+#: src/ch01-02-hello-world.md:115
+msgid "The body of the `main` function holds the following code:"
+msgstr ""
+
+#: src/ch01-02-hello-world.md:121
+msgid ""
+"This line does all the work in this little program: it prints text to the "
+"screen. There are four important details to notice here."
+msgstr ""
+
+#: src/ch01-02-hello-world.md:124
+msgid "First, Rust style is to indent with four spaces, not a tab."
+msgstr ""
+
+#: src/ch01-02-hello-world.md:126
+msgid ""
+"Second, `println!` calls a Rust macro. If it had called a function instead, "
+"it would be entered as `println` (without the `!`). We’ll discuss Rust "
+"macros in more detail in Chapter 19. For now, you just need to know that "
+"using a `!` means that you’re calling a macro instead of a normal function "
+"and that macros don’t always follow the same rules as functions."
+msgstr ""
+
+#: src/ch01-02-hello-world.md:132
+msgid ""
+"Third, you see the `\"Hello, world!\"` string. We pass this string as an "
+"argument to `println!`, and the string is printed to the screen."
+msgstr ""
+
+#: src/ch01-02-hello-world.md:135
+msgid ""
+"Fourth, we end the line with a semicolon (`;`), which indicates that this "
+"expression is over and the next one is ready to begin. Most lines of Rust "
+"code end with a semicolon."
+msgstr ""
+
+#: src/ch01-02-hello-world.md:139
+msgid "Compiling and Running Are Separate Steps"
+msgstr ""
+
+#: src/ch01-02-hello-world.md:141
+msgid ""
+"You’ve just run a newly created program, so let’s examine each step in the "
+"process."
+msgstr ""
+
+#: src/ch01-02-hello-world.md:144
+msgid ""
+"Before running a Rust program, you must compile it using the Rust compiler "
+"by entering the `rustc` command and passing it the name of your source file, "
+"like this:"
+msgstr ""
+
+#: src/ch01-02-hello-world.md:152
+msgid ""
+"If you have a C or C++ background, you’ll notice that this is similar to "
+"`gcc` or `clang`. After compiling successfully, Rust outputs a binary "
+"executable."
+msgstr ""
+
+#: src/ch01-02-hello-world.md:155
+msgid ""
+"On Linux, macOS, and PowerShell on Windows, you can see the executable by "
+"entering the `ls` command in your shell:"
+msgstr ""
+
+#: src/ch01-02-hello-world.md:163
+msgid ""
+"On Linux and macOS, you’ll see two files. With PowerShell on Windows, you’ll "
+"see the same three files that you would see using CMD. With CMD on Windows, "
+"you would enter the following:"
+msgstr ""
+
+#: src/ch01-02-hello-world.md:174
+msgid ""
+"This shows the source code file with the _.rs_ extension, the executable "
+"file (_main.exe_ on Windows, but _main_ on all other platforms), and, when "
+"using Windows, a file containing debugging information with the _.pdb_ "
+"extension. From here, you run the _main_ or _main.exe_ file, like this:"
+msgstr ""
+
+#: src/ch01-02-hello-world.md:183
+msgid ""
+"If your _main.rs_ is your “Hello, world!” program, this line prints `Hello, "
+"world!` to your terminal."
+msgstr ""
+
+#: src/ch01-02-hello-world.md:186
+msgid ""
+"If you’re more familiar with a dynamic language, such as Ruby, Python, or "
+"JavaScript, you might not be used to compiling and running a program as "
+"separate steps. Rust is an _ahead-of-time compiled_ language, meaning you "
+"can compile a program and give the executable to someone else, and they can "
+"run it even without having Rust installed. If you give someone a _.rb_, _."
+"py_, or _.js_ file, they need to have a Ruby, Python, or JavaScript "
+"implementation installed (respectively). But in those languages, you only "
+"need one command to compile and run your program. Everything is a trade-off "
+"in language design."
+msgstr ""
+
+#: src/ch01-02-hello-world.md:195
+msgid ""
+"Just compiling with `rustc` is fine for simple programs, but as your project "
+"grows, you’ll want to manage all the options and make it easy to share your "
+"code. Next, we’ll introduce you to the Cargo tool, which will help you write "
+"real-world Rust programs."
+msgstr ""
+
+#: src/ch01-03-hello-cargo.md:3
+msgid ""
+"Cargo is Rust’s build system and package manager. Most Rustaceans use this "
+"tool to manage their Rust projects because Cargo handles a lot of tasks for "
+"you, such as building your code, downloading the libraries your code depends "
+"on, and building those libraries. (We call the libraries that your code "
+"needs _dependencies_.)"
+msgstr ""
+
+#: src/ch01-03-hello-cargo.md:9
+msgid ""
+"The simplest Rust programs, like the one we’ve written so far, don’t have "
+"any dependencies. If we had built the “Hello, world!” project with Cargo, it "
+"would only use the part of Cargo that handles building your code. As you "
+"write more complex Rust programs, you’ll add dependencies, and if you start "
+"a project using Cargo, adding dependencies will be much easier to do."
+msgstr ""
+
+#: src/ch01-03-hello-cargo.md:15
+msgid ""
+"Because the vast majority of Rust projects use Cargo, the rest of this book "
+"assumes that you’re using Cargo too. Cargo comes installed with Rust if you "
+"used the official installers discussed in the [“Installation”](ch01-01-"
+"installation.html#installation) section. If you installed "
+"Rust through some other means, check whether Cargo is installed by entering "
+"the following in your terminal:"
+msgstr ""
+
+#: src/ch01-03-hello-cargo.md:26
+msgid ""
+"If you see a version number, you have it! If you see an error, such as "
+"`command not found`, look at the documentation for your method of "
+"installation to determine how to install Cargo separately."
+msgstr ""
+
+#: src/ch01-03-hello-cargo.md:30
+msgid "Creating a Project with Cargo"
+msgstr ""
+
+#: src/ch01-03-hello-cargo.md:32
+msgid ""
+"Let’s create a new project using Cargo and look at how it differs from our "
+"original “Hello, world!” project. Navigate back to your _projects_ directory "
+"(or wherever you decided to store your code). Then, on any operating system, "
+"run the following:"
+msgstr ""
+
+#: src/ch01-03-hello-cargo.md:42
+msgid ""
+"The first command creates a new directory and project called _hello_cargo_. "
+"We’ve named our project _hello_cargo_, and Cargo creates its files in a "
+"directory of the same name."
+msgstr ""
+
+#: src/ch01-03-hello-cargo.md:46
+msgid ""
+"Go into the _hello_cargo_ directory and list the files. You’ll see that "
+"Cargo has generated two files and one directory for us: a _Cargo.toml_ file "
+"and a _src_ directory with a _main.rs_ file inside."
+msgstr ""
+
+#: src/ch01-03-hello-cargo.md:50
+msgid ""
+"It has also initialized a new Git repository along with a _.gitignore_ file. "
+"Git files won’t be generated if you run `cargo new` within an existing Git "
+"repository; you can override this behavior by using `cargo new --vcs=git`."
+msgstr ""
+
+#: src/ch01-03-hello-cargo.md:54
+msgid ""
+"Note: Git is a common version control system. You can change `cargo new` to "
+"use a different version control system or no version control system by using "
+"the `--vcs` flag. Run `cargo new --help` to see the available options."
+msgstr ""
+
+#: src/ch01-03-hello-cargo.md:58
+msgid ""
+"Open _Cargo.toml_ in your text editor of choice. It should look similar to "
+"the code in Listing 1-2."
+msgstr ""
+
+#: src/ch01-03-hello-cargo.md:63
+msgid ""
+"```toml\n"
+"[package]\n"
+"name = \"hello_cargo\"\n"
+"version = \"0.1.0\"\n"
+"edition = \"2021\"\n"
+"\n"
+"# See more keys and their definitions at https://doc.rust-lang.org/cargo/"
+"reference/manifest.html\n"
+"\n"
+"[dependencies]\n"
+"```"
+msgstr ""
+
+#: src/ch01-03-hello-cargo.md:76
+msgid ""
+"This file is in the [_TOML_](https://toml.io) (_Tom’s "
+"Obvious, Minimal Language_) format, which is Cargo’s configuration format."
+msgstr ""
+
+#: src/ch01-03-hello-cargo.md:79
+msgid ""
+"The first line, `[package]`, is a section heading that indicates that the "
+"following statements are configuring a package. As we add more information "
+"to this file, we’ll add other sections."
+msgstr ""
+
+#: src/ch01-03-hello-cargo.md:83
+msgid ""
+"The next three lines set the configuration information Cargo needs to "
+"compile your program: the name, the version, and the edition of Rust to use. "
+"We’ll talk about the `edition` key in [Appendix E](appendix-05-editions."
+"html)."
+msgstr ""
+
+#: src/ch01-03-hello-cargo.md:87
+msgid ""
+"The last line, `[dependencies]`, is the start of a section for you to list "
+"any of your project’s dependencies. In Rust, packages of code are referred "
+"to as _crates_. We won’t need any other crates for this project, but we will "
+"in the first project in Chapter 2, so we’ll use this dependencies section "
+"then."
+msgstr ""
+
+#: src/ch01-03-hello-cargo.md:92
+msgid "Now open _src/main.rs_ and take a look:"
+msgstr ""
+
+#: src/ch01-03-hello-cargo.md:94 src/ch02-00-guessing-game-tutorial.md:57
+#: src/ch02-00-guessing-game-tutorial.md:869
+#: src/ch02-00-guessing-game-tutorial.md:991
+#: src/ch02-00-guessing-game-tutorial.md:1086
+#: src/ch03-01-variables-and-mutability.md:18
+#: src/ch03-01-variables-and-mutability.md:79
+#: src/ch03-01-variables-and-mutability.md:164 src/ch03-02-data-types.md:153
+#: src/ch03-02-data-types.md:173 src/ch03-02-data-types.md:206
+#: src/ch03-02-data-types.md:225 src/ch03-02-data-types.md:262
+#: src/ch03-02-data-types.md:274 src/ch03-02-data-types.md:295
+#: src/ch03-02-data-types.md:327 src/ch03-02-data-types.md:382
+#: src/ch03-02-data-types.md:403 src/ch03-03-how-functions-work.md:12
+#: src/ch03-03-how-functions-work.md:66 src/ch03-03-how-functions-work.md:102
+#: src/ch03-03-how-functions-work.md:169 src/ch03-03-how-functions-work.md:221
+#: src/ch03-03-how-functions-work.md:261 src/ch03-03-how-functions-work.md:304
+#: src/ch03-03-how-functions-work.md:322 src/ch03-04-comments.md:26
+#: src/ch03-04-comments.md:37 src/ch03-05-control-flow.md:17
+#: src/ch03-05-control-flow.md:85 src/ch03-05-control-flow.md:120
+#: src/ch03-05-control-flow.md:139 src/ch03-05-control-flow.md:216
+#: src/ch03-05-control-flow.md:273 src/ch03-05-control-flow.md:531
+#: src/ch04-01-what-is-ownership.md:492 src/ch04-01-what-is-ownership.md:534
+#: src/ch04-01-what-is-ownership.md:584
+#: src/ch04-02-references-and-borrowing.md:15
+#: src/ch04-02-references-and-borrowing.md:101
+#: src/ch04-02-references-and-borrowing.md:145
+#: src/ch04-02-references-and-borrowing.md:168
+#: src/ch04-02-references-and-borrowing.md:324
+#: src/ch04-02-references-and-borrowing.md:383 src/ch04-03-slices.md:24
+#: src/ch04-03-slices.md:124 src/ch04-03-slices.md:253
+#: src/ch04-03-slices.md:296 src/ch04-03-slices.md:428
+#: src/ch05-01-defining-structs.md:16 src/ch05-01-defining-structs.md:41
+#: src/ch05-01-defining-structs.md:70 src/ch05-01-defining-structs.md:104
+#: src/ch05-01-defining-structs.md:149 src/ch05-01-defining-structs.md:196
+#: src/ch05-01-defining-structs.md:232 src/ch05-01-defining-structs.md:295
+#: src/ch05-01-defining-structs.md:326 src/ch05-01-defining-structs.md:359
+#: src/ch05-02-example-structs.md:12 src/ch05-02-example-structs.md:76
+#: src/ch05-02-example-structs.md:114 src/ch05-02-example-structs.md:169
+#: src/ch05-02-example-structs.md:238 src/ch05-03-method-syntax.md:18
+#: src/ch05-03-method-syntax.md:90 src/ch05-03-method-syntax.md:187
+#: src/ch05-03-method-syntax.md:235 src/ch05-03-method-syntax.md:298
+#: src/ch07-02-defining-modules-to-control-scope-and-privacy.md:66
+#: src/ch07-04-bringing-paths-into-scope-with-the-use-keyword.md:140
+#: src/ch07-04-bringing-paths-into-scope-with-the-use-keyword.md:345
+#: src/ch07-04-bringing-paths-into-scope-with-the-use-keyword.md:384
+#: src/ch09-01-unrecoverable-errors-with-panic.md:34
+#: src/ch09-01-unrecoverable-errors-with-panic.md:75
+#: src/ch09-02-recoverable-errors-with-result.md:32
+#: src/ch09-02-recoverable-errors-with-result.md:66
+#: src/ch09-02-recoverable-errors-with-result.md:120
+#: src/ch09-02-recoverable-errors-with-result.md:212
+#: src/ch09-02-recoverable-errors-with-result.md:241
+#: src/ch09-02-recoverable-errors-with-result.md:286
+#: src/ch09-02-recoverable-errors-with-result.md:373
+#: src/ch09-02-recoverable-errors-with-result.md:429
+#: src/ch09-02-recoverable-errors-with-result.md:462
+#: src/ch09-02-recoverable-errors-with-result.md:501
+#: src/ch09-02-recoverable-errors-with-result.md:613
+#: src/ch09-03-to-panic-or-not-to-panic.md:149 src/ch10-00-generics.md:45
+#: src/ch10-00-generics.md:80 src/ch10-00-generics.md:127
+#: src/ch10-01-syntax.md:19 src/ch10-01-syntax.md:97 src/ch10-01-syntax.md:167
+#: src/ch10-01-syntax.md:196 src/ch10-01-syntax.md:235
+#: src/ch10-01-syntax.md:308 src/ch10-01-syntax.md:351
+#: src/ch10-01-syntax.md:394 src/ch10-01-syntax.md:471
+#: src/ch10-03-lifetime-syntax.md:148 src/ch10-03-lifetime-syntax.md:173
+#: src/ch10-03-lifetime-syntax.md:276 src/ch10-03-lifetime-syntax.md:342
+#: src/ch10-03-lifetime-syntax.md:381 src/ch10-03-lifetime-syntax.md:454
+#: src/ch10-03-lifetime-syntax.md:482 src/ch10-03-lifetime-syntax.md:540
+#: src/ch12-03-improving-error-handling-and-modularity.md:749
+#: src/ch13-03-improving-our-io-project.md:149 src/ch15-01-box.md:38
+#: src/ch15-01-box.md:112 src/ch15-01-box.md:134 src/ch15-01-box.md:269
+#: src/ch15-02-deref.md:32 src/ch15-02-deref.md:84 src/ch15-02-deref.md:118
+#: src/ch15-02-deref.md:144 src/ch15-02-deref.md:195 src/ch15-02-deref.md:292
+#: src/ch15-02-deref.md:309 src/ch15-02-deref.md:355 src/ch15-03-drop.md:31
+#: src/ch15-03-drop.md:106 src/ch15-03-drop.md:172 src/ch15-04-rc.md:51
+#: src/ch15-04-rc.md:111 src/ch15-04-rc.md:157
+#: src/ch15-05-interior-mutability.md:611 src/ch15-06-reference-cycles.md:18
+#: src/ch15-06-reference-cycles.md:59 src/ch15-06-reference-cycles.md:220
+#: src/ch15-06-reference-cycles.md:255 src/ch15-06-reference-cycles.md:308
+#: src/ch15-06-reference-cycles.md:346 src/ch15-06-reference-cycles.md:427
+#: src/ch16-01-threads.md:42 src/ch16-01-threads.md:113
+#: src/ch16-01-threads.md:171 src/ch16-01-threads.md:236
+#: src/ch16-01-threads.md:296 src/ch16-01-threads.md:343
+#: src/ch16-02-message-passing.md:36 src/ch16-02-message-passing.md:73
+#: src/ch16-02-message-passing.md:106 src/ch16-02-message-passing.md:169
+#: src/ch16-02-message-passing.md:231 src/ch16-02-message-passing.md:298
+#: src/ch16-03-shared-state.md:55 src/ch16-03-shared-state.md:112
+#: src/ch16-03-shared-state.md:198 src/ch16-03-shared-state.md:301
+#: src/ch17-02-trait-objects.md:227 src/ch17-02-trait-objects.md:256
+#: src/ch17-02-trait-objects.md:327 src/ch17-03-oo-design-patterns.md:43
+#: src/ch17-03-oo-design-patterns.md:750 src/ch17-03-oo-design-patterns.md:912
+#: src/ch18-01-all-the-places-for-patterns.md:66
+#: src/ch18-01-all-the-places-for-patterns.md:290
+#: src/ch18-03-pattern-syntax.md:41 src/ch18-03-pattern-syntax.md:165
+#: src/ch18-03-pattern-syntax.md:197 src/ch18-03-pattern-syntax.md:230
+#: src/ch18-03-pattern-syntax.md:278 src/ch18-03-pattern-syntax.md:414
+#: src/ch18-03-pattern-syntax.md:512 src/ch18-03-pattern-syntax.md:606
+#: src/ch18-03-pattern-syntax.md:631 src/ch18-03-pattern-syntax.md:718
+#: src/ch19-01-unsafe-rust.md:409 src/ch19-01-unsafe-rust.md:467
+#: src/ch19-01-unsafe-rust.md:497 src/ch19-03-advanced-traits.md:129
+#: src/ch19-03-advanced-traits.md:252 src/ch19-03-advanced-traits.md:293
+#: src/ch19-03-advanced-traits.md:340 src/ch19-03-advanced-traits.md:413
+#: src/ch19-03-advanced-traits.md:466 src/ch19-03-advanced-traits.md:526
+#: src/ch19-03-advanced-traits.md:614 src/ch19-03-advanced-traits.md:647
+#: src/ch19-03-advanced-traits.md:719 src/ch19-03-advanced-traits.md:781
+#: src/ch19-05-advanced-functions-and-closures.md:25 src/ch19-06-macros.md:216
+#: src/ch20-01-single-threaded.md:37 src/ch20-01-single-threaded.md:140
+#: src/ch20-01-single-threaded.md:310 src/ch20-01-single-threaded.md:389
+#: src/ch20-01-single-threaded.md:462 src/ch20-01-single-threaded.md:530
+#: src/ch20-01-single-threaded.md:621 src/ch20-02-multithreaded.md:18
+#: src/ch20-02-multithreaded.md:152 src/ch20-02-multithreaded.md:218
+#: src/ch20-02-multithreaded.md:316
+#: src/ch20-03-graceful-shutdown-and-cleanup.md:668
+#: src/ch20-03-graceful-shutdown-and-cleanup.md:783
+#: src/appendix-01-keywords.md:89 src/appendix-01-keywords.md:111
+#: src/appendix-04-useful-development-tools.md:39
+#: src/appendix-04-useful-development-tools.md:83
+#: src/appendix-04-useful-development-tools.md:120
+#: src/appendix-04-useful-development-tools.md:149
+msgid "Filename: src/main.rs"
+msgstr ""
+
+#: src/ch01-03-hello-cargo.md:102
+msgid ""
+"Cargo has generated a “Hello, world!” program for you, just like the one we "
+"wrote in Listing 1-1! So far, the differences between our project and the "
+"project Cargo generated are that Cargo placed the code in the _src_ "
+"directory and we have a _Cargo.toml_ configuration file in the top directory."
+msgstr ""
+
+#: src/ch01-03-hello-cargo.md:107
+msgid ""
+"Cargo expects your source files to live inside the _src_ directory. The top-"
+"level project directory is just for README files, license information, "
+"configuration files, and anything else not related to your code. Using Cargo "
+"helps you organize your projects. There’s a place for everything, and "
+"everything is in its place."
+msgstr ""
+
+#: src/ch01-03-hello-cargo.md:113
+msgid ""
+"If you started a project that doesn’t use Cargo, as we did with the “Hello, "
+"world!” project, you can convert it to a project that does use Cargo. Move "
+"the project code into the _src_ directory and create an appropriate _Cargo."
+"toml_ file."
+msgstr ""
+
+#: src/ch01-03-hello-cargo.md:118
+msgid "Building and Running a Cargo Project"
+msgstr ""
+
+#: src/ch01-03-hello-cargo.md:120
+msgid ""
+"Now let’s look at what’s different when we build and run the “Hello, world!” "
+"program with Cargo! From your _hello_cargo_ directory, build your project by "
+"entering the following command:"
+msgstr ""
+
+#: src/ch01-03-hello-cargo.md:124
+msgid ""
+"```console\n"
+"$ cargo build\n"
+" Compiling hello_cargo v0.1.0 (file:///projects/hello_cargo)\n"
+" Finished dev [unoptimized + debuginfo] target(s) in 2.85 secs\n"
+"```"
+msgstr ""
+
+#: src/ch01-03-hello-cargo.md:130
+msgid ""
+"This command creates an executable file in _target/debug/hello_cargo_ (or "
+"_target\\debug\\hello_cargo.exe_ on Windows) rather than in your current "
+"directory. Because the default build is a debug build, Cargo puts the binary "
+"in a directory named _debug_. You can run the executable with this command:"
+msgstr ""
+
+#: src/ch01-03-hello-cargo.md:140
+msgid ""
+"If all goes well, `Hello, world!` should print to the terminal. Running "
+"`cargo build` for the first time also causes Cargo to create a new file at "
+"the top level: _Cargo.lock_. This file keeps track of the exact versions of "
+"dependencies in your project. This project doesn’t have dependencies, so the "
+"file is a bit sparse. You won’t ever need to change this file manually; "
+"Cargo manages its contents for you."
+msgstr ""
+
+#: src/ch01-03-hello-cargo.md:147
+msgid ""
+"We just built a project with `cargo build` and ran it with `./target/debug/"
+"hello_cargo`, but we can also use `cargo run` to compile the code and then "
+"run the resultant executable all in one command:"
+msgstr ""
+
+#: src/ch01-03-hello-cargo.md:158
+msgid ""
+"Using `cargo run` is more convenient than having to remember to run `cargo "
+"build` and then use the whole path to the binary, so most developers use "
+"`cargo run`."
+msgstr ""
+
+#: src/ch01-03-hello-cargo.md:162
+msgid ""
+"Notice that this time we didn’t see output indicating that Cargo was "
+"compiling `hello_cargo`. Cargo figured out that the files hadn’t changed, so "
+"it didn’t rebuild but just ran the binary. If you had modified your source "
+"code, Cargo would have rebuilt the project before running it, and you would "
+"have seen this output:"
+msgstr ""
+
+#: src/ch01-03-hello-cargo.md:168
+msgid ""
+"```console\n"
+"$ cargo run\n"
+" Compiling hello_cargo v0.1.0 (file:///projects/hello_cargo)\n"
+" Finished dev [unoptimized + debuginfo] target(s) in 0.33 secs\n"
+" Running `target/debug/hello_cargo`\n"
+"Hello, world!\n"
+"```"
+msgstr ""
+
+#: src/ch01-03-hello-cargo.md:176
+msgid ""
+"Cargo also provides a command called `cargo check`. This command quickly "
+"checks your code to make sure it compiles but doesn’t produce an executable:"
+msgstr ""
+
+#: src/ch01-03-hello-cargo.md:179
+msgid ""
+"```console\n"
+"$ cargo check\n"
+" Checking hello_cargo v0.1.0 (file:///projects/hello_cargo)\n"
+" Finished dev [unoptimized + debuginfo] target(s) in 0.32 secs\n"
+"```"
+msgstr ""
+
+#: src/ch01-03-hello-cargo.md:185
+msgid ""
+"Why would you not want an executable? Often, `cargo check` is much faster "
+"than `cargo build` because it skips the step of producing an executable. If "
+"you’re continually checking your work while writing the code, using `cargo "
+"check` will speed up the process of letting you know if your project is "
+"still compiling! As such, many Rustaceans run `cargo check` periodically as "
+"they write their program to make sure it compiles. Then they run `cargo "
+"build` when they’re ready to use the executable."
+msgstr ""
+
+#: src/ch01-03-hello-cargo.md:193
+msgid "Let’s recap what we’ve learned so far about Cargo:"
+msgstr ""
+
+#: src/ch01-03-hello-cargo.md:195
+msgid "We can create a project using `cargo new`."
+msgstr ""
+
+#: src/ch01-03-hello-cargo.md:196
+msgid "We can build a project using `cargo build`."
+msgstr ""
+
+#: src/ch01-03-hello-cargo.md:197
+msgid "We can build and run a project in one step using `cargo run`."
+msgstr ""
+
+#: src/ch01-03-hello-cargo.md:198
+msgid ""
+"We can build a project without producing a binary to check for errors using "
+"`cargo check`."
+msgstr ""
+
+#: src/ch01-03-hello-cargo.md:200
+msgid ""
+"Instead of saving the result of the build in the same directory as our code, "
+"Cargo stores it in the _target/debug_ directory."
+msgstr ""
+
+#: src/ch01-03-hello-cargo.md:203
+msgid ""
+"An additional advantage of using Cargo is that the commands are the same no "
+"matter which operating system you’re working on. So, at this point, we’ll no "
+"longer provide specific instructions for Linux and macOS versus Windows."
+msgstr ""
+
+#: src/ch01-03-hello-cargo.md:207
+msgid "Building for Release"
+msgstr ""
+
+#: src/ch01-03-hello-cargo.md:209
+msgid ""
+"When your project is finally ready for release, you can use `cargo build --"
+"release` to compile it with optimizations. This command will create an "
+"executable in _target/release_ instead of _target/debug_. The optimizations "
+"make your Rust code run faster, but turning them on lengthens the time it "
+"takes for your program to compile. This is why there are two different "
+"profiles: one for development, when you want to rebuild quickly and often, "
+"and another for building the final program you’ll give to a user that won’t "
+"be rebuilt repeatedly and that will run as fast as possible. If you’re "
+"benchmarking your code’s running time, be sure to run `cargo build --"
+"release` and benchmark with the executable in _target/release_."
+msgstr ""
+
+#: src/ch01-03-hello-cargo.md:220
+msgid "Cargo as Convention"
+msgstr ""
+
+#: src/ch01-03-hello-cargo.md:222
+msgid ""
+"With simple projects, Cargo doesn’t provide a lot of value over just using "
+"`rustc`, but it will prove its worth as your programs become more intricate. "
+"Once programs grow to multiple files or need a dependency, it’s much easier "
+"to let Cargo coordinate the build."
+msgstr ""
+
+#: src/ch01-03-hello-cargo.md:227
+msgid ""
+"Even though the `hello_cargo` project is simple, it now uses much of the "
+"real tooling you’ll use in the rest of your Rust career. In fact, to work on "
+"any existing projects, you can use the following commands to check out the "
+"code using Git, change to that project’s directory, and build:"
+msgstr ""
+
+#: src/ch01-03-hello-cargo.md:238
+msgid ""
+"For more information about Cargo, check out [its documentation](https://doc."
+"rust-lang.org/cargo/)."
+msgstr ""
+
+#: src/ch01-03-hello-cargo.md:240 src/ch02-00-guessing-game-tutorial.md:1291
+#: src/ch03-05-control-flow.md:544 src/ch04-03-slices.md:490
+#: src/ch05-03-method-syntax.md:382 src/ch06-03-if-let.md:121
+#: src/ch07-05-separating-modules-into-different-files.md:123
+#: src/ch08-03-hash-maps.md:285 src/ch09-03-to-panic-or-not-to-panic.md:269
+#: src/ch10-03-lifetime-syntax.md:879 src/ch11-03-test-organization.md:354
+#: src/ch12-06-writing-to-stderr-instead-of-stdout.md:113
+#: src/ch13-04-performance.md:84 src/ch14-05-extending-cargo.md:10
+#: src/ch15-06-reference-cycles.md:513
+#: src/ch16-04-extensible-concurrency-sync-and-send.md:63
+#: src/ch17-03-oo-design-patterns.md:955 src/ch18-03-pattern-syntax.md:847
+#: src/ch19-06-macros.md:568 src/ch20-03-graceful-shutdown-and-cleanup.md:941
+msgid "Summary"
+msgstr ""
+
+#: src/ch01-03-hello-cargo.md:242
+msgid ""
+"You’re already off to a great start on your Rust journey! In this chapter, "
+"you’ve learned how to:"
+msgstr ""
+
+#: src/ch01-03-hello-cargo.md:245
+msgid "Install the latest stable version of Rust using `rustup`"
+msgstr ""
+
+#: src/ch01-03-hello-cargo.md:246
+msgid "Update to a newer Rust version"
+msgstr ""
+
+#: src/ch01-03-hello-cargo.md:247
+msgid "Open locally installed documentation"
+msgstr ""
+
+#: src/ch01-03-hello-cargo.md:248
+msgid "Write and run a “Hello, world!” program using `rustc` directly"
+msgstr ""
+
+#: src/ch01-03-hello-cargo.md:249
+msgid "Create and run a new project using the conventions of Cargo"
+msgstr ""
+
+#: src/ch01-03-hello-cargo.md:251
+msgid ""
+"This is a great time to build a more substantial program to get used to "
+"reading and writing Rust code. So, in Chapter 2, we’ll build a guessing game "
+"program. If you would rather start by learning how common programming "
+"concepts work in Rust, see Chapter 3 and then return to Chapter 2."
+msgstr ""
+
+#: src/ch02-00-guessing-game-tutorial.md:3
+msgid ""
+"Let’s jump into Rust by working through a hands-on project together! This "
+"chapter introduces you to a few common Rust concepts by showing you how to "
+"use them in a real program. You’ll learn about `let`, `match`, methods, "
+"associated functions, external crates, and more! In the following chapters, "
+"we’ll explore these ideas in more detail. In this chapter, you’ll just "
+"practice the fundamentals."
+msgstr ""
+
+#: src/ch02-00-guessing-game-tutorial.md:10
+msgid ""
+"We’ll implement a classic beginner programming problem: a guessing game. "
+"Here’s how it works: the program will generate a random integer between 1 "
+"and 100. It will then prompt the player to enter a guess. After a guess is "
+"entered, the program will indicate whether the guess is too low or too high. "
+"If the guess is correct, the game will print a congratulatory message and "
+"exit."
+msgstr ""
+
+#: src/ch02-00-guessing-game-tutorial.md:16
+msgid "Setting Up a New Project"
+msgstr ""
+
+#: src/ch02-00-guessing-game-tutorial.md:18
+msgid ""
+"To set up a new project, go to the _projects_ directory that you created in "
+"Chapter 1 and make a new project using Cargo, like so:"
+msgstr ""
+
+#: src/ch02-00-guessing-game-tutorial.md:26
+msgid ""
+"The first command, `cargo new`, takes the name of the project "
+"(`guessing_game`) as the first argument. The second command changes to the "
+"new project’s directory."
+msgstr ""
+
+#: src/ch02-00-guessing-game-tutorial.md:30
+msgid "Look at the generated _Cargo.toml_ file:"
+msgstr ""
+
+#: src/ch02-00-guessing-game-tutorial.md:41
+#: src/ch02-00-guessing-game-tutorial.md:489
+#: src/ch07-04-bringing-paths-into-scope-with-the-use-keyword.md:281
+#: src/ch14-01-release-profiles.md:37 src/ch14-01-release-profiles.md:62
+#: src/ch14-02-publishing-to-crates-io.md:406
+#: src/ch14-02-publishing-to-crates-io.md:443
+#: src/ch14-02-publishing-to-crates-io.md:465
+#: src/ch14-03-cargo-workspaces.md:32 src/ch14-03-cargo-workspaces.md:87
+msgid "Filename: Cargo.toml"
+msgstr ""
+
+#: src/ch02-00-guessing-game-tutorial.md:43
+msgid ""
+"```toml\n"
+"[package]\n"
+"name = \"guessing_game\"\n"
+"version = \"0.1.0\"\n"
+"edition = \"2021\"\n"
+"\n"
+"# See more keys and their definitions at https://doc.rust-lang.org/cargo/"
+"reference/manifest.html\n"
+"\n"
+"[dependencies]\n"
+"```"
+msgstr ""
+
+#: src/ch02-00-guessing-game-tutorial.md:54
+msgid ""
+"As you saw in Chapter 1, `cargo new` generates a “Hello, world!” program for "
+"you. Check out the _src/main.rs_ file:"
+msgstr ""
+
+#: src/ch02-00-guessing-game-tutorial.md:65
+msgid ""
+"Now let’s compile this “Hello, world!” program and run it in the same step "
+"using the `cargo run` command:"
+msgstr ""
+
+#: src/ch02-00-guessing-game-tutorial.md:68
+msgid ""
+"```console\n"
+"$ cargo run\n"
+" Compiling guessing_game v0.1.0 (file:///projects/guessing_game)\n"
+" Finished `dev` profile [unoptimized + debuginfo] target(s) in 1.50s\n"
+" Running `target/debug/guessing_game`\n"
+"Hello, world!\n"
+"```"
+msgstr ""
+
+#: src/ch02-00-guessing-game-tutorial.md:76
+msgid ""
+"The `run` command comes in handy when you need to rapidly iterate on a "
+"project, as we’ll do in this game, quickly testing each iteration before "
+"moving on to the next one."
+msgstr ""
+
+#: src/ch02-00-guessing-game-tutorial.md:80
+msgid ""
+"Reopen the _src/main.rs_ file. You’ll be writing all the code in this file."
+msgstr ""
+
+#: src/ch02-00-guessing-game-tutorial.md:82
+msgid "Processing a Guess"
+msgstr ""
+
+#: src/ch02-00-guessing-game-tutorial.md:84
+msgid ""
+"The first part of the guessing game program will ask for user input, process "
+"that input, and check that the input is in the expected form. To start, "
+"we’ll allow the player to input a guess. Enter the code in Listing 2-1 into "
+"_src/main.rs_."
+msgstr ""
+
+#: src/ch02-00-guessing-game-tutorial.md:95
+#: src/ch02-00-guessing-game-tutorial.md:120
+#: src/ch02-00-guessing-game-tutorial.md:150
+#: src/ch02-00-guessing-game-tutorial.md:174
+#: src/ch02-00-guessing-game-tutorial.md:199
+#: src/ch02-00-guessing-game-tutorial.md:264
+#: src/ch02-00-guessing-game-tutorial.md:316
+#: src/ch02-00-guessing-game-tutorial.md:404
+#: src/ch02-00-guessing-game-tutorial.md:660
+#: src/ch02-00-guessing-game-tutorial.md:757
+#: src/ch02-00-guessing-game-tutorial.md:877
+#: src/ch02-00-guessing-game-tutorial.md:999
+#: src/ch02-00-guessing-game-tutorial.md:1094
+#: src/ch02-00-guessing-game-tutorial.md:1146
+#: src/ch02-00-guessing-game-tutorial.md:1255
+#: src/ch07-04-bringing-paths-into-scope-with-the-use-keyword.md:302
+#: src/ch07-04-bringing-paths-into-scope-with-the-use-keyword.md:355
+#: src/ch07-04-bringing-paths-into-scope-with-the-use-keyword.md:393
+#: src/ch09-03-to-panic-or-not-to-panic.md:157
+#: src/ch19-04-advanced-types.md:226
+msgid "\"Guess the number!\""
+msgstr ""
+
+#: src/ch02-00-guessing-game-tutorial.md:97
+#: src/ch02-00-guessing-game-tutorial.md:122
+#: src/ch02-00-guessing-game-tutorial.md:152
+#: src/ch02-00-guessing-game-tutorial.md:176
+#: src/ch02-00-guessing-game-tutorial.md:201
+#: src/ch02-00-guessing-game-tutorial.md:266
+#: src/ch02-00-guessing-game-tutorial.md:318
+#: src/ch02-00-guessing-game-tutorial.md:406
+#: src/ch02-00-guessing-game-tutorial.md:666
+#: src/ch02-00-guessing-game-tutorial.md:763
+#: src/ch02-00-guessing-game-tutorial.md:883
+#: src/ch02-00-guessing-game-tutorial.md:1008
+#: src/ch02-00-guessing-game-tutorial.md:1101
+#: src/ch02-00-guessing-game-tutorial.md:1153
+#: src/ch02-00-guessing-game-tutorial.md:1260
+#: src/ch07-04-bringing-paths-into-scope-with-the-use-keyword.md:308
+#: src/ch07-04-bringing-paths-into-scope-with-the-use-keyword.md:361
+#: src/ch07-04-bringing-paths-into-scope-with-the-use-keyword.md:399
+#: src/ch09-03-to-panic-or-not-to-panic.md:164
+#: src/ch19-04-advanced-types.md:233
+msgid "\"Please input your guess.\""
+msgstr ""
+
+#: src/ch02-00-guessing-game-tutorial.md:103
+#: src/ch02-00-guessing-game-tutorial.md:128
+#: src/ch02-00-guessing-game-tutorial.md:158
+#: src/ch02-00-guessing-game-tutorial.md:182
+#: src/ch02-00-guessing-game-tutorial.md:207
+#: src/ch02-00-guessing-game-tutorial.md:272
+#: src/ch02-00-guessing-game-tutorial.md:324
+#: src/ch02-00-guessing-game-tutorial.md:333
+#: src/ch02-00-guessing-game-tutorial.md:412
+#: src/ch02-00-guessing-game-tutorial.md:672
+#: src/ch02-00-guessing-game-tutorial.md:769
+#: src/ch02-00-guessing-game-tutorial.md:891
+#: src/ch02-00-guessing-game-tutorial.md:1017
+#: src/ch02-00-guessing-game-tutorial.md:1107
+#: src/ch02-00-guessing-game-tutorial.md:1161
+#: src/ch02-00-guessing-game-tutorial.md:1266 src/ch03-02-data-types.md:417
+#: src/ch07-04-bringing-paths-into-scope-with-the-use-keyword.md:314
+#: src/ch07-04-bringing-paths-into-scope-with-the-use-keyword.md:367
+#: src/ch07-04-bringing-paths-into-scope-with-the-use-keyword.md:405
+#: src/ch09-03-to-panic-or-not-to-panic.md:170
+#: src/ch19-04-advanced-types.md:241
+msgid "\"Failed to read line\""
+msgstr ""
+
+#: src/ch02-00-guessing-game-tutorial.md:105
+#: src/ch02-00-guessing-game-tutorial.md:130
+#: src/ch02-00-guessing-game-tutorial.md:160
+#: src/ch02-00-guessing-game-tutorial.md:184
+#: src/ch02-00-guessing-game-tutorial.md:209
+#: src/ch02-00-guessing-game-tutorial.md:274
+#: src/ch02-00-guessing-game-tutorial.md:326
+#: src/ch02-00-guessing-game-tutorial.md:414
+msgid "\"You guessed: {}\""
+msgstr ""
+
+#: src/ch02-00-guessing-game-tutorial.md:111
+msgid ""
+"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 `io` input/output library into scope. The `io` library comes from the "
+"standard library, known as `std`:"
+msgstr ""
+
+#: src/ch02-00-guessing-game-tutorial.md:134
+msgid ""
+"By default, Rust has a set of items defined in the standard library that it "
+"brings into the scope of every program. This set is called the _prelude_, "
+"and you can see everything in it [in the standard library documentation](../"
+"std/prelude/index.html)."
+msgstr ""
+
+#: src/ch02-00-guessing-game-tutorial.md:138
+msgid ""
+"If a type you want to use isn’t in the prelude, you have to bring that type "
+"into scope explicitly with a `use` statement. Using the `std::io` library "
+"provides you with a number of useful features, including the ability to "
+"accept user input."
+msgstr ""
+
+#: src/ch02-00-guessing-game-tutorial.md:143
+msgid ""
+"As you saw in Chapter 1, the `main` function is the entry point into the "
+"program:"
+msgstr ""
+
+#: src/ch02-00-guessing-game-tutorial.md:164
+msgid ""
+"The `fn` syntax declares a new function; the parentheses, `()`, indicate "
+"there are no parameters; and the curly bracket, `{`, starts the body of the "
+"function."
+msgstr ""
+
+#: src/ch02-00-guessing-game-tutorial.md:167
+msgid ""
+"As you also learned in Chapter 1, `println!` is a macro that prints a string "
+"to the screen:"
+msgstr ""
+
+#: src/ch02-00-guessing-game-tutorial.md:188
+msgid ""
+"This code is printing a prompt stating what the game is and requesting input "
+"from the user."
+msgstr ""
+
+#: src/ch02-00-guessing-game-tutorial.md:191
+msgid "Storing Values with Variables"
+msgstr ""
+
+#: src/ch02-00-guessing-game-tutorial.md:193
+msgid "Next, we’ll create a _variable_ to store the user input, like this:"
+msgstr ""
+
+#: src/ch02-00-guessing-game-tutorial.md:213
+msgid ""
+"Now the program is getting interesting! There’s a lot going on in this "
+"little line. We use the `let` statement to create the variable. Here’s "
+"another example:"
+msgstr ""
+
+#: src/ch02-00-guessing-game-tutorial.md:220
+msgid ""
+"This line creates a new variable named `apples` and binds it to the value 5. "
+"In Rust, variables are immutable by default, meaning once we give the "
+"variable a value, the value won’t change. We’ll be discussing this concept "
+"in detail in the [“Variables and Mutability”](ch03-01-variables-and-"
+"mutability.html#variables-and-mutability) section in Chapter "
+"3. To make a variable mutable, we add `mut` before the variable name:"
+msgstr ""
+
+#: src/ch02-00-guessing-game-tutorial.md:228
+msgid "// immutable\n"
+msgstr ""
+
+#: src/ch02-00-guessing-game-tutorial.md:229
+msgid "// mutable\n"
+msgstr ""
+
+#: src/ch02-00-guessing-game-tutorial.md:232
+msgid ""
+"Note: The `//` syntax starts a comment that continues until the end of the "
+"line. Rust ignores everything in comments. We’ll discuss comments in more "
+"detail in [Chapter 3](ch03-04-comments.html)."
+msgstr ""
+
+#: src/ch02-00-guessing-game-tutorial.md:236
+msgid ""
+"Returning to the guessing game program, you now know that `let mut guess` "
+"will introduce a mutable variable named `guess`. The equal sign (`=`) tells "
+"Rust we want to bind something to the variable now. On the right of the "
+"equal sign is the value that `guess` is bound to, which is the result of "
+"calling `String::new`, a function that returns a new instance of a `String`. "
+"[`String`](../std/string/struct.String.html) is a string type "
+"provided by the standard library that is a growable, UTF-8 encoded bit of "
+"text."
+msgstr ""
+
+#: src/ch02-00-guessing-game-tutorial.md:244
+msgid ""
+"The `::` syntax in the `::new` line indicates that `new` is an associated "
+"function of the `String` type. An _associated function_ is a function that’s "
+"implemented on a type, in this case `String`. This `new` function creates a "
+"new, empty string. You’ll find a `new` function on many types because it’s a "
+"common name for a function that makes a new value of some kind."
+msgstr ""
+
+#: src/ch02-00-guessing-game-tutorial.md:250
+msgid ""
+"In full, the `let mut guess = String::new();` line has created a mutable "
+"variable that is currently bound to a new, empty instance of a `String`. "
+"Whew!"
+msgstr ""
+
+#: src/ch02-00-guessing-game-tutorial.md:253
+msgid "Receiving User Input"
+msgstr ""
+
+#: src/ch02-00-guessing-game-tutorial.md:255
+msgid ""
+"Recall that we included the input/output functionality from the standard "
+"library with `use std::io;` on the first line of the program. Now we’ll call "
+"the `stdin` function from the `io` module, which will allow us to handle "
+"user input:"
+msgstr ""
+
+#: src/ch02-00-guessing-game-tutorial.md:278
+msgid ""
+"If we hadn’t imported the `io` library with `use std::io;` at the beginning "
+"of the program, we could still use the function by writing this function "
+"call as `std::io::stdin`. The `stdin` function returns an instance of [`std::"
+"io::Stdin`](../std/io/struct.Stdin.html), which is a type "
+"that represents a handle to the standard input for your terminal."
+msgstr ""
+
+#: src/ch02-00-guessing-game-tutorial.md:284
+msgid ""
+"Next, the line `.read_line(&mut guess)` calls the [`read_line`](../std/io/"
+"struct.Stdin.html#method.read_line) method on the standard input handle to get input from the user. "
+"We’re also passing `&mut guess` as the argument to `read_line` to tell it "
+"what string to store the user input in. The full job of `read_line` is to "
+"take whatever the user types into standard input and append that into a "
+"string (without overwriting its contents), so we therefore pass that string "
+"as an argument. The string argument needs to be mutable so the method can "
+"change the string’s content."
+msgstr ""
+
+#: src/ch02-00-guessing-game-tutorial.md:293
+msgid ""
+"The `&` indicates that this argument is a _reference_, which gives you a way "
+"to let multiple parts of your code access one piece of data without needing "
+"to copy that data into memory multiple times. References are a complex "
+"feature, and one of Rust’s major advantages is how safe and easy it is to "
+"use references. You don’t need to know a lot of those details to finish this "
+"program. For now, all you need to know is that, like variables, references "
+"are immutable by default. Hence, you need to write `&mut guess` rather than "
+"`&guess` to make it mutable. (Chapter 4 will explain references more "
+"thoroughly.)"
+msgstr ""
+
+#: src/ch02-00-guessing-game-tutorial.md:304
+msgid ""
+msgstr ""
+
+#: src/ch02-00-guessing-game-tutorial.md:306
+msgid "Handling Potential Failure with `Result`"
+msgstr ""
+
+#: src/ch02-00-guessing-game-tutorial.md:308
+msgid ""
+"We’re still working on this line of code. We’re now discussing a third line "
+"of text, but note that it’s still part of a single logical line of code. The "
+"next part is this method:"
+msgstr ""
+
+#: src/ch02-00-guessing-game-tutorial.md:330
+msgid "We could have written this code as:"
+msgstr ""
+
+#: src/ch02-00-guessing-game-tutorial.md:336
+msgid ""
+"However, one long line is difficult to read, so it’s best to divide it. It’s "
+"often wise to introduce a newline and other whitespace to help break up long "
+"lines when you call a method with the `.method_name()` syntax. Now let’s "
+"discuss what this line does."
+msgstr ""
+
+#: src/ch02-00-guessing-game-tutorial.md:341
+msgid ""
+"As mentioned earlier, `read_line` puts whatever the user enters into the "
+"string we pass to it, but it also returns a `Result` value. [`Result`](../"
+"std/result/enum.Result.html) is an [_enumeration_](ch06-00-enums.html), often "
+"called an _enum_, which is a type that can be in one of multiple possible "
+"states. We call each possible state a _variant_."
+msgstr ""
+
+#: src/ch02-00-guessing-game-tutorial.md:347
+msgid ""
+"[Chapter 6](ch06-00-enums.html) will cover enums in more "
+"detail. The purpose of these `Result` types is to encode error-handling "
+"information."
+msgstr ""
+
+#: src/ch02-00-guessing-game-tutorial.md:350
+msgid ""
+"`Result`’s variants are `Ok` and `Err`. The `Ok` variant indicates the "
+"operation was successful, and inside `Ok` is the successfully generated "
+"value. The `Err` variant means the operation failed, and `Err` contains "
+"information about how or why the operation failed."
+msgstr ""
+
+#: src/ch02-00-guessing-game-tutorial.md:355
+msgid ""
+"Values of the `Result` type, like values of any type, have methods defined "
+"on them. An instance of `Result` has an [`expect` method](../std/result/enum."
+"Result.html#method.expect) that you can call. If this "
+"instance of `Result` is an `Err` value, `expect` will cause the program to "
+"crash and display the message that you passed as an argument to `expect`. If "
+"the `read_line` method returns an `Err`, it would likely be the result of an "
+"error coming from the underlying operating system. If this instance of "
+"`Result` is an `Ok` value, `expect` will take the return value that `Ok` is "
+"holding and return just that value to you so you can use it. In this case, "
+"that value is the number of bytes in the user’s input."
+msgstr ""
+
+#: src/ch02-00-guessing-game-tutorial.md:365
+msgid ""
+"If you don’t call `expect`, the program will compile, but you’ll get a "
+"warning:"
+msgstr ""
+
+#: src/ch02-00-guessing-game-tutorial.md:367
+msgid ""
+"```console\n"
+"$ cargo build\n"
+" Compiling guessing_game v0.1.0 (file:///projects/guessing_game)\n"
+"warning: unused `Result` that must be used\n"
+" --> src/main.rs:10:5\n"
+" |\n"
+"10 | io::stdin().read_line(&mut guess);\n"
+" | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n"
+" |\n"
+" = note: this `Result` may be an `Err` variant, which should be handled\n"
+" = note: `#[warn(unused_must_use)]` on by default\n"
+"help: use `let _ = ...` to ignore the resulting value\n"
+" |\n"
+"10 | let _ = io::stdin().read_line(&mut guess);\n"
+" | +++++++\n"
+"\n"
+"warning: `guessing_game` (bin \"guessing_game\") generated 1 warning\n"
+" Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.59s\n"
+"```"
+msgstr ""
+
+#: src/ch02-00-guessing-game-tutorial.md:387
+msgid ""
+"Rust warns that you haven’t used the `Result` value returned from "
+"`read_line`, indicating that the program hasn’t handled a possible error."
+msgstr ""
+
+#: src/ch02-00-guessing-game-tutorial.md:390
+msgid ""
+"The right way to suppress the warning is to actually write error-handling "
+"code, but in our case we just want to crash this program when a problem "
+"occurs, so we can use `expect`. You’ll learn about recovering from errors in "
+"[Chapter 9](ch09-02-recoverable-errors-with-result.html)."
+msgstr ""
+
+#: src/ch02-00-guessing-game-tutorial.md:395
+msgid "Printing Values with `println!` Placeholders"
+msgstr ""
+
+#: src/ch02-00-guessing-game-tutorial.md:397
+msgid ""
+"Aside from the closing curly bracket, there’s only one more line to discuss "
+"in the code so far:"
+msgstr ""
+
+#: src/ch02-00-guessing-game-tutorial.md:418
+msgid ""
+"This line prints the string that now contains the user’s input. The `{}` set "
+"of curly brackets is a placeholder: think of `{}` as little crab pincers "
+"that hold a value in place. When printing the value of a variable, the "
+"variable name can go inside the curly brackets. When printing the result of "
+"evaluating an expression, place empty curly brackets in the format string, "
+"then follow the 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 `println!` would "
+"look like this:"
+msgstr ""
+
+#: src/ch02-00-guessing-game-tutorial.md:431
+msgid "\"x = {x} and y + 2 = {}\""
+msgstr ""
+
+#: src/ch02-00-guessing-game-tutorial.md:434
+msgid "This code would print `x = 5 and y + 2 = 12`."
+msgstr ""
+
+#: src/ch02-00-guessing-game-tutorial.md:436
+msgid "Testing the First Part"
+msgstr ""
+
+#: src/ch02-00-guessing-game-tutorial.md:438
+msgid ""
+"Let’s test the first part of the guessing game. Run it using `cargo run`:"
+msgstr ""
+
+#: src/ch02-00-guessing-game-tutorial.md:446
+msgid ""
+"```console\n"
+"$ cargo run\n"
+" Compiling guessing_game v0.1.0 (file:///projects/guessing_game)\n"
+" Finished dev [unoptimized + debuginfo] target(s) in 6.44s\n"
+" Running `target/debug/guessing_game`\n"
+"Guess the number!\n"
+"Please input your guess.\n"
+"6\n"
+"You guessed: 6\n"
+"```"
+msgstr ""
+
+#: src/ch02-00-guessing-game-tutorial.md:457
+msgid ""
+"At this point, the first part of the game is done: we’re getting input from "
+"the keyboard and then printing it."
+msgstr ""
+
+#: src/ch02-00-guessing-game-tutorial.md:460
+msgid "Generating a Secret Number"
+msgstr ""
+
+#: src/ch02-00-guessing-game-tutorial.md:462
+msgid ""
+"Next, we need to generate a secret number that the user will try to guess. "
+"The secret number should be different every time so the game is fun to play "
+"more than once. We’ll use a random number between 1 and 100 so the game "
+"isn’t too difficult. Rust doesn’t yet include random number functionality in "
+"its standard library. However, the Rust team does provide a [`rand` crate]"
+"(https://crates.io/crates/rand) with said functionality."
+msgstr ""
+
+#: src/ch02-00-guessing-game-tutorial.md:469
+msgid "Using a Crate to Get More Functionality"
+msgstr ""
+
+#: src/ch02-00-guessing-game-tutorial.md:471
+msgid ""
+"Remember that a crate is a collection of Rust source code files. The project "
+"we’ve been building is a _binary crate_, which is an executable. The `rand` "
+"crate is a _library crate_, which contains code that is intended to be used "
+"in other programs and can’t be executed on its own."
+msgstr ""
+
+#: src/ch02-00-guessing-game-tutorial.md:476
+msgid ""
+"Cargo’s coordination of external crates is where Cargo really shines. Before "
+"we can write code that uses `rand`, we need to modify the _Cargo.toml_ file "
+"to include the `rand` crate as a dependency. Open that file now and add the "
+"following line to the bottom, beneath the `[dependencies]` section header "
+"that Cargo created for you. Be sure to specify `rand` exactly as we have "
+"here, with this version number, or the code examples in this tutorial may "
+"not work:"
+msgstr ""
+
+#: src/ch02-00-guessing-game-tutorial.md:491
+#: src/ch14-03-cargo-workspaces.md:225
+msgid ""
+"```toml\n"
+"[dependencies]\n"
+"rand = \"0.8.5\"\n"
+"```"
+msgstr ""
+
+#: src/ch02-00-guessing-game-tutorial.md:496
+msgid ""
+"In the _Cargo.toml_ file, everything that follows a header is part of that "
+"section that continues until another section starts. In `[dependencies]` you "
+"tell Cargo which external crates your project depends on and which versions "
+"of those crates you require. In this case, we specify the `rand` crate with "
+"the semantic version specifier `0.8.5`. Cargo understands [Semantic "
+"Versioning](http://semver.org) (sometimes called _SemVer_), "
+"which is a standard for writing version numbers. The specifier `0.8.5` is "
+"actually shorthand for `^0.8.5`, which means any version that is at least "
+"0.8.5 but below 0.9.0."
+msgstr ""
+
+#: src/ch02-00-guessing-game-tutorial.md:506
+msgid ""
+"Cargo considers these versions to have public APIs compatible with version "
+"0.8.5, and this specification ensures you’ll get the latest patch release "
+"that will still compile with the code in this chapter. Any version 0.9.0 or "
+"greater is not guaranteed to have the same API as what the following "
+"examples use."
+msgstr ""
+
+#: src/ch02-00-guessing-game-tutorial.md:511
+msgid ""
+"Now, without changing any of the code, let’s build the project, as shown in "
+"Listing 2-2."
+msgstr ""
+
+#: src/ch02-00-guessing-game-tutorial.md:522
+msgid ""
+"```console\n"
+"$ cargo build\n"
+" Updating crates.io index\n"
+" Downloaded rand v0.8.5\n"
+" Downloaded libc v0.2.127\n"
+" Downloaded getrandom v0.2.7\n"
+" Downloaded cfg-if v1.0.0\n"
+" Downloaded ppv-lite86 v0.2.16\n"
+" Downloaded rand_chacha v0.3.1\n"
+" Downloaded rand_core v0.6.3\n"
+" Compiling libc v0.2.127\n"
+" Compiling getrandom v0.2.7\n"
+" Compiling cfg-if v1.0.0\n"
+" Compiling ppv-lite86 v0.2.16\n"
+" Compiling rand_core v0.6.3\n"
+" Compiling rand_chacha v0.3.1\n"
+" Compiling rand v0.8.5\n"
+" Compiling guessing_game v0.1.0 (file:///projects/guessing_game)\n"
+" Finished dev [unoptimized + debuginfo] target(s) in 2.53s\n"
+"```"
+msgstr ""
+
+#: src/ch02-00-guessing-game-tutorial.md:545
+msgid ""
+"You may see different version numbers (but they will all be compatible with "
+"the code, thanks to SemVer!) and different lines (depending on the operating "
+"system), and the lines may be in a different order."
+msgstr ""
+
+#: src/ch02-00-guessing-game-tutorial.md:549
+msgid ""
+"When we include an external dependency, Cargo fetches the latest versions of "
+"everything that dependency needs from the _registry_, which is a copy of "
+"data from [Crates.io](https://crates.io/). Crates.io is where people in the "
+"Rust ecosystem post their open source Rust projects for others to use."
+msgstr ""
+
+#: src/ch02-00-guessing-game-tutorial.md:554
+msgid ""
+"After updating the registry, Cargo checks the `[dependencies]` section and "
+"downloads any crates listed that aren’t already downloaded. In this case, "
+"although we only listed `rand` as a dependency, Cargo also grabbed other "
+"crates that `rand` depends on to work. After downloading the crates, Rust "
+"compiles them and then compiles the project with the dependencies available."
+msgstr ""
+
+#: src/ch02-00-guessing-game-tutorial.md:560
+msgid ""
+"If you immediately run `cargo build` again without making any changes, you "
+"won’t get any output aside from the `Finished` line. Cargo knows it has "
+"already downloaded and compiled the dependencies, and you haven’t changed "
+"anything about them in your _Cargo.toml_ file. Cargo also knows that you "
+"haven’t changed anything about your code, so it doesn’t recompile that "
+"either. With nothing to do, it simply exits."
+msgstr ""
+
+#: src/ch02-00-guessing-game-tutorial.md:567
+msgid ""
+"If you open the _src/main.rs_ file, make a trivial change, and then save it "
+"and build again, you’ll only see two lines of output:"
+msgstr ""
+
+#: src/ch02-00-guessing-game-tutorial.md:575
+msgid ""
+"```console\n"
+"$ cargo build\n"
+" Compiling guessing_game v0.1.0 (file:///projects/guessing_game)\n"
+" Finished dev [unoptimized + debuginfo] target(s) in 2.53 secs\n"
+"```"
+msgstr ""
+
+#: src/ch02-00-guessing-game-tutorial.md:581
+msgid ""
+"These lines show that Cargo only updates the build with your tiny change to "
+"the _src/main.rs_ file. Your dependencies haven’t changed, so Cargo knows it "
+"can reuse what it has already downloaded and compiled for those."
+msgstr ""
+
+#: src/ch02-00-guessing-game-tutorial.md:585
+msgid "Ensuring Reproducible Builds with the _Cargo.lock_ File"
+msgstr ""
+
+#: src/ch02-00-guessing-game-tutorial.md:587
+msgid ""
+"Cargo has a mechanism that ensures you can rebuild the same artifact every "
+"time you or anyone else builds your code: Cargo will use only the versions "
+"of the dependencies you specified until you indicate otherwise. For example, "
+"say that next week version 0.8.6 of the `rand` crate comes out, and that "
+"version contains an important bug fix, but it also contains a regression "
+"that will break your code. To handle this, Rust creates the _Cargo.lock_ "
+"file the first time you run `cargo build`, so we now have this in the "
+"_guessing_game_ directory."
+msgstr ""
+
+#: src/ch02-00-guessing-game-tutorial.md:596
+msgid ""
+"When you build a project for the first time, Cargo figures out all the "
+"versions of the dependencies that fit the criteria and then writes them to "
+"the _Cargo.lock_ file. When you build your project in the future, Cargo will "
+"see that the _Cargo.lock_ file exists and will use the versions specified "
+"there rather than doing all the work of figuring out versions again. This "
+"lets you have a reproducible build automatically. In other words, your "
+"project will remain at 0.8.5 until you explicitly upgrade, thanks to the "
+"_Cargo.lock_ file. Because the _Cargo.lock_ file is important for "
+"reproducible builds, it’s often checked into source control with the rest of "
+"the code in your project."
+msgstr ""
+
+#: src/ch02-00-guessing-game-tutorial.md:606
+msgid "Updating a Crate to Get a New Version"
+msgstr ""
+
+#: src/ch02-00-guessing-game-tutorial.md:608
+msgid ""
+"When you _do_ want to update a crate, Cargo provides the command `update`, "
+"which will ignore the _Cargo.lock_ file and figure out all the latest "
+"versions that fit your specifications in _Cargo.toml_. Cargo will then write "
+"those versions to the _Cargo.lock_ file. In this case, Cargo will only look "
+"for versions greater than 0.8.5 and less than 0.9.0. If the `rand` crate has "
+"released the two new versions 0.8.6 and 0.9.0, you would see the following "
+"if you ran `cargo update`:"
+msgstr ""
+
+#: src/ch02-00-guessing-game-tutorial.md:628
+msgid ""
+"Cargo ignores the 0.9.0 release. At this point, you would also notice a "
+"change in your _Cargo.lock_ file noting that the version of the `rand` crate "
+"you are now using is 0.8.6. To use `rand` version 0.9.0 or any version in "
+"the 0.9._x_ series, you’d have to update the _Cargo.toml_ file to look like "
+"this instead:"
+msgstr ""
+
+#: src/ch02-00-guessing-game-tutorial.md:633
+msgid ""
+"```toml\n"
+"[dependencies]\n"
+"rand = \"0.9.0\"\n"
+"```"
+msgstr ""
+
+#: src/ch02-00-guessing-game-tutorial.md:638
+msgid ""
+"The next time you run `cargo build`, Cargo will update the registry of "
+"crates available and reevaluate your `rand` requirements according to the "
+"new version you have specified."
+msgstr ""
+
+#: src/ch02-00-guessing-game-tutorial.md:642
+msgid ""
+"There’s a lot more to say about [Cargo](https://doc.rust-lang.org/"
+"cargo/) and [its ecosystem](https://doc.rust-lang.org/cargo/"
+"reference/publishing.html), which we’ll discuss in Chapter "
+"14, but for now, that’s all you need to know. Cargo makes it very easy to "
+"reuse libraries, so Rustaceans are able to write smaller projects that are "
+"assembled from a number of packages."
+msgstr ""
+
+#: src/ch02-00-guessing-game-tutorial.md:648
+msgid "Generating a Random Number"
+msgstr ""
+
+#: src/ch02-00-guessing-game-tutorial.md:650
+msgid ""
+"Let’s start using `rand` to generate a number to guess. The next step is to "
+"update _src/main.rs_, as shown in Listing 2-3."
+msgstr ""
+
+#: src/ch02-00-guessing-game-tutorial.md:664
+#: src/ch02-00-guessing-game-tutorial.md:761
+#: src/ch02-00-guessing-game-tutorial.md:881
+#: src/ch02-00-guessing-game-tutorial.md:1005
+#: src/ch02-00-guessing-game-tutorial.md:1098
+#: src/ch02-00-guessing-game-tutorial.md:1150
+#: src/ch07-04-bringing-paths-into-scope-with-the-use-keyword.md:306
+#: src/ch07-04-bringing-paths-into-scope-with-the-use-keyword.md:359
+#: src/ch07-04-bringing-paths-into-scope-with-the-use-keyword.md:397
+#: src/ch19-04-advanced-types.md:230
+msgid "\"The secret number is: {secret_number}\""
+msgstr ""
+
+#: src/ch02-00-guessing-game-tutorial.md:674
+#: src/ch02-00-guessing-game-tutorial.md:771
+#: src/ch02-00-guessing-game-tutorial.md:895
+#: src/ch02-00-guessing-game-tutorial.md:1021
+#: src/ch02-00-guessing-game-tutorial.md:1111
+#: src/ch02-00-guessing-game-tutorial.md:1168
+#: src/ch02-00-guessing-game-tutorial.md:1273
+#: src/ch07-04-bringing-paths-into-scope-with-the-use-keyword.md:316
+#: src/ch07-04-bringing-paths-into-scope-with-the-use-keyword.md:369
+#: src/ch07-04-bringing-paths-into-scope-with-the-use-keyword.md:409
+#: src/ch19-04-advanced-types.md:248
+msgid "\"You guessed: {guess}\""
+msgstr ""
+
+#: src/ch02-00-guessing-game-tutorial.md:680
+msgid ""
+"First we add the line `use rand::Rng;`. The `Rng` trait defines methods that "
+"random number generators implement, and this trait must be in scope for us "
+"to use those methods. Chapter 10 will cover traits in detail."
+msgstr ""
+
+#: src/ch02-00-guessing-game-tutorial.md:684
+msgid ""
+"Next, we’re adding two lines in the middle. In the first line, we call the "
+"`rand::thread_rng` function that gives us the particular random number "
+"generator we’re going to use: one that is local to the current thread of "
+"execution and is seeded by the operating system. Then we call the "
+"`gen_range` method on the random number generator. This method is defined by "
+"the `Rng` trait that we brought into scope with the `use rand::Rng;` "
+"statement. The `gen_range` method takes a range expression as an argument "
+"and generates a random number in the range. The kind of range expression "
+"we’re using here takes the form `start..=end` and is inclusive on the lower "
+"and upper bounds, so we need to specify `1..=100` to request a number "
+"between 1 and 100."
+msgstr ""
+
+#: src/ch02-00-guessing-game-tutorial.md:695
+msgid ""
+"Note: You won’t just know which traits to use and which methods and "
+"functions to call from a crate, so each crate has documentation with "
+"instructions for using it. Another neat feature of Cargo is that running the "
+"`cargo doc --open` command will build documentation provided by all your "
+"dependencies locally and open it in your browser. If you’re interested in "
+"other functionality in the `rand` crate, for example, run `cargo doc --open` "
+"and click `rand` in the sidebar on the left."
+msgstr ""
+
+#: src/ch02-00-guessing-game-tutorial.md:703
+msgid ""
+"The second new line prints the secret number. This is useful while we’re "
+"developing the program to be able to test it, but we’ll delete it from the "
+"final version. It’s not much of a game if the program prints the answer as "
+"soon as it starts!"
+msgstr ""
+
+#: src/ch02-00-guessing-game-tutorial.md:708
+msgid "Try running the program a few times:"
+msgstr ""
+
+#: src/ch02-00-guessing-game-tutorial.md:718
+msgid ""
+"```console\n"
+"$ cargo run\n"
+" Compiling guessing_game v0.1.0 (file:///projects/guessing_game)\n"
+" Finished dev [unoptimized + debuginfo] target(s) in 2.53s\n"
+" Running `target/debug/guessing_game`\n"
+"Guess the number!\n"
+"The secret number is: 7\n"
+"Please input your guess.\n"
+"4\n"
+"You guessed: 4\n"
+"\n"
+"$ cargo run\n"
+" Finished dev [unoptimized + debuginfo] target(s) in 0.02s\n"
+" Running `target/debug/guessing_game`\n"
+"Guess the number!\n"
+"The secret number is: 83\n"
+"Please input your guess.\n"
+"5\n"
+"You guessed: 5\n"
+"```"
+msgstr ""
+
+#: src/ch02-00-guessing-game-tutorial.md:739
+msgid ""
+"You should get different random numbers, and they should all be numbers "
+"between 1 and 100. Great job!"
+msgstr ""
+
+#: src/ch02-00-guessing-game-tutorial.md:742
+msgid "Comparing the Guess to the Secret Number"
+msgstr ""
+
+#: src/ch02-00-guessing-game-tutorial.md:744
+msgid ""
+"Now that we have user input and a random number, we can compare them. That "
+"step is shown in Listing 2-4. Note that this code won’t compile just yet, as "
+"we will explain."
+msgstr ""
+
+#: src/ch02-00-guessing-game-tutorial.md:756
+#: src/ch02-00-guessing-game-tutorial.md:885
+#: src/ch02-00-guessing-game-tutorial.md:1003
+#: src/ch02-00-guessing-game-tutorial.md:1010
+#: src/ch02-00-guessing-game-tutorial.md:1113
+#: src/ch02-00-guessing-game-tutorial.md:1157
+#: src/ch02-00-guessing-game-tutorial.md:1170
+#: src/ch05-01-defining-structs.md:207 src/ch05-01-defining-structs.md:243
+#: src/ch06-01-defining-an-enum.md:207 src/ch06-01-defining-an-enum.md:211
+#: src/ch06-02-match.md:118 src/ch06-02-match.md:149 src/ch06-03-if-let.md:70
+#: src/ch06-03-if-let.md:97
+#: src/ch07-04-bringing-paths-into-scope-with-the-use-keyword.md:169
+#: src/ch07-04-bringing-paths-into-scope-with-the-use-keyword.md:174
+#: src/ch07-04-bringing-paths-into-scope-with-the-use-keyword.md:201
+#: src/ch07-04-bringing-paths-into-scope-with-the-use-keyword.md:206
+#: src/ch07-04-bringing-paths-into-scope-with-the-use-keyword.md:348
+#: src/ch07-04-bringing-paths-into-scope-with-the-use-keyword.md:351
+#: src/ch07-04-bringing-paths-into-scope-with-the-use-keyword.md:387
+#: src/ch07-04-bringing-paths-into-scope-with-the-use-keyword.md:389
+#: src/ch09-03-to-panic-or-not-to-panic.md:162
+#: src/ch09-03-to-panic-or-not-to-panic.md:183 src/ch10-02-traits.md:645
+#: src/ch11-01-writing-tests.md:407 src/ch11-01-writing-tests.md:471
+#: src/ch11-01-writing-tests.md:914 src/ch11-01-writing-tests.md:981
+#: src/ch12-02-reading-a-file.md:36
+#: src/ch12-03-improving-error-handling-and-modularity.md:84
+#: src/ch12-03-improving-error-handling-and-modularity.md:155
+#: src/ch12-03-improving-error-handling-and-modularity.md:252
+#: src/ch12-03-improving-error-handling-and-modularity.md:254
+#: src/ch12-03-improving-error-handling-and-modularity.md:332
+#: src/ch12-03-improving-error-handling-and-modularity.md:337
+#: src/ch12-03-improving-error-handling-and-modularity.md:478
+#: src/ch12-03-improving-error-handling-and-modularity.md:564
+#: src/ch12-03-improving-error-handling-and-modularity.md:585
+#: src/ch12-03-improving-error-handling-and-modularity.md:630
+#: src/ch12-03-improving-error-handling-and-modularity.md:758
+#: src/ch12-03-improving-error-handling-and-modularity.md:844
+#: src/ch12-03-improving-error-handling-and-modularity.md:857
+#: src/ch12-03-improving-error-handling-and-modularity.md:884
+#: src/ch12-03-improving-error-handling-and-modularity.md:896
+#: src/ch12-05-working-with-environment-variables.md:496
+#: src/ch13-03-improving-our-io-project.md:165
+#: src/ch13-03-improving-our-io-project.md:192
+#: src/ch13-03-improving-our-io-project.md:230
+#: src/ch14-02-publishing-to-crates-io.md:232
+#: src/ch14-02-publishing-to-crates-io.md:297
+#: src/ch14-02-publishing-to-crates-io.md:314
+#: src/ch14-02-publishing-to-crates-io.md:347
+#: src/ch15-05-interior-mutability.md:412 src/ch16-02-message-passing.md:306
+#: src/ch16-02-message-passing.md:343 src/ch17-03-oo-design-patterns.md:160
+#: src/ch17-03-oo-design-patterns.md:211 src/ch17-03-oo-design-patterns.md:255
+#: src/ch17-03-oo-design-patterns.md:362 src/ch17-03-oo-design-patterns.md:399
+#: src/ch17-03-oo-design-patterns.md:412 src/ch17-03-oo-design-patterns.md:463
+#: src/ch17-03-oo-design-patterns.md:478 src/ch17-03-oo-design-patterns.md:602
+#: src/ch17-03-oo-design-patterns.md:610 src/ch17-03-oo-design-patterns.md:640
+#: src/ch17-03-oo-design-patterns.md:863 src/ch19-03-advanced-traits.md:67
+#: src/ch19-04-advanced-types.md:95 src/ch19-04-advanced-types.md:99
+#: src/ch19-04-advanced-types.md:118 src/ch19-04-advanced-types.md:122
+#: src/ch19-04-advanced-types.md:207 src/ch19-04-advanced-types.md:237
+#: src/ch19-04-advanced-types.md:250 src/ch19-04-advanced-types.md:402
+#: src/ch19-04-advanced-types.md:410 src/ch19-04-advanced-types.md:420
+#: src/ch19-06-macros.md:375 src/ch20-01-single-threaded.md:396
+#: src/ch20-01-single-threaded.md:479 src/ch20-01-single-threaded.md:563
+#: src/ch20-01-single-threaded.md:638 src/ch20-01-single-threaded.md:642
+#: src/ch20-02-multithreaded.md:27 src/ch20-02-multithreaded.md:41
+#: src/ch20-02-multithreaded.md:55 src/ch20-02-multithreaded.md:463
+#: src/ch20-02-multithreaded.md:532 src/ch20-02-multithreaded.md:597
+#: src/ch20-02-multithreaded.md:616 src/ch20-02-multithreaded.md:695
+#: src/ch20-02-multithreaded.md:714 src/ch20-02-multithreaded.md:805
+#: src/ch20-02-multithreaded.md:826 src/ch20-02-multithreaded.md:873
+#: src/ch20-02-multithreaded.md:894 src/ch20-02-multithreaded.md:902
+#: src/ch20-02-multithreaded.md:982 src/ch20-02-multithreaded.md:993
+#: src/ch20-02-multithreaded.md:1017 src/ch20-02-multithreaded.md:1025
+#: src/ch20-02-multithreaded.md:1035 src/ch20-02-multithreaded.md:1075
+#: src/ch20-02-multithreaded.md:1081 src/ch20-02-multithreaded.md:1114
+#: src/ch20-02-multithreaded.md:1204 src/ch20-02-multithreaded.md:1356
+#: src/ch20-03-graceful-shutdown-and-cleanup.md:333
+#: src/ch20-03-graceful-shutdown-and-cleanup.md:475
+#: src/ch20-03-graceful-shutdown-and-cleanup.md:489
+msgid "// --snip--\n"
+msgstr ""
+
+#: src/ch02-00-guessing-game-tutorial.md:774
+#: src/ch02-00-guessing-game-tutorial.md:898
+#: src/ch02-00-guessing-game-tutorial.md:1024
+#: src/ch02-00-guessing-game-tutorial.md:1116
+#: src/ch02-00-guessing-game-tutorial.md:1173
+#: src/ch02-00-guessing-game-tutorial.md:1276
+#: src/ch07-04-bringing-paths-into-scope-with-the-use-keyword.md:372
+#: src/ch07-04-bringing-paths-into-scope-with-the-use-keyword.md:412
+#: src/ch09-03-to-panic-or-not-to-panic.md:184
+#: src/ch19-04-advanced-types.md:253
+msgid "\"Too small!\""
+msgstr ""
+
+#: src/ch02-00-guessing-game-tutorial.md:775
+#: src/ch02-00-guessing-game-tutorial.md:899
+#: src/ch02-00-guessing-game-tutorial.md:1025
+#: src/ch02-00-guessing-game-tutorial.md:1117
+#: src/ch02-00-guessing-game-tutorial.md:1174
+#: src/ch02-00-guessing-game-tutorial.md:1277
+#: src/ch07-04-bringing-paths-into-scope-with-the-use-keyword.md:373
+#: src/ch07-04-bringing-paths-into-scope-with-the-use-keyword.md:413
+#: src/ch09-03-to-panic-or-not-to-panic.md:185
+#: src/ch19-04-advanced-types.md:254
+msgid "\"Too big!\""
+msgstr ""
+
+#: src/ch02-00-guessing-game-tutorial.md:776
+#: src/ch02-00-guessing-game-tutorial.md:900
+#: src/ch02-00-guessing-game-tutorial.md:1026
+#: src/ch02-00-guessing-game-tutorial.md:1119
+#: src/ch02-00-guessing-game-tutorial.md:1176
+#: src/ch02-00-guessing-game-tutorial.md:1279
+#: src/ch07-04-bringing-paths-into-scope-with-the-use-keyword.md:374
+#: src/ch07-04-bringing-paths-into-scope-with-the-use-keyword.md:414
+#: src/ch09-03-to-panic-or-not-to-panic.md:187
+#: src/ch19-04-advanced-types.md:256
+msgid "\"You win!\""
+msgstr ""
+
+#: src/ch02-00-guessing-game-tutorial.md:783
+msgid ""
+"First we add another `use` statement, bringing a type called `std::cmp::"
+"Ordering` into scope from the standard library. The `Ordering` type is "
+"another enum and has the variants `Less`, `Greater`, and `Equal`. These are "
+"the three outcomes that are possible when you compare two values."
+msgstr ""
+
+#: src/ch02-00-guessing-game-tutorial.md:788
+msgid ""
+"Then we add five new lines at the bottom that use the `Ordering` type. The "
+"`cmp` method compares two values and can be called on anything that can be "
+"compared. It takes a reference to whatever you want to compare with: here "
+"it’s comparing `guess` to `secret_number`. Then it returns a variant of the "
+"`Ordering` enum we brought into scope with the `use` statement. We use a "
+"[`match`](ch06-02-match.html) expression to decide what to do "
+"next based on which variant of `Ordering` was returned from the call to "
+"`cmp` with the values in `guess` and `secret_number`."
+msgstr ""
+
+#: src/ch02-00-guessing-game-tutorial.md:797
+msgid ""
+"A `match` expression is made up of _arms_. An arm consists of a _pattern_ to "
+"match against, and the code that should be run if the value given to `match` "
+"fits that arm’s pattern. Rust takes the value given to `match` and looks "
+"through each arm’s pattern in turn. Patterns and the `match` 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."
+msgstr ""
+
+#: src/ch02-00-guessing-game-tutorial.md:805
+msgid ""
+"Let’s walk through an example with the `match` expression we use here. Say "
+"that the user has guessed 50 and the randomly generated secret number this "
+"time is 38."
+msgstr ""
+
+#: src/ch02-00-guessing-game-tutorial.md:809
+msgid ""
+"When the code compares 50 to 38, the `cmp` method will return `Ordering::"
+"Greater` because 50 is greater than 38. The `match` expression gets the "
+"`Ordering::Greater` value and starts checking each arm’s pattern. It looks "
+"at the first arm’s pattern, `Ordering::Less`, and sees that the value "
+"`Ordering::Greater` does not match `Ordering::Less`, so it ignores the code "
+"in that arm and moves to the next arm. The next arm’s pattern is `Ordering::"
+"Greater`, which _does_ match `Ordering::Greater`! The associated code in "
+"that arm will execute and print `Too big!` to the screen. The `match` "
+"expression ends after the first successful match, so it won’t look at the "
+"last arm in this scenario."
+msgstr ""
+
+#: src/ch02-00-guessing-game-tutorial.md:820
+msgid "However, the code in Listing 2-4 won’t compile yet. Let’s try it:"
+msgstr ""
+
+#: src/ch02-00-guessing-game-tutorial.md:827
+msgid ""
+"```console\n"
+"$ cargo build\n"
+" Compiling libc v0.2.86\n"
+" Compiling getrandom v0.2.2\n"
+" Compiling cfg-if v1.0.0\n"
+" Compiling ppv-lite86 v0.2.10\n"
+" Compiling rand_core v0.6.2\n"
+" Compiling rand_chacha v0.3.0\n"
+" Compiling rand v0.8.5\n"
+" Compiling guessing_game v0.1.0 (file:///projects/guessing_game)\n"
+"error[E0308]: mismatched types\n"
+" --> src/main.rs:22:21\n"
+" |\n"
+"22 | match guess.cmp(&secret_number) {\n"
+" | --- ^^^^^^^^^^^^^^ expected `&String`, found `&{integer}"
+"`\n"
+" | |\n"
+" | arguments to this method are incorrect\n"
+" |\n"
+" = note: expected reference `&String`\n"
+" found reference `&{integer}`\n"
+"note: method defined here\n"
+" --> /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/core/src/cmp."
+"rs:840:8\n"
+"\n"
+"For more information about this error, try `rustc --explain E0308`.\n"
+"error: could not compile `guessing_game` (bin \"guessing_game\") due to 1 "
+"previous error\n"
+"```"
+msgstr ""
+
+#: src/ch02-00-guessing-game-tutorial.md:854
+msgid ""
+"The core of the error states that there are _mismatched types_. Rust has a "
+"strong, static type system. However, it also has type inference. When we "
+"wrote `let mut guess = String::new()`, Rust was able to infer that `guess` "
+"should be a `String` and didn’t make us write the type. The `secret_number`, "
+"on the other hand, is a number type. A few of Rust’s number types can have a "
+"value between 1 and 100: `i32`, a 32-bit number; `u32`, an unsigned 32-bit "
+"number; `i64`, a 64-bit number; as well as others. Unless otherwise "
+"specified, Rust defaults to an `i32`, which is the type of `secret_number` "
+"unless you add type information elsewhere that would cause Rust to infer a "
+"different numerical type. The reason for the error is that Rust cannot "
+"compare a string and a number type."
+msgstr ""
+
+#: src/ch02-00-guessing-game-tutorial.md:865
+msgid ""
+"Ultimately, we want to convert the `String` the program reads as input into "
+"a number type so we can compare it numerically to the secret number. We do "
+"so by adding this line to the `main` function body:"
+msgstr ""
+
+#: src/ch02-00-guessing-game-tutorial.md:893
+#: src/ch02-00-guessing-game-tutorial.md:908
+#: src/ch02-00-guessing-game-tutorial.md:1019
+#: src/ch02-00-guessing-game-tutorial.md:1109
+#: src/ch07-04-bringing-paths-into-scope-with-the-use-keyword.md:407
+msgid "\"Please type a number!\""
+msgstr ""
+
+#: src/ch02-00-guessing-game-tutorial.md:905
+msgid "The line is:"
+msgstr ""
+
+#: src/ch02-00-guessing-game-tutorial.md:911
+msgid ""
+"We create a variable named `guess`. But wait, doesn’t the program already "
+"have a variable named `guess`? It does, but helpfully Rust allows us to "
+"shadow the previous value of `guess` with a new one. _Shadowing_ lets us "
+"reuse the `guess` variable name rather than forcing us to create two unique "
+"variables, such as `guess_str` and `guess`, for example. We’ll cover this in "
+"more detail in [Chapter 3](ch03-01-variables-and-mutability."
+"html#shadowing), but for now, know that this feature is often "
+"used when you want to convert a value from one type to another type."
+msgstr ""
+
+#: src/ch02-00-guessing-game-tutorial.md:919
+msgid ""
+"We bind this new variable to the expression `guess.trim().parse()`. The "
+"`guess` in the expression refers to the original `guess` variable that "
+"contained the input as a string. The `trim` method on a `String` instance "
+"will eliminate any whitespace at the beginning and end, which we must do to "
+"be able to compare the string to the `u32`, which can only contain numerical "
+"data. The user must press enter to satisfy `read_line` and input "
+"their guess, which adds a newline character to the string. For example, if "
+"the user types 5 and presses enter, `guess` looks like "
+"this: `5\\n`. The `\\n` represents “newline.” (On Windows, pressing "
+"enter results in a carriage return and a newline, `\\r\\n`.) The "
+"`trim` method eliminates `\\n` or `\\r\\n`, resulting in just `5`."
+msgstr ""
+
+#: src/ch02-00-guessing-game-tutorial.md:931
+msgid ""
+"The [`parse` method on strings](../std/primitive.str.html#method.parse) converts a string to another type. Here, we use it to convert "
+"from a string to a number. We need to tell Rust the exact number type we "
+"want by using `let guess: u32`. The colon (`:`) after `guess` tells Rust "
+"we’ll annotate the variable’s type. Rust has a few built-in number types; "
+"the `u32` seen here is an unsigned, 32-bit integer. It’s a good default "
+"choice for a small positive number. You’ll learn about other number types in "
+"[Chapter 3](ch03-02-data-types.html#integer-types)."
+msgstr ""
+
+#: src/ch02-00-guessing-game-tutorial.md:939
+msgid ""
+"Additionally, the `u32` annotation in this example program and the "
+"comparison with `secret_number` means Rust will infer that `secret_number` "
+"should be a `u32` as well. So now the comparison will be between two values "
+"of the same type!"
+msgstr ""
+
+#: src/ch02-00-guessing-game-tutorial.md:944
+msgid ""
+"The `parse` method will only work on characters that can logically be "
+"converted into numbers and so can easily cause errors. If, for example, the "
+"string contained `A👍%`, there would be no way to convert that to a number. "
+"Because it might fail, the `parse` method returns a `Result` type, much as "
+"the `read_line` method does (discussed earlier in [“Handling Potential "
+"Failure with `Result`”](#handling-potential-failure-with-result): if the user enters a non-number answer, the program "
+"will crash. We can take advantage of that to allow the user to quit, as "
+"shown here:"
+msgstr ""
+
+#: src/ch02-00-guessing-game-tutorial.md:1053
+msgid ""
+"```console\n"
+"$ cargo run\n"
+" Compiling guessing_game v0.1.0 (file:///projects/guessing_game)\n"
+" Finished dev [unoptimized + debuginfo] target(s) in 1.50s\n"
+" Running `target/debug/guessing_game`\n"
+"Guess the number!\n"
+"The secret number is: 59\n"
+"Please input your guess.\n"
+"45\n"
+"You guessed: 45\n"
+"Too small!\n"
+"Please input your guess.\n"
+"60\n"
+"You guessed: 60\n"
+"Too big!\n"
+"Please input your guess.\n"
+"59\n"
+"You guessed: 59\n"
+"You win!\n"
+"Please input your guess.\n"
+"quit\n"
+"thread 'main' panicked at 'Please type a number!: ParseIntError { kind: "
+"InvalidDigit }', src/main.rs:28:47\n"
+"note: run with `RUST_BACKTRACE=1` environment variable to display a "
+"backtrace\n"
+"```"
+msgstr ""
+
+#: src/ch02-00-guessing-game-tutorial.md:1078
+msgid ""
+"Typing `quit` will quit the game, but as you’ll notice, so will entering any "
+"other non-number input. This is suboptimal, to say the least; we want the "
+"game to also stop when the correct number is guessed."
+msgstr ""
+
+#: src/ch02-00-guessing-game-tutorial.md:1082
+msgid "Quitting After a Correct Guess"
+msgstr ""
+
+#: src/ch02-00-guessing-game-tutorial.md:1084
+msgid ""
+"Let’s program the game to quit when the user wins by adding a `break` "
+"statement:"
+msgstr ""
+
+#: src/ch02-00-guessing-game-tutorial.md:1127
+msgid ""
+"Adding the `break` line after `You win!` makes the program exit the loop "
+"when the user guesses the secret number correctly. Exiting the loop also "
+"means exiting the program, because the loop is the last part of `main`."
+msgstr ""
+
+#: src/ch02-00-guessing-game-tutorial.md:1131
+msgid "Handling Invalid Input"
+msgstr ""
+
+#: src/ch02-00-guessing-game-tutorial.md:1133
+msgid ""
+"To further refine the game’s behavior, rather than crashing the program when "
+"the user inputs a non-number, let’s make the game ignore a non-number so the "
+"user can continue guessing. We can do that by altering the line where "
+"`guess` is converted from a `String` to a `u32`, as shown in Listing 2-5."
+msgstr ""
+
+#: src/ch02-00-guessing-game-tutorial.md:1186
+msgid ""
+"We switch from an `expect` call to a `match` expression to move from "
+"crashing on an error to handling the error. Remember that `parse` returns a "
+"`Result` type and `Result` is an enum that has the variants `Ok` and `Err`. "
+"We’re using a `match` expression here, as we did with the `Ordering` result "
+"of the `cmp` method."
+msgstr ""
+
+#: src/ch02-00-guessing-game-tutorial.md:1192
+msgid ""
+"If `parse` is able to successfully turn the string into a number, it will "
+"return an `Ok` value that contains the resultant number. That `Ok` value "
+"will match the first arm’s pattern, and the `match` expression will just "
+"return the `num` value that `parse` produced and put inside the `Ok` value. "
+"That number will end up right where we want it in the new `guess` variable "
+"we’re creating."
+msgstr ""
+
+#: src/ch02-00-guessing-game-tutorial.md:1198
+msgid ""
+"If `parse` is _not_ able to turn the string into a number, it will return an "
+"`Err` value that contains more information about the error. The `Err` value "
+"does not match the `Ok(num)` pattern in the first `match` arm, but it does "
+"match the `Err(_)` pattern in the second arm. The underscore, `_`, is a "
+"catchall value; in this example, we’re saying we want to match all `Err` "
+"values, no matter what information they have inside them. So the program "
+"will execute the second arm’s code, `continue`, which tells the program to "
+"go to the next iteration of the `loop` and ask for another guess. So, "
+"effectively, the program ignores all errors that `parse` might encounter!"
+msgstr ""
+
+#: src/ch02-00-guessing-game-tutorial.md:1208
+msgid "Now everything in the program should work as expected. Let’s try it:"
+msgstr ""
+
+#: src/ch02-00-guessing-game-tutorial.md:1219
+msgid ""
+"```console\n"
+"$ cargo run\n"
+" Compiling guessing_game v0.1.0 (file:///projects/guessing_game)\n"
+" Finished dev [unoptimized + debuginfo] target(s) in 4.45s\n"
+" Running `target/debug/guessing_game`\n"
+"Guess the number!\n"
+"The secret number is: 61\n"
+"Please input your guess.\n"
+"10\n"
+"You guessed: 10\n"
+"Too small!\n"
+"Please input your guess.\n"
+"99\n"
+"You guessed: 99\n"
+"Too big!\n"
+"Please input your guess.\n"
+"foo\n"
+"Please input your guess.\n"
+"61\n"
+"You guessed: 61\n"
+"You win!\n"
+"```"
+msgstr ""
+
+#: src/ch02-00-guessing-game-tutorial.md:1242
+msgid ""
+"Awesome! With one tiny final tweak, we will finish the guessing game. Recall "
+"that the program is still printing the secret number. That worked well for "
+"testing, but it ruins the game. Let’s delete the `println!` that outputs the "
+"secret number. Listing 2-6 shows the final code."
+msgstr ""
+
+#: src/ch02-00-guessing-game-tutorial.md:1289
+msgid ""
+"At this point, you’ve successfully built the guessing game. Congratulations!"
+msgstr ""
+
+#: src/ch02-00-guessing-game-tutorial.md:1293
+msgid ""
+"This project was a hands-on way to introduce you to many new Rust concepts: "
+"`let`, `match`, functions, the use of external crates, and more. In the next "
+"few chapters, you’ll learn about these concepts in more detail. Chapter 3 "
+"covers concepts that most programming languages have, such as variables, "
+"data types, and functions, and shows how to use them in Rust. Chapter 4 "
+"explores ownership, a feature that makes Rust different from other "
+"languages. Chapter 5 discusses structs and method syntax, and Chapter 6 "
+"explains how enums work."
+msgstr ""
+
+#: src/ch03-00-common-programming-concepts.md:3
+msgid ""
+"This chapter covers concepts that appear in almost every programming "
+"language and how they work in Rust. Many programming languages have much in "
+"common at their core. None of the concepts presented in this chapter are "
+"unique to Rust, but we’ll discuss them in the context of Rust and explain "
+"the conventions around using these concepts."
+msgstr ""
+
+#: src/ch03-00-common-programming-concepts.md:9
+msgid ""
+"Specifically, you’ll learn about variables, basic types, functions, "
+"comments, and control flow. These foundations will be in every Rust program, "
+"and learning them early will give you a strong core to start from."
+msgstr ""
+
+#: src/ch03-00-common-programming-concepts.md:13
+msgid "Keywords"
+msgstr ""
+
+#: src/ch03-00-common-programming-concepts.md:15
+msgid ""
+"The Rust language has a set of _keywords_ that are reserved for use by the "
+"language only, much as in other languages. Keep in mind that you cannot use "
+"these words as names of variables or functions. Most of the keywords have "
+"special meanings, and you’ll be using them to do various tasks in your Rust "
+"programs; a few have no current functionality associated with them but have "
+"been reserved for functionality that might be added to Rust in the future. "
+"You can find a list of the keywords in [Appendix A](appendix-01-keywords."
+"md)."
+msgstr ""
+
+#: src/ch03-01-variables-and-mutability.md:3
+msgid ""
+"As mentioned in the [“Storing Values with Variables”](ch02-00-guessing-game-"
+"tutorial.html#storing-values-with-variables) section, by "
+"default, variables are immutable. This is one of many nudges Rust gives you "
+"to write your code in a way that takes advantage of the safety and easy "
+"concurrency that Rust offers. However, you still have the option to make "
+"your variables mutable. Let’s explore how and why Rust encourages you to "
+"favor immutability and why sometimes you might want to opt out."
+msgstr ""
+
+#: src/ch03-01-variables-and-mutability.md:11
+msgid ""
+"When a variable is immutable, once a value is bound to a name, you can’t "
+"change that value. To illustrate this, generate a new project called "
+"_variables_ in your _projects_ directory by using `cargo new variables`."
+msgstr ""
+
+#: src/ch03-01-variables-and-mutability.md:15
+msgid ""
+"Then, in your new _variables_ directory, open _src/main.rs_ and replace its "
+"code with the following code, which won’t compile just yet:"
+msgstr ""
+
+#: src/ch03-01-variables-and-mutability.md:23
+#: src/ch03-01-variables-and-mutability.md:25
+#: src/ch03-01-variables-and-mutability.md:84
+#: src/ch03-01-variables-and-mutability.md:86
+#: src/ch03-01-variables-and-mutability.md:177
+#: src/ch03-03-how-functions-work.md:74 src/ch03-03-how-functions-work.md:271
+#: src/ch03-03-how-functions-work.md:310 src/ch03-03-how-functions-work.md:328
+msgid "\"The value of x is: {x}\""
+msgstr ""
+
+#: src/ch03-01-variables-and-mutability.md:29
+msgid ""
+"Save and run the program using `cargo run`. You should receive an error "
+"message regarding an immutability error, as shown in this output:"
+msgstr ""
+
+#: src/ch03-01-variables-and-mutability.md:32
+msgid ""
+"```console\n"
+"$ cargo run\n"
+" Compiling variables v0.1.0 (file:///projects/variables)\n"
+"error[E0384]: cannot assign twice to immutable variable `x`\n"
+" --> src/main.rs:4:5\n"
+" |\n"
+"2 | let x = 5;\n"
+" | -\n"
+" | |\n"
+" | first assignment to `x`\n"
+" | help: consider making this binding mutable: `mut x`\n"
+"3 | println!(\"The value of x is: {x}\");\n"
+"4 | x = 6;\n"
+" | ^^^^^ cannot assign twice to immutable variable\n"
+"\n"
+"For more information about this error, try `rustc --explain E0384`.\n"
+"error: could not compile `variables` (bin \"variables\") due to 1 previous "
+"error\n"
+"```"
+msgstr ""
+
+#: src/ch03-01-variables-and-mutability.md:51
+msgid ""
+"This example shows how the compiler helps you find errors in your programs. "
+"Compiler errors can be frustrating, but really they only mean your program "
+"isn’t safely doing what you want it to do yet; they do _not_ mean that "
+"you’re not a good programmer! Experienced Rustaceans still get compiler "
+"errors."
+msgstr ""
+
+#: src/ch03-01-variables-and-mutability.md:56
+msgid ""
+"You received the error message `` cannot assign twice to immutable variable "
+"`x` `` because you tried to assign a second value to the immutable `x` "
+"variable."
+msgstr ""
+
+#: src/ch03-01-variables-and-mutability.md:59
+msgid ""
+"It’s important that we get compile-time errors when we attempt to change a "
+"value that’s designated as immutable because this very situation can lead to "
+"bugs. If one part of our code operates on the assumption that a value will "
+"never change and another part of our code changes that value, it’s possible "
+"that the first part of the code won’t do what it was designed to do. The "
+"cause of this kind of bug can be difficult to track down after the fact, "
+"especially when the second piece of code changes the value only _sometimes_. "
+"The Rust compiler guarantees that when you state that a value won’t change, "
+"it really won’t change, so you don’t have to keep track of it yourself. Your "
+"code is thus easier to reason through."
+msgstr ""
+
+#: src/ch03-01-variables-and-mutability.md:70
+msgid ""
+"But mutability can be very useful, and can make code more convenient to "
+"write. Although variables are immutable by default, you can make them "
+"mutable by adding `mut` in front of the variable name as you did in [Chapter "
+"2](ch02-00-guessing-game-tutorial.html#storing-values-with-variables). Adding `mut` also conveys intent to future readers of the code "
+"by indicating that other parts of the code will be changing this variable’s "
+"value."
+msgstr ""
+
+#: src/ch03-01-variables-and-mutability.md:77
+msgid "For example, let’s change _src/main.rs_ to the following:"
+msgstr ""
+
+#: src/ch03-01-variables-and-mutability.md:90
+msgid "When we run the program now, we get this:"
+msgstr ""
+
+#: src/ch03-01-variables-and-mutability.md:92
+msgid ""
+"```console\n"
+"$ cargo run\n"
+" Compiling variables v0.1.0 (file:///projects/variables)\n"
+" Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.30s\n"
+" Running `target/debug/variables`\n"
+"The value of x is: 5\n"
+"The value of x is: 6\n"
+"```"
+msgstr ""
+
+#: src/ch03-01-variables-and-mutability.md:101
+msgid ""
+"We’re allowed to change the value bound to `x` from `5` to `6` when `mut` is "
+"used. Ultimately, deciding whether to use mutability or not is up to you and "
+"depends on what you think is clearest in that particular situation."
+msgstr ""
+
+#: src/ch03-01-variables-and-mutability.md:105
+msgid "Constants"
+msgstr ""
+
+#: src/ch03-01-variables-and-mutability.md:107
+msgid ""
+"Like immutable variables, _constants_ are values that are bound to a name "
+"and are not allowed to change, but there are a few differences between "
+"constants and variables."
+msgstr ""
+
+#: src/ch03-01-variables-and-mutability.md:111
+msgid ""
+"First, you aren’t allowed to use `mut` with constants. Constants aren’t just "
+"immutable by default—they’re always immutable. You declare constants using "
+"the `const` keyword instead of the `let` keyword, and the type of the value "
+"_must_ be annotated. We’ll cover types and type annotations in the next "
+"section, [“Data Types”](ch03-02-data-types.html#data-types), "
+"so don’t worry about the details right now. Just know that you must always "
+"annotate the type."
+msgstr ""
+
+#: src/ch03-01-variables-and-mutability.md:118
+msgid ""
+"Constants can be declared in any scope, including the global scope, which "
+"makes them useful for values that many parts of code need to know about."
+msgstr ""
+
+#: src/ch03-01-variables-and-mutability.md:121
+msgid ""
+"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."
+msgstr ""
+
+#: src/ch03-01-variables-and-mutability.md:124
+msgid "Here’s an example of a constant declaration:"
+msgstr ""
+
+#: src/ch03-01-variables-and-mutability.md:130
+msgid ""
+"The constant’s name is `THREE_HOURS_IN_SECONDS` and its value is set to the "
+"result of multiplying 60 (the number of seconds in a minute) by 60 (the "
+"number of minutes in an hour) by 3 (the number of hours we want to count in "
+"this program). Rust’s naming convention for constants is to use all "
+"uppercase with underscores between words. The compiler is able to evaluate a "
+"limited set of operations at compile time, which lets us choose to write out "
+"this value in a way that’s easier to understand and verify, rather than "
+"setting this constant to the value 10,800. See the [Rust Reference’s section "
+"on constant evaluation](../reference/const_eval.html) for more information "
+"on what operations can be used when declaring constants."
+msgstr ""
+
+#: src/ch03-01-variables-and-mutability.md:141
+msgid ""
+"Constants are valid for the entire time a program runs, within the scope in "
+"which they were declared. This property makes constants useful for values in "
+"your application domain that multiple parts of the program might need to "
+"know about, such as the maximum number of points any player of a game is "
+"allowed to earn, or the speed of light."
+msgstr ""
+
+#: src/ch03-01-variables-and-mutability.md:147
+msgid ""
+"Naming hardcoded values used throughout your program as constants is useful "
+"in conveying the meaning of that value to future maintainers of the code. It "
+"also helps to have only one place in your code you would need to change if "
+"the hardcoded value needed to be updated in the future."
+msgstr ""
+
+#: src/ch03-01-variables-and-mutability.md:152
+msgid "Shadowing"
+msgstr ""
+
+#: src/ch03-01-variables-and-mutability.md:154
+msgid ""
+"As you saw in the guessing game tutorial in [Chapter 2](ch02-00-guessing-"
+"game-tutorial.html#comparing-the-guess-to-the-secret-number), "
+"you can declare a new variable with the same name as a previous variable. "
+"Rustaceans say that the first variable is _shadowed_ by the second, which "
+"means that the second variable is what the compiler will see when you use "
+"the name of the variable. In effect, the second variable overshadows the "
+"first, taking any uses of the variable name to itself until either it itself "
+"is shadowed or the scope ends. We can shadow a variable by using the same "
+"variable’s name and repeating the use of the `let` keyword as follows:"
+msgstr ""
+
+#: src/ch03-01-variables-and-mutability.md:174
+msgid "\"The value of x in the inner scope is: {x}\""
+msgstr ""
+
+#: src/ch03-01-variables-and-mutability.md:181
+msgid ""
+"This program first binds `x` to a value of `5`. Then it creates a new "
+"variable `x` by repeating `let x =`, taking the original value and adding "
+"`1` so the value of `x` is then `6`. Then, within an inner scope created "
+"with the curly brackets, the third `let` statement also shadows `x` and "
+"creates a new variable, multiplying the previous value by `2` to give `x` a "
+"value of `12`. When that scope is over, the inner shadowing ends and `x` "
+"returns to being `6`. When we run this program, it will output the following:"
+msgstr ""
+
+#: src/ch03-01-variables-and-mutability.md:189
+msgid ""
+"```console\n"
+"$ cargo run\n"
+" Compiling variables v0.1.0 (file:///projects/variables)\n"
+" Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.31s\n"
+" Running `target/debug/variables`\n"
+"The value of x in the inner scope is: 12\n"
+"The value of x is: 6\n"
+"```"
+msgstr ""
+
+#: src/ch03-01-variables-and-mutability.md:198
+msgid ""
+"Shadowing is different from marking a variable as `mut` because we’ll get a "
+"compile-time error if we accidentally try to reassign to this variable "
+"without using the `let` keyword. By using `let`, we can perform a few "
+"transformations on a value but have the variable be immutable after those "
+"transformations have been completed."
+msgstr ""
+
+#: src/ch03-01-variables-and-mutability.md:204
+msgid ""
+"The other difference between `mut` and shadowing is that because we’re "
+"effectively creating a new variable when we use the `let` keyword again, we "
+"can 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:"
+msgstr ""
+
+#: src/ch03-01-variables-and-mutability.md:212
+#: src/ch03-01-variables-and-mutability.md:225
+msgid "\" \""
+msgstr ""
+
+#: src/ch03-01-variables-and-mutability.md:217
+msgid ""
+"The first `spaces` variable is a string type and the second `spaces` "
+"variable is a number type. Shadowing thus spares us from having to come up "
+"with different names, such as `spaces_str` and `spaces_num`; instead, we can "
+"reuse the simpler `spaces` name. However, if we try to use `mut` for this, "
+"as shown here, we’ll get a compile-time error:"
+msgstr ""
+
+#: src/ch03-01-variables-and-mutability.md:230
+msgid "The error says we’re not allowed to mutate a variable’s type:"
+msgstr ""
+
+#: src/ch03-01-variables-and-mutability.md:232
+msgid ""
+"```console\n"
+"$ cargo run\n"
+" Compiling variables v0.1.0 (file:///projects/variables)\n"
+"error[E0308]: mismatched types\n"
+" --> src/main.rs:3:14\n"
+" |\n"
+"2 | let mut spaces = \" \";\n"
+" | ----- expected due to this value\n"
+"3 | spaces = spaces.len();\n"
+" | ^^^^^^^^^^^^ expected `&str`, found `usize`\n"
+"\n"
+"For more information about this error, try `rustc --explain E0308`.\n"
+"error: could not compile `variables` (bin \"variables\") due to 1 previous "
+"error\n"
+"```"
+msgstr ""
+
+#: src/ch03-01-variables-and-mutability.md:247
+msgid ""
+"Now that we’ve explored how variables work, let’s look at more data types "
+"they can have."
+msgstr ""
+
+#: src/ch03-02-data-types.md:3
+msgid ""
+"Every value in Rust is of a certain _data type_, which tells Rust what kind "
+"of data is being specified so it knows how to work with that data. We’ll "
+"look at two data type subsets: scalar and compound."
+msgstr ""
+
+#: src/ch03-02-data-types.md:7
+msgid ""
+"Keep in mind that Rust is a _statically typed_ language, which means that it "
+"must know the types of all variables at compile time. The compiler can "
+"usually infer what type we want to use based on the value and how we use it. "
+"In cases when many types are possible, such as when we converted a `String` "
+"to a numeric type using `parse` in the [“Comparing the Guess to the Secret "
+"Number”](ch02-00-guessing-game-tutorial.html#comparing-the-guess-to-the-"
+"secret-number) section in Chapter 2, we must add a type "
+"annotation, like this:"
+msgstr ""
+
+#: src/ch03-02-data-types.md:16
+msgid "\"42\""
+msgstr ""
+
+#: src/ch03-02-data-types.md:16
+msgid "\"Not a number!\""
+msgstr ""
+
+#: src/ch03-02-data-types.md:19
+msgid ""
+"If we don’t add the `: u32` type annotation shown in the preceding code, "
+"Rust will display the following error, which means the compiler needs more "
+"information from us to know which type we want to use:"
+msgstr ""
+
+#: src/ch03-02-data-types.md:23
+msgid ""
+"```console\n"
+"$ cargo build\n"
+" Compiling no_type_annotations v0.1.0 (file:///projects/"
+"no_type_annotations)\n"
+"error[E0284]: type annotations needed\n"
+" --> src/main.rs:2:9\n"
+" |\n"
+"2 | let guess = \"42\".parse().expect(\"Not a number!\");\n"
+" | ^^^^^ ----- type must be known at this point\n"
+" |\n"
+" = note: cannot satisfy `<_ as FromStr>::Err == _`\n"
+"help: consider giving `guess` an explicit type\n"
+" |\n"
+"2 | let guess: /* Type */ = \"42\".parse().expect(\"Not a number!\");\n"
+" | ++++++++++++\n"
+"\n"
+"For more information about this error, try `rustc --explain E0284`.\n"
+"error: could not compile `no_type_annotations` (bin \"no_type_annotations\") "
+"due to 1 previous error\n"
+"```"
+msgstr ""
+
+#: src/ch03-02-data-types.md:42
+msgid "You’ll see different type annotations for other data types."
+msgstr ""
+
+#: src/ch03-02-data-types.md:44
+msgid "Scalar Types"
+msgstr ""
+
+#: src/ch03-02-data-types.md:46
+msgid ""
+"A _scalar_ type represents a single value. Rust has four primary scalar "
+"types: integers, floating-point numbers, Booleans, and characters. You may "
+"recognize these from other programming languages. Let’s jump into how they "
+"work in Rust."
+msgstr ""
+
+#: src/ch03-02-data-types.md:50
+msgid "Integer Types"
+msgstr ""
+
+#: src/ch03-02-data-types.md:52
+msgid ""
+"An _integer_ is a number without a fractional component. We used one integer "
+"type in Chapter 2, the `u32` type. This type declaration indicates that the "
+"value it’s associated with should be an unsigned integer (signed integer "
+"types start with `i` instead of `u`) that takes up 32 bits of space. Table "
+"3-1 shows the built-in integer types in Rust. We can use any of these "
+"variants to declare the type of an integer value."
+msgstr ""
+
+#: src/ch03-02-data-types.md:59
+msgid "Table 3-1: Integer Types in Rust"
+msgstr ""
+
+#: src/ch03-02-data-types.md:61
+msgid "Length"
+msgstr ""
+
+#: src/ch03-02-data-types.md:61
+msgid "Signed"
+msgstr ""
+
+#: src/ch03-02-data-types.md:61
+msgid "Unsigned"
+msgstr ""
+
+#: src/ch03-02-data-types.md:63
+msgid "8-bit"
+msgstr ""
+
+#: src/ch03-02-data-types.md:63
+msgid "`i8`"
+msgstr ""
+
+#: src/ch03-02-data-types.md:63
+msgid "`u8`"
+msgstr ""
+
+#: src/ch03-02-data-types.md:64
+msgid "16-bit"
+msgstr ""
+
+#: src/ch03-02-data-types.md:64
+msgid "`i16`"
+msgstr ""
+
+#: src/ch03-02-data-types.md:64
+msgid "`u16`"
+msgstr ""
+
+#: src/ch03-02-data-types.md:65
+msgid "32-bit"
+msgstr ""
+
+#: src/ch03-02-data-types.md:65
+msgid "`i32`"
+msgstr ""
+
+#: src/ch03-02-data-types.md:65
+msgid "`u32`"
+msgstr ""
+
+#: src/ch03-02-data-types.md:66
+msgid "64-bit"
+msgstr ""
+
+#: src/ch03-02-data-types.md:66
+msgid "`i64`"
+msgstr ""
+
+#: src/ch03-02-data-types.md:66
+msgid "`u64`"
+msgstr ""
+
+#: src/ch03-02-data-types.md:67
+msgid "128-bit"
+msgstr ""
+
+#: src/ch03-02-data-types.md:67
+msgid "`i128`"
+msgstr ""
+
+#: src/ch03-02-data-types.md:67
+msgid "`u128`"
+msgstr ""
+
+#: src/ch03-02-data-types.md:68
+msgid "arch"
+msgstr ""
+
+#: src/ch03-02-data-types.md:68
+msgid "`isize`"
+msgstr ""
+
+#: src/ch03-02-data-types.md:68
+msgid "`usize`"
+msgstr ""
+
+#: src/ch03-02-data-types.md:70
+msgid ""
+"Each variant can be either signed or unsigned and has an explicit size. "
+"_Signed_ and _unsigned_ refer to whether it’s possible for the number to be "
+"negative—in other words, whether the number needs to have a sign with it "
+"(signed) or whether it will only ever be positive and can therefore be "
+"represented without a sign (unsigned). It’s like writing numbers on paper: "
+"when the sign matters, a number is shown with a plus sign or a minus sign; "
+"however, when it’s safe to assume the number is positive, it’s shown with no "
+"sign. Signed numbers are stored using [two’s complement](https://en."
+"wikipedia.org/wiki/Two%27s_complement) representation."
+msgstr ""
+
+#: src/ch03-02-data-types.md:80
+msgid ""
+"Each signed variant can store numbers from -(2n - 1) to 2n - "
+"1 - 1 inclusive, where _n_ is the number of bits that variant uses. So "
+"an `i8` can store numbers from -(27) to 27 - 1, which "
+"equals \\-128 to 127. Unsigned variants can store numbers from 0 to 2n"
+"sup> - 1, so a `u8` can store numbers from 0 to 28 - 1, which "
+"equals 0 to 255."
+msgstr ""
+
+#: src/ch03-02-data-types.md:86
+msgid ""
+"Additionally, the `isize` and `usize` types depend on the architecture of "
+"the computer your program is running on, which is denoted in the table as "
+"“arch”: 64 bits if you’re on a 64-bit architecture and 32 bits if you’re on "
+"a 32-bit architecture."
+msgstr ""
+
+#: src/ch03-02-data-types.md:91
+msgid ""
+"You can write integer literals in any of the forms shown in Table 3-2. Note "
+"that number literals that can be multiple numeric types allow a type suffix, "
+"such as `57u8`, to designate the type. Number literals can also use `_` as a "
+"visual separator to make the number easier to read, such as `1_000`, which "
+"will have the same value as if you had specified `1000`."
+msgstr ""
+
+#: src/ch03-02-data-types.md:97
+msgid "Table 3-2: Integer Literals in Rust"
+msgstr ""
+
+#: src/ch03-02-data-types.md:99
+msgid "Number literals"
+msgstr ""
+
+#: src/ch03-02-data-types.md:99 src/appendix-02-operators.md:16
+msgid "Example"
+msgstr ""
+
+#: src/ch03-02-data-types.md:101
+msgid "Decimal"
+msgstr ""
+
+#: src/ch03-02-data-types.md:101
+msgid "`98_222`"
+msgstr ""
+
+#: src/ch03-02-data-types.md:102
+msgid "Hex"
+msgstr ""
+
+#: src/ch03-02-data-types.md:102
+msgid "`0xff`"
+msgstr ""
+
+#: src/ch03-02-data-types.md:103
+msgid "Octal"
+msgstr ""
+
+#: src/ch03-02-data-types.md:103
+msgid "`0o77`"
+msgstr ""
+
+#: src/ch03-02-data-types.md:104
+msgid "Binary"
+msgstr ""
+
+#: src/ch03-02-data-types.md:104
+msgid "`0b1111_0000`"
+msgstr ""
+
+#: src/ch03-02-data-types.md:105
+msgid "Byte (`u8` only)"
+msgstr ""
+
+#: src/ch03-02-data-types.md:105
+msgid "`b'A'`"
+msgstr ""
+
+#: src/ch03-02-data-types.md:107
+msgid ""
+"So how do you know which type of integer to use? If you’re unsure, Rust’s "
+"defaults are generally good places to start: integer types default to `i32`. "
+"The primary situation in which you’d use `isize` or `usize` is when indexing "
+"some sort of collection."
+msgstr ""
+
+#: src/ch03-02-data-types.md:112
+msgid "Integer Overflow"
+msgstr ""
+
+#: src/ch03-02-data-types.md:114
+msgid ""
+"Let’s say you have a variable of type `u8` that can hold values between 0 "
+"and 255. If you try to change the variable to a value outside that range, "
+"such as 256, _integer overflow_ will occur, which can result in one of two "
+"behaviors. When you’re compiling in debug mode, Rust includes checks for "
+"integer overflow that cause your program to _panic_ at runtime if this "
+"behavior occurs. Rust uses the term _panicking_ when a program exits with an "
+"error; we’ll discuss panics in more depth in the [“Unrecoverable Errors with "
+"`panic!`”](ch09-01-unrecoverable-errors-with-panic.html) "
+"section in Chapter 9."
+msgstr ""
+
+#: src/ch03-02-data-types.md:124
+msgid ""
+"When you’re compiling in release mode with the `--release` flag, Rust does "
+"_not_ include checks for integer overflow that cause panics. Instead, if "
+"overflow occurs, Rust performs _two’s complement wrapping_. In short, values "
+"greater than the maximum value the type can hold “wrap around” to the "
+"minimum of the values the type can hold. In the case of a `u8`, the value "
+"256 becomes 0, the value 257 becomes 1, and so on. The program won’t panic, "
+"but the variable will have a value that probably isn’t what you were "
+"expecting it to have. Relying on integer overflow’s wrapping behavior is "
+"considered an error."
+msgstr ""
+
+#: src/ch03-02-data-types.md:133
+msgid ""
+"To explicitly handle the possibility of overflow, you can use these families "
+"of methods provided by the standard library for primitive numeric types:"
+msgstr ""
+
+#: src/ch03-02-data-types.md:136
+msgid ""
+"Wrap in all modes with the `wrapping_*` methods, such as `wrapping_add`."
+msgstr ""
+
+#: src/ch03-02-data-types.md:137
+msgid ""
+"Return the `None` value if there is overflow with the `checked_*` methods."
+msgstr ""
+
+#: src/ch03-02-data-types.md:138
+msgid ""
+"Return the value and a boolean indicating whether there was overflow with "
+"the `overflowing_*` methods."
+msgstr ""
+
+#: src/ch03-02-data-types.md:140
+msgid ""
+"Saturate at the value’s minimum or maximum values with the `saturating_*` "
+"methods."
+msgstr ""
+
+#: src/ch03-02-data-types.md:143
+msgid "Floating-Point Types"
+msgstr ""
+
+#: src/ch03-02-data-types.md:145
+msgid ""
+"Rust also has two primitive types for _floating-point numbers_, which are "
+"numbers with decimal points. Rust’s floating-point types are `f32` and "
+"`f64`, which are 32 bits and 64 bits in size, respectively. The default type "
+"is `f64` because on modern CPUs, it’s roughly the same speed as `f32` but is "
+"capable of more precision. All floating-point types are signed."
+msgstr ""
+
+#: src/ch03-02-data-types.md:151
+msgid "Here’s an example that shows floating-point numbers in action:"
+msgstr ""
+
+#: src/ch03-02-data-types.md:157
+msgid "// f64\n"
+msgstr ""
+
+#: src/ch03-02-data-types.md:159
+msgid "// f32\n"
+msgstr ""
+
+#: src/ch03-02-data-types.md:163
+msgid ""
+"Floating-point numbers are represented according to the IEEE-754 standard. "
+"The `f32` type is a single-precision float, and `f64` has double precision."
+msgstr ""
+
+#: src/ch03-02-data-types.md:166
+msgid "Numeric Operations"
+msgstr ""
+
+#: src/ch03-02-data-types.md:168
+msgid ""
+"Rust supports the basic mathematical operations you’d expect for all the "
+"number types: addition, subtraction, multiplication, division, and "
+"remainder. Integer division truncates toward zero to the nearest integer. "
+"The following code shows how you’d use each numeric operation in a `let` "
+"statement:"
+msgstr ""
+
+#: src/ch03-02-data-types.md:177
+msgid "// addition\n"
+msgstr ""
+
+#: src/ch03-02-data-types.md:180
+msgid "// subtraction\n"
+msgstr ""
+
+#: src/ch03-02-data-types.md:183
+msgid "// multiplication\n"
+msgstr ""
+
+#: src/ch03-02-data-types.md:186
+msgid "// division\n"
+msgstr ""
+
+#: src/ch03-02-data-types.md:188
+msgid "// Results in -1\n"
+msgstr ""
+
+#: src/ch03-02-data-types.md:190
+msgid "// remainder\n"
+msgstr ""
+
+#: src/ch03-02-data-types.md:195
+msgid ""
+"Each expression in these statements uses a mathematical operator and "
+"evaluates to a single value, which is then bound to a variable. [Appendix B]"
+"(appendix-02-operators.md) contains a list of all operators "
+"that Rust provides."
+msgstr ""
+
+#: src/ch03-02-data-types.md:200
+msgid "The Boolean Type"
+msgstr ""
+
+#: src/ch03-02-data-types.md:202
+msgid ""
+"As in most other programming languages, a Boolean type in Rust has two "
+"possible values: `true` and `false`. Booleans are one byte in size. The "
+"Boolean type in Rust is specified using `bool`. For example:"
+msgstr ""
+
+#: src/ch03-02-data-types.md:212 src/ch03-02-data-types.md:230
+msgid "// with explicit type annotation\n"
+msgstr ""
+
+#: src/ch03-02-data-types.md:216
+msgid ""
+"The main way to use Boolean values is through conditionals, such as an `if` "
+"expression. We’ll cover how `if` expressions work in Rust in the [“Control "
+"Flow”](ch03-05-control-flow.html#control-flow) section."
+msgstr ""
+
+#: src/ch03-02-data-types.md:220
+msgid "The Character Type"
+msgstr ""
+
+#: src/ch03-02-data-types.md:222
+msgid ""
+"Rust’s `char` type is the language’s most primitive alphabetic type. Here "
+"are some examples of declaring `char` values:"
+msgstr ""
+
+#: src/ch03-02-data-types.md:229 src/ch18-03-pattern-syntax.md:146
+msgid "'z'"
+msgstr ""
+
+#: src/ch03-02-data-types.md:230
+msgid "'ℤ'"
+msgstr ""
+
+#: src/ch03-02-data-types.md:231
+msgid "'😻'"
+msgstr ""
+
+#: src/ch03-02-data-types.md:235
+msgid ""
+"Note that we specify `char` literals with single quotes, as opposed to "
+"string literals, which use double quotes. Rust’s `char` type is four bytes "
+"in size and represents a Unicode Scalar Value, which means it can represent "
+"a lot more than just ASCII. Accented letters; Chinese, Japanese, and Korean "
+"characters; emoji; and zero-width spaces are all valid `char` values in "
+"Rust. Unicode Scalar Values range from `U+0000` to `U+D7FF` and `U+E000` to "
+"`U+10FFFF` inclusive. However, a “character” isn’t really a concept in "
+"Unicode, so your human intuition for what a “character” is may not match up "
+"with what a `char` is in Rust. We’ll discuss this topic in detail in "
+"[“Storing UTF-8 Encoded Text with Strings”](ch08-02-strings.html#storing-"
+"utf-8-encoded-text-with-strings) in Chapter 8."
+msgstr ""
+
+#: src/ch03-02-data-types.md:246
+msgid "Compound Types"
+msgstr ""
+
+#: src/ch03-02-data-types.md:248
+msgid ""
+"_Compound types_ can group multiple values into one type. Rust has two "
+"primitive compound types: tuples and arrays."
+msgstr ""
+
+#: src/ch03-02-data-types.md:251
+msgid "The Tuple Type"
+msgstr ""
+
+#: src/ch03-02-data-types.md:253
+msgid ""
+"A _tuple_ is a general way of grouping together a number of values with a "
+"variety of types into one compound type. Tuples have a fixed length: once "
+"declared, they cannot grow or shrink in size."
+msgstr ""
+
+#: src/ch03-02-data-types.md:257
+msgid ""
+"We create a tuple by writing a comma-separated list of values inside "
+"parentheses. Each position in the tuple has a type, and the types of the "
+"different values in the tuple don’t have to be the same. We’ve added "
+"optional type annotations in this example:"
+msgstr ""
+
+#: src/ch03-02-data-types.md:270
+msgid ""
+"The variable `tup` 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:"
+msgstr ""
+
+#: src/ch03-02-data-types.md:282 src/ch03-03-how-functions-work.md:230
+msgid "\"The value of y is: {y}\""
+msgstr ""
+
+#: src/ch03-02-data-types.md:286
+msgid ""
+"This program first creates a tuple and binds it to the variable `tup`. It "
+"then uses a pattern with `let` to take `tup` and turn it into three separate "
+"variables, `x`, `y`, and `z`. This is called _destructuring_ because it "
+"breaks the single tuple into three parts. Finally, the program prints the "
+"value of `y`, which is `6.4`."
+msgstr ""
+
+#: src/ch03-02-data-types.md:292
+msgid ""
+"We can also access a tuple element directly by using a period (`.`) followed "
+"by the index of the value we want to access. For example:"
+msgstr ""
+
+#: src/ch03-02-data-types.md:309
+msgid ""
+"This program creates the tuple `x` and then accesses each element of the "
+"tuple using their respective indices. As with most programming languages, "
+"the first index in a tuple is 0."
+msgstr ""
+
+#: src/ch03-02-data-types.md:313
+msgid ""
+"The tuple without any values has a special name, _unit_. This value and its "
+"corresponding type are both written `()` and represent an empty value or an "
+"empty return type. Expressions implicitly return the unit value if they "
+"don’t return any other value."
+msgstr ""
+
+#: src/ch03-02-data-types.md:318
+msgid "The Array Type"
+msgstr ""
+
+#: src/ch03-02-data-types.md:320
+msgid ""
+"Another way to have a collection of multiple values is with an _array_. "
+"Unlike a tuple, every element of an array must have the same type. Unlike "
+"arrays in some other languages, arrays in Rust have a fixed length."
+msgstr ""
+
+#: src/ch03-02-data-types.md:324
+msgid ""
+"We write the values in an array as a comma-separated list inside square "
+"brackets:"
+msgstr ""
+
+#: src/ch03-02-data-types.md:335
+msgid ""
+"Arrays are useful when you want your data allocated on the stack rather than "
+"the heap (we will discuss the stack and the heap more in [Chapter 4](ch04-01-"
+"what-is-ownership.html#the-stack-and-the-heap)) or when you "
+"want to ensure you always have a fixed number of elements. An array isn’t as "
+"flexible as the vector type, though. A _vector_ is a similar collection type "
+"provided by the standard library that _is_ allowed to grow or shrink in "
+"size. If you’re unsure whether to use an array or a vector, chances are you "
+"should use a vector. [Chapter 8](ch08-01-vectors.html) "
+"discusses vectors in more detail."
+msgstr ""
+
+#: src/ch03-02-data-types.md:344
+msgid ""
+"However, arrays are more useful when you know the number of elements will "
+"not 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:"
+msgstr ""
+
+#: src/ch03-02-data-types.md:350
+msgid "\"January\""
+msgstr ""
+
+#: src/ch03-02-data-types.md:350
+msgid "\"February\""
+msgstr ""
+
+#: src/ch03-02-data-types.md:350
+msgid "\"March\""
+msgstr ""
+
+#: src/ch03-02-data-types.md:350
+msgid "\"April\""
+msgstr ""
+
+#: src/ch03-02-data-types.md:350
+msgid "\"May\""
+msgstr ""
+
+#: src/ch03-02-data-types.md:350
+msgid "\"June\""
+msgstr ""
+
+#: src/ch03-02-data-types.md:350
+msgid "\"July\""
+msgstr ""
+
+#: src/ch03-02-data-types.md:351
+msgid "\"August\""
+msgstr ""
+
+#: src/ch03-02-data-types.md:351
+msgid "\"September\""
+msgstr ""
+
+#: src/ch03-02-data-types.md:351
+msgid "\"October\""
+msgstr ""
+
+#: src/ch03-02-data-types.md:351
+msgid "\"November\""
+msgstr ""
+
+#: src/ch03-02-data-types.md:351
+msgid "\"December\""
+msgstr ""
+
+#: src/ch03-02-data-types.md:354
+msgid ""
+"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:"
+msgstr ""
+
+#: src/ch03-02-data-types.md:361
+msgid ""
+"Here, `i32` is the type of each element. After the semicolon, the number `5` "
+"indicates the array contains five elements."
+msgstr ""
+
+#: src/ch03-02-data-types.md:364
+msgid ""
+"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:"
+msgstr ""
+
+#: src/ch03-02-data-types.md:372
+msgid ""
+"The array named `a` will contain `5` elements that will all be set to the "
+"value `3` initially. This is the same as writing `let a = [3, 3, 3, 3, 3];` "
+"but in a more concise way."
+msgstr ""
+
+#: src/ch03-02-data-types.md:376
+msgid "Accessing Array Elements"
+msgstr ""
+
+#: src/ch03-02-data-types.md:378
+msgid ""
+"An array is a single chunk of memory of a known, fixed size that can be "
+"allocated on the stack. You can access elements of an array using indexing, "
+"like this:"
+msgstr ""
+
+#: src/ch03-02-data-types.md:393
+msgid ""
+"In this example, the variable named `first` will get the value `1` because "
+"that is the value at index `[0]` in the array. The variable named `second` "
+"will get the value `2` from index `[1]` in the array."
+msgstr ""
+
+#: src/ch03-02-data-types.md:397
+msgid "Invalid Array Element Access"
+msgstr ""
+
+#: src/ch03-02-data-types.md:399
+msgid ""
+"Let’s see what happens if you try to access an element of an array that is "
+"past the end of the array. Say you run this code, similar to the guessing "
+"game in Chapter 2, to get an array index from the user:"
+msgstr ""
+
+#: src/ch03-02-data-types.md:411
+msgid "\"Please enter an array index.\""
+msgstr ""
+
+#: src/ch03-02-data-types.md:422
+msgid "\"Index entered was not a number\""
+msgstr ""
+
+#: src/ch03-02-data-types.md:426
+msgid "\"The value of the element at index {index} is: {element}\""
+msgstr ""
+
+#: src/ch03-02-data-types.md:430
+msgid ""
+"This code compiles successfully. If you run this code using `cargo run` and "
+"enter `0`, `1`, `2`, `3`, or `4`, the program will print out the "
+"corresponding value at that index in the array. If you instead enter a "
+"number past the end of the array, such as `10`, you’ll see output like this:"
+msgstr ""
+
+#: src/ch03-02-data-types.md:447
+msgid ""
+"The program resulted in a _runtime_ error at the point of using an invalid "
+"value in the indexing operation. The program exited with an error message "
+"and didn’t execute the final `println!` statement. When you attempt to "
+"access an element using indexing, Rust will check that the index you’ve "
+"specified is less than the array length. If the index is greater than or "
+"equal to the length, Rust will panic. This check has to happen at runtime, "
+"especially in this case, because the compiler can’t possibly know what value "
+"a user will enter when they run the code later."
+msgstr ""
+
+#: src/ch03-02-data-types.md:456
+msgid ""
+"This is an example of Rust’s memory safety principles in action. In many low-"
+"level languages, this kind of check is not done, and when you provide an "
+"incorrect index, invalid memory can be accessed. Rust protects you against "
+"this kind of error by immediately exiting instead of allowing the memory "
+"access and continuing. Chapter 9 discusses more of Rust’s error handling and "
+"how you can write readable, safe code that neither panics nor allows invalid "
+"memory access."
+msgstr ""
+
+#: src/ch03-03-how-functions-work.md:3
+msgid ""
+"Functions are prevalent in Rust code. You’ve already seen one of the most "
+"important functions in the language: the `main` function, which is the entry "
+"point of many programs. You’ve also seen the `fn` keyword, which allows you "
+"to declare new functions."
+msgstr ""
+
+#: src/ch03-03-how-functions-work.md:8
+msgid ""
+"Rust code uses _snake case_ as the conventional style for function and "
+"variable names, in which all letters are lowercase and underscores separate "
+"words. Here’s a program that contains an example function definition:"
+msgstr ""
+
+#: src/ch03-03-how-functions-work.md:22
+msgid "\"Another function.\""
+msgstr ""
+
+#: src/ch03-03-how-functions-work.md:26
+msgid ""
+"We define a function in Rust by entering `fn` followed by a function name "
+"and a set of parentheses. The curly brackets tell the compiler where the "
+"function body begins and ends."
+msgstr ""
+
+#: src/ch03-03-how-functions-work.md:30
+msgid ""
+"We can call any function we’ve defined by entering its name followed by a "
+"set of parentheses. Because `another_function` is defined in the program, it "
+"can be called from inside the `main` function. Note that we defined "
+"`another_function` _after_ the `main` function in the source code; we could "
+"have defined it before as well. Rust doesn’t care where you define your "
+"functions, only that they’re defined somewhere in a scope that can be seen "
+"by the caller."
+msgstr ""
+
+#: src/ch03-03-how-functions-work.md:37
+msgid ""
+"Let’s start a new binary project named _functions_ to explore functions "
+"further. Place the `another_function` example in _src/main.rs_ and run it. "
+"You should see the following output:"
+msgstr ""
+
+#: src/ch03-03-how-functions-work.md:41
+msgid ""
+"```console\n"
+"$ cargo run\n"
+" Compiling functions v0.1.0 (file:///projects/functions)\n"
+" Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.28s\n"
+" Running `target/debug/functions`\n"
+"Hello, world!\n"
+"Another function.\n"
+"```"
+msgstr ""
+
+#: src/ch03-03-how-functions-work.md:50
+msgid ""
+"The lines execute in the order in which they appear in the `main` function. "
+"First the “Hello, world!” message prints, and then `another_function` is "
+"called and its message is printed."
+msgstr ""
+
+#: src/ch03-03-how-functions-work.md:54
+msgid "Parameters"
+msgstr ""
+
+#: src/ch03-03-how-functions-work.md:56
+msgid ""
+"We can define functions to have _parameters_, which are special variables "
+"that are part of a function’s signature. When a function has parameters, you "
+"can provide it with concrete values for those parameters. Technically, the "
+"concrete values are called _arguments_, but in casual conversation, people "
+"tend to use the words _parameter_ and _argument_ interchangeably for either "
+"the variables in a function’s definition or the concrete values passed in "
+"when you call a function."
+msgstr ""
+
+#: src/ch03-03-how-functions-work.md:64
+msgid "In this version of `another_function` we add a parameter:"
+msgstr ""
+
+#: src/ch03-03-how-functions-work.md:78
+msgid "Try running this program; you should get the following output:"
+msgstr ""
+
+#: src/ch03-03-how-functions-work.md:80
+msgid ""
+"```console\n"
+"$ cargo run\n"
+" Compiling functions v0.1.0 (file:///projects/functions)\n"
+" Finished `dev` profile [unoptimized + debuginfo] target(s) in 1.21s\n"
+" Running `target/debug/functions`\n"
+"The value of x is: 5\n"
+"```"
+msgstr ""
+
+#: src/ch03-03-how-functions-work.md:88
+msgid ""
+"The declaration of `another_function` has one parameter named `x`. The type "
+"of `x` is specified as `i32`. When we pass `5` in to `another_function`, the "
+"`println!` macro puts `5` where the pair of curly brackets containing `x` "
+"was in the format string."
+msgstr ""
+
+#: src/ch03-03-how-functions-work.md:93
+msgid ""
+"In function signatures, you _must_ declare the type of each parameter. This "
+"is a deliberate decision in Rust’s design: requiring type annotations in "
+"function definitions means the compiler almost never needs you to use them "
+"elsewhere in the code to figure out what type you mean. The compiler is also "
+"able to give more helpful error messages if it knows what types the function "
+"expects."
+msgstr ""
+
+#: src/ch03-03-how-functions-work.md:99
+msgid ""
+"When defining multiple parameters, separate the parameter declarations with "
+"commas, like this:"
+msgstr ""
+
+#: src/ch03-03-how-functions-work.md:106
+msgid "'h'"
+msgstr ""
+
+#: src/ch03-03-how-functions-work.md:110
+msgid "\"The measurement is: {value}{unit_label}\""
+msgstr ""
+
+#: src/ch03-03-how-functions-work.md:114
+msgid ""
+"This example creates a function named `print_labeled_measurement` with two "
+"parameters. The first parameter is named `value` and is an `i32`. The second "
+"is named `unit_label` and is type `char`. The function then prints text "
+"containing both the `value` and the `unit_label`."
+msgstr ""
+
+#: src/ch03-03-how-functions-work.md:119
+msgid ""
+"Let’s try running this code. Replace the program currently in your "
+"_functions_ project’s _src/main.rs_ file with the preceding example and run "
+"it using `cargo run`:"
+msgstr ""
+
+#: src/ch03-03-how-functions-work.md:123
+msgid ""
+"```console\n"
+"$ cargo run\n"
+" Compiling functions v0.1.0 (file:///projects/functions)\n"
+" Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.31s\n"
+" Running `target/debug/functions`\n"
+"The measurement is: 5h\n"
+"```"
+msgstr ""
+
+#: src/ch03-03-how-functions-work.md:131
+msgid ""
+"Because we called the function with `5` as the value for `value` and `'h'` "
+"as the value for `unit_label`, the program output contains those values."
+msgstr ""
+
+#: src/ch03-03-how-functions-work.md:134
+msgid "Statements and Expressions"
+msgstr ""
+
+#: src/ch03-03-how-functions-work.md:136
+msgid ""
+"Function bodies are made up of a series of statements optionally ending in "
+"an expression. So far, the functions we’ve covered haven’t included an "
+"ending expression, but you have seen an expression as part of a statement. "
+"Because Rust is an expression-based language, this is an important "
+"distinction to understand. Other languages don’t have the same distinctions, "
+"so let’s look at what statements and expressions are and how their "
+"differences affect the bodies of functions."
+msgstr ""
+
+#: src/ch03-03-how-functions-work.md:144
+msgid ""
+"**Statements** are instructions that perform some action and do not return a "
+"value."
+msgstr ""
+
+#: src/ch03-03-how-functions-work.md:146
+msgid ""
+"**Expressions** evaluate to a resultant value. Let’s look at some examples."
+msgstr ""
+
+#: src/ch03-03-how-functions-work.md:148
+msgid ""
+"We’ve actually already used statements and expressions. Creating a variable "
+"and assigning a value to it with the `let` keyword is a statement. In "
+"Listing 3-1, `let y = 6;` is a statement."
+msgstr ""
+
+#: src/ch03-03-how-functions-work.md:162
+msgid ""
+"Function definitions are also statements; the entire preceding example is a "
+"statement in itself. (As we will see below, _calling_ a function is not a "
+"statement.)"
+msgstr ""
+
+#: src/ch03-03-how-functions-work.md:166
+msgid ""
+"Statements do not return values. Therefore, you can’t assign a `let` "
+"statement to another variable, as the following code tries to do; you’ll get "
+"an error:"
+msgstr ""
+
+#: src/ch03-03-how-functions-work.md:177
+msgid "When you run this program, the error you’ll get looks like this:"
+msgstr ""
+
+#: src/ch03-03-how-functions-work.md:179
+msgid ""
+"```console\n"
+"$ cargo run\n"
+" Compiling functions v0.1.0 (file:///projects/functions)\n"
+"error: expected expression, found `let` statement\n"
+" --> src/main.rs:2:14\n"
+" |\n"
+"2 | let x = (let y = 6);\n"
+" | ^^^\n"
+" |\n"
+" = note: only supported directly in conditions of `if` and `while` "
+"expressions\n"
+"\n"
+"warning: unnecessary parentheses around assigned value\n"
+" --> src/main.rs:2:13\n"
+" |\n"
+"2 | let x = (let y = 6);\n"
+" | ^ ^\n"
+" |\n"
+" = note: `#[warn(unused_parens)]` on by default\n"
+"help: remove these parentheses\n"
+" |\n"
+"2 - let x = (let y = 6);\n"
+"2 + let x = let y = 6;\n"
+" |\n"
+"\n"
+"warning: `functions` (bin \"functions\") generated 1 warning\n"
+"error: could not compile `functions` (bin \"functions\") due to 1 previous "
+"error; 1 warning emitted\n"
+"```"
+msgstr ""
+
+#: src/ch03-03-how-functions-work.md:207
+msgid ""
+"The `let y = 6` statement does not return a value, so there isn’t anything "
+"for `x` to bind to. This is different from what happens in other languages, "
+"such as C and Ruby, where the assignment returns the value of the "
+"assignment. In those languages, you can write `x = y = 6` and have both `x` "
+"and `y` have the value `6`; that is not the case in Rust."
+msgstr ""
+
+#: src/ch03-03-how-functions-work.md:213
+msgid ""
+"Expressions evaluate to a value and make up most of the rest of the code "
+"that you’ll write in Rust. Consider a math operation, such as `5 + 6`, which "
+"is an expression that evaluates to the value `11`. Expressions can be part "
+"of statements: in Listing 3-1, the `6` in the statement `let y = 6;` is an "
+"expression that evaluates to the value `6`. Calling a function is an "
+"expression. Calling a macro is an expression. A new scope block created with "
+"curly brackets is an expression, for example:"
+msgstr ""
+
+#: src/ch03-03-how-functions-work.md:234
+msgid "This expression:"
+msgstr ""
+
+#: src/ch03-03-how-functions-work.md:243
+msgid ""
+"is a block that, in this case, evaluates to `4`. That value gets bound to "
+"`y` as part of the `let` statement. Note that the `x + 1` line doesn’t have "
+"a semicolon at the end, which is unlike most of the lines you’ve seen so "
+"far. Expressions do not include ending semicolons. If you add a semicolon to "
+"the end of an expression, you turn it into a statement, and it will then not "
+"return a value. Keep this in mind as you explore function return values and "
+"expressions next."
+msgstr ""
+
+#: src/ch03-03-how-functions-work.md:251
+msgid "Functions with Return Values"
+msgstr ""
+
+#: src/ch03-03-how-functions-work.md:253
+msgid ""
+"Functions can return values to the code that calls them. We don’t name "
+"return values, but we must declare their type after an arrow (`->`). In "
+"Rust, the return value of the function is synonymous with the value of the "
+"final expression in the block of the body of a function. You can return "
+"early from a function by using the `return` keyword and specifying a value, "
+"but most functions return the last expression implicitly. Here’s an example "
+"of a function that returns a value:"
+msgstr ""
+
+#: src/ch03-03-how-functions-work.md:275
+msgid ""
+"There are no function calls, macros, or even `let` statements in the `five` "
+"function—just the number `5` by itself. That’s a perfectly valid function in "
+"Rust. Note that the function’s return type is specified too, as `-> i32`. "
+"Try running this code; the output should look like this:"
+msgstr ""
+
+#: src/ch03-03-how-functions-work.md:280
+msgid ""
+"```console\n"
+"$ cargo run\n"
+" Compiling functions v0.1.0 (file:///projects/functions)\n"
+" Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.30s\n"
+" Running `target/debug/functions`\n"
+"The value of x is: 5\n"
+"```"
+msgstr ""
+
+#: src/ch03-03-how-functions-work.md:288
+msgid ""
+"The `5` in `five` is the function’s return value, which is why the return "
+"type is `i32`. Let’s examine this in more detail. There are two important "
+"bits: first, the line `let x = five();` shows that we’re using the return "
+"value of a function to initialize a variable. Because the function `five` "
+"returns a `5`, that line is the same as the following:"
+msgstr ""
+
+#: src/ch03-03-how-functions-work.md:298
+msgid ""
+"Second, the `five` function has no parameters and defines the type of the "
+"return value, but the body of the function is a lonely `5` with no semicolon "
+"because it’s an expression whose value we want to return."
+msgstr ""
+
+#: src/ch03-03-how-functions-work.md:302
+msgid "Let’s look at another example:"
+msgstr ""
+
+#: src/ch03-03-how-functions-work.md:318
+msgid ""
+"Running this code will print `The value of x is: 6`. But if we place a "
+"semicolon at the end of the line containing `x + 1`, changing it from an "
+"expression to a statement, we’ll get an error:"
+msgstr ""
+
+#: src/ch03-03-how-functions-work.md:336
+msgid "Compiling this code produces an error, as follows:"
+msgstr ""
+
+#: src/ch03-03-how-functions-work.md:338
+msgid ""
+"```console\n"
+"$ cargo run\n"
+" Compiling functions v0.1.0 (file:///projects/functions)\n"
+"error[E0308]: mismatched types\n"
+" --> src/main.rs:7:24\n"
+" |\n"
+"7 | fn plus_one(x: i32) -> i32 {\n"
+" | -------- ^^^ expected `i32`, found `()`\n"
+" | |\n"
+" | implicitly returns `()` as its body has no tail or `return` "
+"expression\n"
+"8 | x + 1;\n"
+" | - help: remove this semicolon to return this value\n"
+"\n"
+"For more information about this error, try `rustc --explain E0308`.\n"
+"error: could not compile `functions` (bin \"functions\") due to 1 previous "
+"error\n"
+"```"
+msgstr ""
+
+#: src/ch03-03-how-functions-work.md:355
+msgid ""
+"The main error message, `mismatched types`, reveals the core issue with this "
+"code. The definition of the function `plus_one` says that it will return an "
+"`i32`, but statements don’t evaluate to a value, which is expressed by `()`, "
+"the unit type. Therefore, nothing is returned, which contradicts the "
+"function definition and results in an error. In this output, Rust provides a "
+"message to possibly help rectify this issue: it suggests removing the "
+"semicolon, which would fix the error."
+msgstr ""
+
+#: src/ch03-04-comments.md:3
+msgid ""
+"All programmers strive to make their code easy to understand, but sometimes "
+"extra explanation is warranted. In these cases, programmers leave _comments_ "
+"in their source code that the compiler will ignore but people reading the "
+"source code may find useful."
+msgstr ""
+
+#: src/ch03-04-comments.md:8
+msgid "Here’s a simple comment:"
+msgstr ""
+
+#: src/ch03-04-comments.md:11
+msgid "// hello, world\n"
+msgstr ""
+
+#: src/ch03-04-comments.md:14
+msgid ""
+"In Rust, the idiomatic comment style starts a comment with two slashes, and "
+"the comment continues until the end of the line. For comments that extend "
+"beyond a single line, you’ll need to include `//` on each line, like this:"
+msgstr ""
+
+#: src/ch03-04-comments.md:19
+msgid ""
+"// So we’re doing something complicated here, long enough that we need\n"
+"// multiple lines of comments to do it! Whew! Hopefully, this comment will\n"
+"// explain what’s going on.\n"
+msgstr ""
+
+#: src/ch03-04-comments.md:24
+msgid "Comments can also be placed at the end of lines containing code:"
+msgstr ""
+
+#: src/ch03-04-comments.md:30 src/ch03-04-comments.md:41
+msgid "// I’m feeling lucky today\n"
+msgstr ""
+
+#: src/ch03-04-comments.md:34
+msgid ""
+"But you’ll more often see them used in this format, with the comment on a "
+"separate line above the code it’s annotating:"
+msgstr ""
+
+#: src/ch03-04-comments.md:46
+msgid ""
+"Rust also has another kind of comment, documentation comments, which we’ll "
+"discuss in the [“Publishing a Crate to Crates.io”](ch14-02-publishing-to-"
+"crates-io.html) section of Chapter 14."
+msgstr ""
+
+#: src/ch03-05-control-flow.md:3
+msgid ""
+"The ability to run some code depending on whether a condition is `true` and "
+"to run some code repeatedly while a condition is `true` are basic building "
+"blocks in most programming languages. The most common constructs that let "
+"you control the flow of execution of Rust code are `if` expressions and "
+"loops."
+msgstr ""
+
+#: src/ch03-05-control-flow.md:8
+msgid "`if` Expressions"
+msgstr ""
+
+#: src/ch03-05-control-flow.md:10
+msgid ""
+"An `if` expression allows you to branch your code depending on conditions. "
+"You provide a condition and then state, “If this condition is met, run this "
+"block of code. If the condition is not met, do not run this block of code.”"
+msgstr ""
+
+#: src/ch03-05-control-flow.md:14
+msgid ""
+"Create a new project called _branches_ in your _projects_ directory to "
+"explore the `if` expression. In the _src/main.rs_ file, input the following:"
+msgstr ""
+
+#: src/ch03-05-control-flow.md:24 src/ch03-05-control-flow.md:64
+msgid "\"condition was true\""
+msgstr ""
+
+#: src/ch03-05-control-flow.md:26 src/ch03-05-control-flow.md:66
+msgid "\"condition was false\""
+msgstr ""
+
+#: src/ch03-05-control-flow.md:31
+msgid ""
+"All `if` expressions start with the keyword `if`, followed by a condition. "
+"In this case, the condition checks whether or not the variable `number` has "
+"a value less than 5. We place the block of code to execute if the condition "
+"is `true` immediately after the condition inside curly brackets. Blocks of "
+"code associated with the conditions in `if` expressions are sometimes called "
+"_arms_, just like the arms in `match` expressions that we discussed in the "
+"[“Comparing the Guess to the Secret Number”](ch02-00-guessing-game-tutorial."
+"html#comparing-the-guess-to-the-secret-number) section of Chapter 2."
+msgstr ""
+
+#: src/ch03-05-control-flow.md:40
+msgid ""
+"Optionally, we can also include an `else` expression, which we chose to do "
+"here, to give the program an alternative block of code to execute should the "
+"condition evaluate to `false`. If you don’t provide an `else` expression and "
+"the condition is `false`, the program will just skip the `if` block and move "
+"on to the next bit of code."
+msgstr ""
+
+#: src/ch03-05-control-flow.md:46
+msgid "Try running this code; you should see the following output:"
+msgstr ""
+
+#: src/ch03-05-control-flow.md:48
+msgid ""
+"```console\n"
+"$ cargo run\n"
+" Compiling branches v0.1.0 (file:///projects/branches)\n"
+" Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.31s\n"
+" Running `target/debug/branches`\n"
+"condition was true\n"
+"```"
+msgstr ""
+
+#: src/ch03-05-control-flow.md:56
+msgid ""
+"Let’s try changing the value of `number` to a value that makes the condition "
+"`false` to see what happens:"
+msgstr ""
+
+#: src/ch03-05-control-flow.md:71
+msgid "Run the program again, and look at the output:"
+msgstr ""
+
+#: src/ch03-05-control-flow.md:73
+msgid ""
+"```console\n"
+"$ cargo run\n"
+" Compiling branches v0.1.0 (file:///projects/branches)\n"
+" Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.31s\n"
+" Running `target/debug/branches`\n"
+"condition was false\n"
+"```"
+msgstr ""
+
+#: src/ch03-05-control-flow.md:81
+msgid ""
+"It’s also worth noting that the condition in this code _must_ be a `bool`. "
+"If the condition isn’t a `bool`, we’ll get an error. For example, try "
+"running the following code:"
+msgstr ""
+
+#: src/ch03-05-control-flow.md:92
+msgid "\"number was three\""
+msgstr ""
+
+#: src/ch03-05-control-flow.md:97
+msgid ""
+"The `if` condition evaluates to a value of `3` this time, and Rust throws an "
+"error:"
+msgstr ""
+
+#: src/ch03-05-control-flow.md:100
+msgid ""
+"```console\n"
+"$ cargo run\n"
+" Compiling branches v0.1.0 (file:///projects/branches)\n"
+"error[E0308]: mismatched types\n"
+" --> src/main.rs:4:8\n"
+" |\n"
+"4 | if number {\n"
+" | ^^^^^^ expected `bool`, found integer\n"
+"\n"
+"For more information about this error, try `rustc --explain E0308`.\n"
+"error: could not compile `branches` (bin \"branches\") due to 1 previous "
+"error\n"
+"```"
+msgstr ""
+
+#: src/ch03-05-control-flow.md:113
+msgid ""
+"The error indicates that Rust expected a `bool` but got an integer. Unlike "
+"languages such as Ruby and JavaScript, Rust will not automatically try to "
+"convert non-Boolean types to a Boolean. You must be explicit and always "
+"provide `if` with a Boolean as its condition. If we want the `if` code block "
+"to run only when a number is not equal to `0`, for example, we can change "
+"the `if` expression to the following:"
+msgstr ""
+
+#: src/ch03-05-control-flow.md:127
+msgid "\"number was something other than zero\""
+msgstr ""
+
+#: src/ch03-05-control-flow.md:132
+msgid "Running this code will print `number was something other than zero`."
+msgstr ""
+
+#: src/ch03-05-control-flow.md:134
+msgid "Handling Multiple Conditions with `else if`"
+msgstr ""
+
+#: src/ch03-05-control-flow.md:136
+msgid ""
+"You can use multiple conditions by combining `if` and `else` in an `else if` "
+"expression. For example:"
+msgstr ""
+
+#: src/ch03-05-control-flow.md:146
+msgid "\"number is divisible by 4\""
+msgstr ""
+
+#: src/ch03-05-control-flow.md:148
+msgid "\"number is divisible by 3\""
+msgstr ""
+
+#: src/ch03-05-control-flow.md:150
+msgid "\"number is divisible by 2\""
+msgstr ""
+
+#: src/ch03-05-control-flow.md:152
+msgid "\"number is not divisible by 4, 3, or 2\""
+msgstr ""
+
+#: src/ch03-05-control-flow.md:157
+msgid ""
+"This program has four possible paths it can take. After running it, you "
+"should see the following output:"
+msgstr ""
+
+#: src/ch03-05-control-flow.md:160
+msgid ""
+"```console\n"
+"$ cargo run\n"
+" Compiling branches v0.1.0 (file:///projects/branches)\n"
+" Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.31s\n"
+" Running `target/debug/branches`\n"
+"number is divisible by 3\n"
+"```"
+msgstr ""
+
+#: src/ch03-05-control-flow.md:168
+msgid ""
+"When this program executes, it checks each `if` expression in turn and "
+"executes the first body for which the condition evaluates to `true`. Note "
+"that even though 6 is divisible by 2, we don’t see the output `number is "
+"divisible by 2`, nor do we see the `number is not divisible by 4, 3, or 2` "
+"text from the `else` block. That’s because Rust only executes the block for "
+"the first `true` condition, and once it finds one, it doesn’t even check the "
+"rest."
+msgstr ""
+
+#: src/ch03-05-control-flow.md:175
+msgid ""
+"Using too many `else if` expressions can clutter your code, so if you have "
+"more than one, you might want to refactor your code. Chapter 6 describes a "
+"powerful Rust branching construct called `match` for these cases."
+msgstr ""
+
+#: src/ch03-05-control-flow.md:179
+msgid "Using `if` in a `let` Statement"
+msgstr ""
+
+#: src/ch03-05-control-flow.md:181
+msgid ""
+"Because `if` is an expression, we can use it on the right side of a `let` "
+"statement to assign the outcome to a variable, as in Listing 3-2."
+msgstr ""
+
+#: src/ch03-05-control-flow.md:191 src/ch03-05-control-flow.md:224
+msgid "\"The value of number is: {number}\""
+msgstr ""
+
+#: src/ch03-05-control-flow.md:197
+msgid ""
+"The `number` variable will be bound to a value based on the outcome of the "
+"`if` expression. Run this code to see what happens:"
+msgstr ""
+
+#: src/ch03-05-control-flow.md:200
+msgid ""
+"```console\n"
+"$ cargo run\n"
+" Compiling branches v0.1.0 (file:///projects/branches)\n"
+" Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.30s\n"
+" Running `target/debug/branches`\n"
+"The value of number is: 5\n"
+"```"
+msgstr ""
+
+#: src/ch03-05-control-flow.md:208
+msgid ""
+"Remember that blocks of code evaluate to the last expression in them, and "
+"numbers by themselves are also expressions. In this case, the value of the "
+"whole `if` expression depends on which block of code executes. This means "
+"the values that have the potential to be results from each arm of the `if` "
+"must be the same type; in Listing 3-2, the results of both the `if` arm and "
+"the `else` arm were `i32` integers. If the types are mismatched, as in the "
+"following example, we’ll get an error:"
+msgstr ""
+
+#: src/ch03-05-control-flow.md:222
+msgid "\"six\""
+msgstr ""
+
+#: src/ch03-05-control-flow.md:228
+msgid ""
+"When we try to compile this code, we’ll get an error. The `if` and `else` "
+"arms have value types that are incompatible, and Rust indicates exactly "
+"where to find the problem in the program:"
+msgstr ""
+
+#: src/ch03-05-control-flow.md:232
+msgid ""
+"```console\n"
+"$ cargo run\n"
+" Compiling branches v0.1.0 (file:///projects/branches)\n"
+"error[E0308]: `if` and `else` have incompatible types\n"
+" --> src/main.rs:4:44\n"
+" |\n"
+"4 | let number = if condition { 5 } else { \"six\" };\n"
+" | - ^^^^^ expected integer, found "
+"`&str`\n"
+" | |\n"
+" | expected because of this\n"
+"\n"
+"For more information about this error, try `rustc --explain E0308`.\n"
+"error: could not compile `branches` (bin \"branches\") due to 1 previous "
+"error\n"
+"```"
+msgstr ""
+
+#: src/ch03-05-control-flow.md:247
+msgid ""
+"The expression in the `if` block evaluates to an integer, and the expression "
+"in the `else` block evaluates to a string. This won’t work because variables "
+"must have a single type, and Rust needs to know at compile time what type "
+"the `number` variable is, definitively. Knowing the type of `number` lets "
+"the compiler verify the type is valid everywhere we use `number`. Rust "
+"wouldn’t be able to do that if the type of `number` was only determined at "
+"runtime; the compiler would be more complex and would make fewer guarantees "
+"about the code if it had to keep track of multiple hypothetical types for "
+"any variable."
+msgstr ""
+
+#: src/ch03-05-control-flow.md:256
+msgid "Repetition with Loops"
+msgstr ""
+
+#: src/ch03-05-control-flow.md:258
+msgid ""
+"It’s often useful to execute a block of code more than once. For this task, "
+"Rust provides several _loops_, which will run through the code inside the "
+"loop body to the end and then start immediately back at the beginning. To "
+"experiment with loops, let’s make a new project called _loops_."
+msgstr ""
+
+#: src/ch03-05-control-flow.md:263
+msgid ""
+"Rust has three kinds of loops: `loop`, `while`, and `for`. Let’s try each "
+"one."
+msgstr ""
+
+#: src/ch03-05-control-flow.md:265
+msgid "Repeating Code with `loop`"
+msgstr ""
+
+#: src/ch03-05-control-flow.md:267
+msgid ""
+"The `loop` keyword tells Rust to execute a block of code over and over again "
+"forever or until you explicitly tell it to stop."
+msgstr ""
+
+#: src/ch03-05-control-flow.md:270
+msgid ""
+"As an example, change the _src/main.rs_ file in your _loops_ directory to "
+"look like this:"
+msgstr ""
+
+#: src/ch03-05-control-flow.md:278
+msgid "\"again!\""
+msgstr ""
+
+#: src/ch03-05-control-flow.md:283
+msgid ""
+"When we run this program, we’ll see `again!` printed over and over "
+"continuously until we stop the program manually. Most terminals support the "
+"keyboard shortcut ctrl\\-c to interrupt a program that "
+"is stuck in a continual loop. Give it a try:"
+msgstr ""
+
+#: src/ch03-05-control-flow.md:294
+msgid ""
+"```console\n"
+"$ cargo run\n"
+" Compiling loops v0.1.0 (file:///projects/loops)\n"
+" Finished dev [unoptimized + debuginfo] target(s) in 0.29s\n"
+" Running `target/debug/loops`\n"
+"again!\n"
+"again!\n"
+"again!\n"
+"again!\n"
+"^Cagain!\n"
+"```"
+msgstr ""
+
+#: src/ch03-05-control-flow.md:306
+msgid ""
+"The symbol `^C` represents where you pressed ctrl\\-c. "
+"You may or may not see the word `again!` printed after the `^C`, depending "
+"on where the code was in the loop when it received the interrupt signal."
+msgstr ""
+
+#: src/ch03-05-control-flow.md:310
+msgid ""
+"Fortunately, Rust also provides a way to break out of a loop using code. You "
+"can place the `break` keyword within the loop to tell the program when to "
+"stop executing the loop. Recall that we did this in the guessing game in the "
+"[“Quitting After a Correct Guess”](ch02-00-guessing-game-tutorial."
+"html#quitting-after-a-correct-guess) section of Chapter 2 to exit the program when the user won the game by "
+"guessing the correct number."
+msgstr ""
+
+#: src/ch03-05-control-flow.md:317
+msgid ""
+"We also used `continue` in the guessing game, which in a loop tells the "
+"program to skip over any remaining code in this iteration of the loop and go "
+"to the next iteration."
+msgstr ""
+
+#: src/ch03-05-control-flow.md:321
+msgid "Returning Values from Loops"
+msgstr ""
+
+#: src/ch03-05-control-flow.md:323
+msgid ""
+"One of the uses of a `loop` is to retry an operation you know might fail, "
+"such as checking whether a thread has completed its job. You might also need "
+"to pass the result of that operation out of the loop to the rest of your "
+"code. To do this, you can add the value you want returned after the `break` "
+"expression you use to stop the loop; that value will be returned out of the "
+"loop so you can use it, as shown here:"
+msgstr ""
+
+#: src/ch03-05-control-flow.md:342
+msgid "\"The result is {result}\""
+msgstr ""
+
+#: src/ch03-05-control-flow.md:346
+msgid ""
+"Before the loop, we declare a variable named `counter` and initialize it to "
+"`0`. Then we declare a variable named `result` to hold the value returned "
+"from the loop. On every iteration of the loop, we add `1` to the `counter` "
+"variable, and then check whether the `counter` is equal to `10`. When it is, "
+"we use the `break` keyword with the value `counter * 2`. After the loop, we "
+"use a semicolon to end the statement that assigns the value to `result`. "
+"Finally, we print the value in `result`, which in this case is `20`."
+msgstr ""
+
+#: src/ch03-05-control-flow.md:354
+msgid ""
+"You can also `return` from inside a loop. While `break` only exits the "
+"current loop, `return` always exits the current function."
+msgstr ""
+
+#: src/ch03-05-control-flow.md:357
+msgid "Loop Labels to Disambiguate Between Multiple Loops"
+msgstr ""
+
+#: src/ch03-05-control-flow.md:359
+msgid ""
+"If you have loops within loops, `break` and `continue` apply to the "
+"innermost loop at that point. You can optionally specify a _loop label_ on a "
+"loop that you can then use with `break` or `continue` to specify that those "
+"keywords apply to the labeled loop instead of the innermost loop. Loop "
+"labels must begin with a single quote. Here’s an example with two nested "
+"loops:"
+msgstr ""
+
+#: src/ch03-05-control-flow.md:369
+msgid "\"count = {count}\""
+msgstr ""
+
+#: src/ch03-05-control-flow.md:373
+msgid "\"remaining = {remaining}\""
+msgstr ""
+
+#: src/ch03-05-control-flow.md:385
+msgid "\"End count = {count}\""
+msgstr ""
+
+#: src/ch03-05-control-flow.md:389
+msgid ""
+"The outer loop has the label `'counting_up`, and it will count up from 0 to "
+"2. The inner loop without a label counts down from 10 to 9. The first "
+"`break` that doesn’t specify a label will exit the inner loop only. The "
+"`break 'counting_up;` statement will exit the outer loop. This code prints:"
+msgstr ""
+
+#: src/ch03-05-control-flow.md:394
+msgid ""
+"```console\n"
+"$ cargo run\n"
+" Compiling loops v0.1.0 (file:///projects/loops)\n"
+" Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.58s\n"
+" Running `target/debug/loops`\n"
+"count = 0\n"
+"remaining = 10\n"
+"remaining = 9\n"
+"count = 1\n"
+"remaining = 10\n"
+"remaining = 9\n"
+"count = 2\n"
+"remaining = 10\n"
+"End count = 2\n"
+"```"
+msgstr ""
+
+#: src/ch03-05-control-flow.md:410
+msgid "Conditional Loops with `while`"
+msgstr ""
+
+#: src/ch03-05-control-flow.md:412
+msgid ""
+"A program will often need to evaluate a condition within a loop. While the "
+"condition is `true`, the loop runs. When the condition ceases to be `true`, "
+"the program calls `break`, stopping the loop. It’s possible to implement "
+"behavior like this using a combination of `loop`, `if`, `else`, and `break`; "
+"you could try that now in a program, if you’d like. However, this pattern is "
+"so common that Rust has a built-in language construct for it, called a "
+"`while` loop. In Listing 3-3, we use `while` to loop the program three "
+"times, counting down each time, and then, after the loop, print a message "
+"and exit."
+msgstr ""
+
+#: src/ch03-05-control-flow.md:428 src/ch03-05-control-flow.md:536
+msgid "\"{number}!\""
+msgstr ""
+
+#: src/ch03-05-control-flow.md:433 src/ch03-05-control-flow.md:538
+msgid "\"LIFTOFF!!!\""
+msgstr ""
+
+#: src/ch03-05-control-flow.md:439
+msgid ""
+"This construct eliminates a lot of nesting that would be necessary if you "
+"used `loop`, `if`, `else`, and `break`, and it’s clearer. While a condition "
+"evaluates to `true`, the code runs; otherwise, it exits the loop."
+msgstr ""
+
+#: src/ch03-05-control-flow.md:443
+msgid "Looping Through a Collection with `for`"
+msgstr ""
+
+#: src/ch03-05-control-flow.md:445
+msgid ""
+"You can also use the `while` construct to loop over the elements of a "
+"collection, such as an array. For example, the loop in Listing 3-4 prints "
+"each element in the array `a`."
+msgstr ""
+
+#: src/ch03-05-control-flow.md:457
+msgid "\"the value is: {}\""
+msgstr ""
+
+#: src/ch03-05-control-flow.md:466
+msgid ""
+"Here, the code counts up through the elements in the array. It starts at "
+"index `0`, and then loops until it reaches the final index in the array "
+"(that is, when `index < 5` is no longer `true`). Running this code will "
+"print every element in the array:"
+msgstr ""
+
+#: src/ch03-05-control-flow.md:471
+msgid ""
+"```console\n"
+"$ cargo run\n"
+" Compiling loops v0.1.0 (file:///projects/loops)\n"
+" Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.32s\n"
+" Running `target/debug/loops`\n"
+"the value is: 10\n"
+"the value is: 20\n"
+"the value is: 30\n"
+"the value is: 40\n"
+"the value is: 50\n"
+"```"
+msgstr ""
+
+#: src/ch03-05-control-flow.md:483
+msgid ""
+"All five array values appear in the terminal, as expected. Even though "
+"`index` will reach a value of `5` at some point, the loop stops executing "
+"before trying to fetch a sixth value from the array."
+msgstr ""
+
+#: src/ch03-05-control-flow.md:487
+msgid ""
+"However, this approach is error prone; we could cause the program to panic "
+"if the index value or test condition is incorrect. For example, if you "
+"changed the definition of the `a` array to have four elements but forgot to "
+"update the condition to `while index < 4`, the code would panic. It’s also "
+"slow, because the compiler adds runtime code to perform the conditional "
+"check of whether the index is within the bounds of the array on every "
+"iteration through the loop."
+msgstr ""
+
+#: src/ch03-05-control-flow.md:494
+msgid ""
+"As a more concise alternative, you can use a `for` loop and execute some "
+"code for each item in a collection. A `for` loop looks like the code in "
+"Listing 3-5."
+msgstr ""
+
+#: src/ch03-05-control-flow.md:504
+msgid "\"the value is: {element}\""
+msgstr ""
+
+#: src/ch03-05-control-flow.md:511
+msgid ""
+"When we run this code, we’ll see the same output as in Listing 3-4. More "
+"importantly, we’ve now increased the safety of the code and eliminated the "
+"chance of bugs that might result from going beyond the end of the array or "
+"not going far enough and missing some items."
+msgstr ""
+
+#: src/ch03-05-control-flow.md:516
+msgid ""
+"Using the `for` loop, you wouldn’t need to remember to change any other code "
+"if you changed the number of values in the array, as you would with the "
+"method used in Listing 3-4."
+msgstr ""
+
+#: src/ch03-05-control-flow.md:520
+msgid ""
+"The safety and conciseness of `for` loops make them the most commonly used "
+"loop construct in Rust. Even in situations in which you want to run some "
+"code a certain number of times, as in the countdown example that used a "
+"`while` loop in Listing 3-3, most Rustaceans would use a `for` loop. The way "
+"to do that would be to use a `Range`, provided by the standard library, "
+"which generates all numbers in sequence starting from one number and ending "
+"before another number."
+msgstr ""
+
+#: src/ch03-05-control-flow.md:528
+msgid ""
+"Here’s what the countdown would look like using a `for` loop and another "
+"method we’ve not yet talked about, `rev`, to reverse the range:"
+msgstr ""
+
+#: src/ch03-05-control-flow.md:542
+msgid "This code is a bit nicer, isn’t it?"
+msgstr ""
+
+#: src/ch03-05-control-flow.md:546
+msgid ""
+"You made it! This was a sizable chapter: you learned about variables, scalar "
+"and compound data types, functions, comments, `if` expressions, and loops! "
+"To practice with the concepts discussed in this chapter, try building "
+"programs to do the following:"
+msgstr ""
+
+#: src/ch03-05-control-flow.md:551
+msgid "Convert temperatures between Fahrenheit and Celsius."
+msgstr ""
+
+#: src/ch03-05-control-flow.md:552
+msgid "Generate the _n_th Fibonacci number."
+msgstr ""
+
+#: src/ch03-05-control-flow.md:553
+msgid ""
+"Print the lyrics to the Christmas carol “The Twelve Days of Christmas,” "
+"taking advantage of the repetition in the song."
+msgstr ""
+
+#: src/ch03-05-control-flow.md:556
+msgid ""
+"When you’re ready to move on, we’ll talk about a concept in Rust that "
+"_doesn’t_ commonly exist in other programming languages: ownership."
+msgstr ""
+
+#: src/ch04-00-understanding-ownership.md:3
+msgid ""
+"Ownership is Rust’s most unique feature and has deep implications for the "
+"rest of the language. It enables Rust to make memory safety guarantees "
+"without needing a garbage collector, so it’s important to understand how "
+"ownership works. In this chapter, we’ll talk about ownership as well as "
+"several related features: borrowing, slices, and how Rust lays data out in "
+"memory."
+msgstr ""
+
+#: src/ch04-01-what-is-ownership.md:1
+msgid "What Is Ownership?"
+msgstr ""
+
+#: src/ch04-01-what-is-ownership.md:3
+msgid ""
+"_Ownership_ is a set of rules that govern how a Rust program manages memory. "
+"All programs have to manage the way they use a computer’s memory while "
+"running. Some languages have garbage collection that regularly looks for no-"
+"longer-used memory as the program runs; in other languages, the programmer "
+"must explicitly allocate and free the memory. Rust uses a third approach: "
+"memory is managed through a system of ownership with a set of rules that the "
+"compiler checks. If any of the rules are violated, the program won’t "
+"compile. None of the features of ownership will slow down your program while "
+"it’s running."
+msgstr ""
+
+#: src/ch04-01-what-is-ownership.md:12
+msgid ""
+"Because ownership is a new concept for many programmers, it does take some "
+"time to get used to. The good news is that the more experienced you become "
+"with Rust and the rules of the ownership system, the easier you’ll find it "
+"to naturally develop code that is safe and efficient. Keep at it!"
+msgstr ""
+
+#: src/ch04-01-what-is-ownership.md:17
+msgid ""
+"When you understand ownership, you’ll have a solid foundation for "
+"understanding the features that make Rust unique. In this chapter, you’ll "
+"learn ownership by working through some examples that focus on a very common "
+"data structure: strings."
+msgstr ""
+
+#: src/ch04-01-what-is-ownership.md:22
+msgid "The Stack and the Heap"
+msgstr ""
+
+#: src/ch04-01-what-is-ownership.md:24
+msgid ""
+"Many programming languages don’t require you to think about the stack and "
+"the heap very often. But in a systems programming language like Rust, "
+"whether a value is on the stack or the heap affects how the language behaves "
+"and why you have to make certain decisions. Parts of ownership will be "
+"described in relation to the stack and the heap later in this chapter, so "
+"here is a brief explanation in preparation."
+msgstr ""
+
+#: src/ch04-01-what-is-ownership.md:31
+msgid ""
+"Both the stack and the heap are parts of memory available to your code to "
+"use at runtime, but they are structured in different ways. The stack stores "
+"values in the order it gets them and removes the values in the opposite "
+"order. This is referred to as _last in, first out_. Think of a stack of "
+"plates: when you add more plates, you put them on top of the pile, and when "
+"you need a plate, you take one off the top. Adding or removing plates from "
+"the middle or bottom wouldn’t work as well! Adding data is called _pushing "
+"onto the stack_, and removing data is called _popping off the stack_. All "
+"data stored on the stack must have a known, fixed size. Data with an unknown "
+"size at compile time or a size that might change must be stored on the heap "
+"instead."
+msgstr ""
+
+#: src/ch04-01-what-is-ownership.md:43
+msgid ""
+"The heap is less organized: when you put data on the heap, you request a "
+"certain amount of space. The memory allocator finds an empty spot in the "
+"heap that is big enough, marks it as being in use, and returns a _pointer_, "
+"which is the address of that location. This process is called _allocating on "
+"the heap_ and is sometimes abbreviated as just _allocating_ (pushing values "
+"onto the stack is not considered allocating). Because the pointer to the "
+"heap is a known, fixed size, you can store the pointer on the stack, but "
+"when you want the actual data, you must follow the pointer. Think of being "
+"seated at a restaurant. When you enter, you state the number of people in "
+"your group, and the host finds an empty table that fits everyone and leads "
+"you there. If someone in your group comes late, they can ask where you’ve "
+"been seated to find you."
+msgstr ""
+
+#: src/ch04-01-what-is-ownership.md:56
+msgid ""
+"Pushing to the stack is faster than allocating on the heap because the "
+"allocator never has to search for a place to store new data; that location "
+"is always at the top of the stack. Comparatively, allocating space on the "
+"heap requires more work because the allocator must first find a big enough "
+"space to hold the data and then perform bookkeeping to prepare for the next "
+"allocation."
+msgstr ""
+
+#: src/ch04-01-what-is-ownership.md:63
+msgid ""
+"Accessing data in the heap is slower than accessing data on the stack "
+"because you have to follow a pointer to get there. Contemporary processors "
+"are faster if they jump around less in memory. Continuing the analogy, "
+"consider a server at a restaurant taking orders from many tables. It’s most "
+"efficient to get all the orders at one table before moving on to the next "
+"table. Taking an order from table A, then an order from table B, then one "
+"from A again, and then one from B again would be a much slower process. By "
+"the same token, a processor can do its job better if it works on data that’s "
+"close to other data (as it is on the stack) rather than farther away (as it "
+"can be on the heap)."
+msgstr ""
+
+#: src/ch04-01-what-is-ownership.md:74
+msgid ""
+"When your code calls a function, the values passed into the function "
+"(including, potentially, pointers to data on the heap) and the function’s "
+"local variables get pushed onto the stack. When the function is over, those "
+"values get popped off the stack."
+msgstr ""
+
+#: src/ch04-01-what-is-ownership.md:79
+msgid ""
+"Keeping track of what parts of code are using what data on the heap, "
+"minimizing the amount of duplicate data on the heap, and cleaning up unused "
+"data on the heap so you don’t run out of space are all problems that "
+"ownership addresses. Once you understand ownership, you won’t need to think "
+"about the stack and the heap very often, but knowing that the main purpose "
+"of ownership is to manage heap data can help explain why it works the way it "
+"does."
+msgstr ""
+
+#: src/ch04-01-what-is-ownership.md:86
+msgid "Ownership Rules"
+msgstr ""
+
+#: src/ch04-01-what-is-ownership.md:88
+msgid ""
+"First, let’s take a look at the ownership rules. Keep these rules in mind as "
+"we work through the examples that illustrate them:"
+msgstr ""
+
+#: src/ch04-01-what-is-ownership.md:91
+msgid "Each value in Rust has an _owner_."
+msgstr ""
+
+#: src/ch04-01-what-is-ownership.md:92
+msgid "There can only be one owner at a time."
+msgstr ""
+
+#: src/ch04-01-what-is-ownership.md:93
+msgid "When the owner goes out of scope, the value will be dropped."
+msgstr ""
+
+#: src/ch04-01-what-is-ownership.md:95
+msgid "Variable Scope"
+msgstr ""
+
+#: src/ch04-01-what-is-ownership.md:97
+msgid ""
+"Now that we’re past basic Rust syntax, we won’t include all the `fn main() "
+"{` code in examples, so if you’re following along, make sure to put the "
+"following examples inside a `main` function manually. As a result, our "
+"examples will be a bit more concise, letting us focus on the actual details "
+"rather than boilerplate code."
+msgstr ""
+
+#: src/ch04-01-what-is-ownership.md:103
+msgid ""
+"As a first example of ownership, we’ll look at the _scope_ of some "
+"variables. A scope is the range within a program for which an item is valid. "
+"Take the following variable:"
+msgstr ""
+
+#: src/ch04-01-what-is-ownership.md:108 src/ch04-01-what-is-ownership.md:119
+#: src/ch04-01-what-is-ownership.md:165 src/ch04-01-what-is-ownership.md:179
+#: src/ch04-01-what-is-ownership.md:228 src/ch04-01-what-is-ownership.md:281
+#: src/ch04-01-what-is-ownership.md:350 src/ch04-01-what-is-ownership.md:421
+#: src/ch04-01-what-is-ownership.md:496 src/ch04-01-what-is-ownership.md:541
+#: src/ch04-01-what-is-ownership.md:588
+#: src/ch04-02-references-and-borrowing.md:19
+#: src/ch04-02-references-and-borrowing.md:53
+#: src/ch04-02-references-and-borrowing.md:74
+#: src/ch04-02-references-and-borrowing.md:105
+#: src/ch04-02-references-and-borrowing.md:149
+#: src/ch04-02-references-and-borrowing.md:172
+#: src/ch04-02-references-and-borrowing.md:227
+#: src/ch04-02-references-and-borrowing.md:242
+#: src/ch04-02-references-and-borrowing.md:288
+#: src/ch04-02-references-and-borrowing.md:332
+#: src/ch04-02-references-and-borrowing.md:392
+#: src/ch04-02-references-and-borrowing.md:412 src/ch04-03-slices.md:213
+#: src/ch04-03-slices.md:223 src/ch04-03-slices.md:235
+#: src/ch06-01-defining-an-enum.md:295 src/ch08-02-strings.md:270
+#: src/ch13-01-closures.md:241 src/ch19-03-advanced-traits.md:795
+#: src/ch19-04-advanced-types.md:277
+msgid "\"hello\""
+msgstr ""
+
+#: src/ch04-01-what-is-ownership.md:111
+msgid ""
+"The variable `s` refers to a string literal, where the value of the string "
+"is hardcoded into the text of our program. The variable is valid from the "
+"point at which it’s declared until the end of the current _scope_. Listing "
+"4-1 shows a program with comments annotating where the variable `s` would be "
+"valid."
+msgstr ""
+
+#: src/ch04-01-what-is-ownership.md:118
+msgid "// s is not valid here, it’s not yet declared\n"
+msgstr ""
+
+#: src/ch04-01-what-is-ownership.md:119 src/ch04-01-what-is-ownership.md:228
+msgid "// s is valid from this point forward\n"
+msgstr ""
+
+#: src/ch04-01-what-is-ownership.md:121 src/ch04-01-what-is-ownership.md:230
+msgid "// do stuff with s\n"
+msgstr ""
+
+#: src/ch04-01-what-is-ownership.md:122
+msgid "// this scope is now over, and s is no longer valid\n"
+msgstr ""
+
+#: src/ch04-01-what-is-ownership.md:126
+msgid ""
+"Listing 4-1: A variable and the scope in which it is "
+"valid"
+msgstr ""
+
+#: src/ch04-01-what-is-ownership.md:129
+msgid "In other words, there are two important points in time here:"
+msgstr ""
+
+#: src/ch04-01-what-is-ownership.md:131
+msgid "When `s` comes _into_ scope, it is valid."
+msgstr ""
+
+#: src/ch04-01-what-is-ownership.md:132
+msgid "It remains valid until it goes _out of_ scope."
+msgstr ""
+
+#: src/ch04-01-what-is-ownership.md:134
+msgid ""
+"At this point, the relationship between scopes and when variables are valid "
+"is similar to that in other programming languages. Now we’ll build on top of "
+"this understanding by introducing the `String` type."
+msgstr ""
+
+#: src/ch04-01-what-is-ownership.md:138
+msgid "The `String` Type"
+msgstr ""
+
+#: src/ch04-01-what-is-ownership.md:140
+msgid ""
+"To illustrate the rules of ownership, we need a data type that is more "
+"complex than those we covered in the [“Data Types”](ch03-02-data-types."
+"html#data-types) section of Chapter 3. The types covered "
+"previously are of a known size, can be stored on the stack and popped off "
+"the stack when their scope is over, and can be quickly and trivially copied "
+"to make a new, independent instance if another part of code needs to use the "
+"same value in a different scope. But we want to look at data that is stored "
+"on the heap and explore how Rust knows when to clean up that data, and the "
+"`String` type is a great example."
+msgstr ""
+
+#: src/ch04-01-what-is-ownership.md:149
+msgid ""
+"We’ll concentrate on the parts of `String` that relate to ownership. These "
+"aspects also apply to other complex data types, whether they are provided by "
+"the standard library or created by you. We’ll discuss `String` in more depth "
+"in [Chapter 8](ch08-02-strings.html)."
+msgstr ""
+
+#: src/ch04-01-what-is-ownership.md:154
+msgid ""
+"We’ve already seen string literals, where a string value is hardcoded into "
+"our program. String literals are convenient, but they aren’t suitable for "
+"every situation in which we may want to use text. One reason is that they’re "
+"immutable. Another is that not every string value can be known when we write "
+"our code: for example, what if we want to take user input and store it? For "
+"these situations, Rust has a second string type, `String`. This type manages "
+"data allocated on the heap and as such is able to store an amount of text "
+"that is unknown to us at compile time. You can create a `String` from a "
+"string literal using the `from` function, like so:"
+msgstr ""
+
+#: src/ch04-01-what-is-ownership.md:168
+msgid ""
+"The double colon `::` operator allows us to namespace this particular `from` "
+"function under the `String` type rather than using some sort of name like "
+"`string_from`. We’ll discuss this syntax more in the [“Method Syntax”]"
+"(ch05-03-method-syntax.html#method-syntax) section of Chapter "
+"5, and when we talk about namespacing with modules in [“Paths for Referring "
+"to an Item in the Module Tree”](ch07-03-paths-for-referring-to-an-item-in-"
+"the-module-tree.html) in Chapter 7."
+msgstr ""
+
+#: src/ch04-01-what-is-ownership.md:175
+msgid "This kind of string _can_ be mutated:"
+msgstr ""
+
+#: src/ch04-01-what-is-ownership.md:181
+msgid "\", world!\""
+msgstr ""
+
+#: src/ch04-01-what-is-ownership.md:181
+msgid "// push_str() appends a literal to a String\n"
+msgstr ""
+
+#: src/ch04-01-what-is-ownership.md:183
+msgid "\"{s}\""
+msgstr ""
+
+#: src/ch04-01-what-is-ownership.md:183
+msgid "// This will print `hello, world!`\n"
+msgstr ""
+
+#: src/ch04-01-what-is-ownership.md:187
+msgid ""
+"So, what’s the difference here? Why can `String` be mutated but literals "
+"cannot? The difference is in how these two types deal with memory."
+msgstr ""
+
+#: src/ch04-01-what-is-ownership.md:190
+msgid "Memory and Allocation"
+msgstr ""
+
+#: src/ch04-01-what-is-ownership.md:192
+msgid ""
+"In the case of a string literal, we know the contents at compile time, so "
+"the text is hardcoded directly into the final executable. This is why string "
+"literals are fast and efficient. But these properties only come from the "
+"string literal’s immutability. Unfortunately, we can’t put a blob of memory "
+"into the binary for each piece of text whose size is unknown at compile time "
+"and whose size might change while running the program."
+msgstr ""
+
+#: src/ch04-01-what-is-ownership.md:199
+msgid ""
+"With the `String` type, in order to support a mutable, growable piece of "
+"text, we need to allocate an amount of memory on the heap, unknown at "
+"compile time, to hold the contents. This means:"
+msgstr ""
+
+#: src/ch04-01-what-is-ownership.md:203
+msgid "The memory must be requested from the memory allocator at runtime."
+msgstr ""
+
+#: src/ch04-01-what-is-ownership.md:204
+msgid ""
+"We need a way of returning this memory to the allocator when we’re done with "
+"our `String`."
+msgstr ""
+
+#: src/ch04-01-what-is-ownership.md:207
+msgid ""
+"That first part is done by us: when we call `String::from`, its "
+"implementation requests the memory it needs. This is pretty much universal "
+"in programming languages."
+msgstr ""
+
+#: src/ch04-01-what-is-ownership.md:211
+msgid ""
+"However, the second part is different. In languages with a _garbage "
+"collector (GC)_, the GC keeps track of and cleans up memory that isn’t being "
+"used anymore, and we don’t need to think about it. In most languages without "
+"a GC, it’s our responsibility to identify when memory is no longer being "
+"used and to call code to explicitly free it, just as we did to request it. "
+"Doing this correctly has historically been a difficult programming problem. "
+"If we forget, we’ll waste memory. If we do it too early, we’ll have an "
+"invalid variable. If we do it twice, that’s a bug too. We need to pair "
+"exactly one `allocate` with exactly one `free`."
+msgstr ""
+
+#: src/ch04-01-what-is-ownership.md:221
+msgid ""
+"Rust takes a different path: the memory is automatically returned once the "
+"variable that owns it goes out of scope. Here’s a version of our scope "
+"example from Listing 4-1 using a `String` instead of a string literal:"
+msgstr ""
+
+#: src/ch04-01-what-is-ownership.md:231
+msgid ""
+"// this scope is now over, and s is no\n"
+" // longer valid\n"
+msgstr ""
+
+#: src/ch04-01-what-is-ownership.md:236
+msgid ""
+"There is a natural point at which we can return the memory our `String` "
+"needs to the allocator: when `s` goes out of scope. When a variable goes out "
+"of scope, Rust calls a special function for us. This function is called "
+"[`drop`](../std/ops/trait.Drop.html#tymethod.drop), and it’s "
+"where the author of `String` can put the code to return the memory. Rust "
+"calls `drop` automatically at the closing curly bracket."
+msgstr ""
+
+#: src/ch04-01-what-is-ownership.md:243
+msgid ""
+"Note: In C++, this pattern of deallocating resources at the end of an item’s "
+"lifetime is sometimes called _Resource Acquisition Is Initialization "
+"(RAII)_. The `drop` function in Rust will be familiar to you if you’ve used "
+"RAII patterns."
+msgstr ""
+
+#: src/ch04-01-what-is-ownership.md:248
+msgid ""
+"This pattern has a profound impact on the way Rust code is written. It may "
+"seem simple right now, but the behavior of code can be unexpected in more "
+"complicated situations when we want to have multiple variables use the data "
+"we’ve allocated on the heap. Let’s explore some of those situations now."
+msgstr ""
+
+#: src/ch04-01-what-is-ownership.md:254
+msgid ""
+msgstr ""
+
+#: src/ch04-01-what-is-ownership.md:256
+msgid "Variables and Data Interacting with Move"
+msgstr ""
+
+#: src/ch04-01-what-is-ownership.md:258
+msgid ""
+"Multiple variables can interact with the same data in different ways in "
+"Rust. Let’s look at an example using an integer in Listing 4-2."
+msgstr ""
+
+#: src/ch04-01-what-is-ownership.md:268
+msgid ""
+"Listing 4-2: Assigning the integer value of variable "
+"`x` to `y`"
+msgstr ""
+
+#: src/ch04-01-what-is-ownership.md:271
+msgid ""
+"We can probably guess what this is doing: “bind the value `5` to `x`; then "
+"make a copy of the value in `x` and bind it to `y`.” We now have two "
+"variables, `x` and `y`, and both equal `5`. This is indeed what is "
+"happening, because integers are simple values with a known, fixed size, and "
+"these two `5` values are pushed onto the stack."
+msgstr ""
+
+#: src/ch04-01-what-is-ownership.md:277
+msgid "Now let’s look at the `String` version:"
+msgstr ""
+
+#: src/ch04-01-what-is-ownership.md:286
+msgid ""
+"This looks very similar, so we might assume that the way it works would be "
+"the same: that is, the second line would make a copy of the value in `s1` "
+"and bind it to `s2`. But this isn’t quite what happens."
+msgstr ""
+
+#: src/ch04-01-what-is-ownership.md:290
+msgid ""
+"Take a look at Figure 4-1 to see what is happening to `String` under the "
+"covers. A `String` is made up of three parts, shown on the left: a pointer "
+"to the memory that holds the contents of the string, a length, and a "
+"capacity. This group of data is stored on the stack. On the right is the "
+"memory on the heap that holds the contents."
+msgstr ""
+
+#: src/ch04-01-what-is-ownership.md:296
+msgid ""
+""
+msgstr ""
+
+#: src/ch04-01-what-is-ownership.md:302
+msgid ""
+"Figure 4-1: Representation in memory of a `String` "
+"holding the value `\"hello\"` bound to `s1`"
+msgstr ""
+
+#: src/ch04-01-what-is-ownership.md:305
+msgid ""
+"The length is how much memory, in bytes, the contents of the `String` are "
+"currently using. The capacity is the total amount of memory, in bytes, that "
+"the `String` has received from the allocator. The difference between length "
+"and capacity matters, but not in this context, so for now, it’s fine to "
+"ignore the capacity."
+msgstr ""
+
+#: src/ch04-01-what-is-ownership.md:311
+msgid ""
+"When we assign `s1` to `s2`, the `String` data is copied, meaning we copy "
+"the pointer, the length, and the capacity that are on the stack. We do not "
+"copy the data on the heap that the pointer refers to. In other words, the "
+"data representation in memory looks like Figure 4-2."
+msgstr ""
+
+#: src/ch04-01-what-is-ownership.md:316
+msgid ""
+""
+msgstr ""
+
+#: src/ch04-01-what-is-ownership.md:320
+msgid ""
+"Figure 4-2: Representation in memory of the variable "
+"`s2` that has a copy of the pointer, length, and capacity of `s1`"
+msgstr ""
+
+#: src/ch04-01-what-is-ownership.md:323
+msgid ""
+"The representation does _not_ look like Figure 4-3, which is what memory "
+"would look like if Rust instead copied the heap data as well. If Rust did "
+"this, the operation `s2 = s1` could be very expensive in terms of runtime "
+"performance if the data on the heap were large."
+msgstr ""
+
+#: src/ch04-01-what-is-ownership.md:328
+msgid ""
+""
+msgstr ""
+
+#: src/ch04-01-what-is-ownership.md:332
+msgid ""
+"Figure 4-3: Another possibility for what `s2 = s1` "
+"might do if Rust copied the heap data as well"
+msgstr ""
+
+#: src/ch04-01-what-is-ownership.md:335
+msgid ""
+"Earlier, we said that when a variable goes out of scope, Rust automatically "
+"calls the `drop` function and cleans up the heap memory for that variable. "
+"But Figure 4-2 shows both data pointers pointing to the same location. This "
+"is a problem: when `s2` and `s1` go out of scope, they will both try to free "
+"the same memory. This is known as a _double free_ error and is one of the "
+"memory safety bugs we mentioned previously. Freeing memory twice can lead to "
+"memory corruption, which can potentially lead to security vulnerabilities."
+msgstr ""
+
+#: src/ch04-01-what-is-ownership.md:343
+msgid ""
+"To ensure memory safety, after the line `let s2 = s1;`, Rust considers `s1` "
+"as no longer valid. Therefore, Rust doesn’t need to free anything when `s1` "
+"goes out of scope. Check out what happens when you try to use `s1` after "
+"`s2` is created; it won’t work:"
+msgstr ""
+
+#: src/ch04-01-what-is-ownership.md:353
+msgid "\"{s1}, world!\""
+msgstr ""
+
+#: src/ch04-01-what-is-ownership.md:357
+msgid ""
+"You’ll get an error like this because Rust prevents you from using the "
+"invalidated reference:"
+msgstr ""
+
+#: src/ch04-01-what-is-ownership.md:360
+msgid ""
+"```console\n"
+"$ cargo run\n"
+" Compiling ownership v0.1.0 (file:///projects/ownership)\n"
+"error[E0382]: borrow of moved value: `s1`\n"
+" --> src/main.rs:5:15\n"
+" |\n"
+"2 | let s1 = String::from(\"hello\");\n"
+" | -- move occurs because `s1` has type `String`, which does not "
+"implement the `Copy` trait\n"
+"3 | let s2 = s1;\n"
+" | -- value moved here\n"
+"4 |\n"
+"5 | println!(\"{s1}, world!\");\n"
+" | ^^^^ value borrowed here after move\n"
+" |\n"
+" = note: this error originates in the macro `$crate::format_args_nl` which "
+"comes from the expansion of the macro `println` (in Nightly builds, run with "
+"-Z macro-backtrace for more info)\n"
+"help: consider cloning the value if the performance cost is acceptable\n"
+" |\n"
+"3 | let s2 = s1.clone();\n"
+" | ++++++++\n"
+"\n"
+"For more information about this error, try `rustc --explain E0382`.\n"
+"error: could not compile `ownership` (bin \"ownership\") due to 1 previous "
+"error\n"
+"```"
+msgstr ""
+
+#: src/ch04-01-what-is-ownership.md:384
+msgid ""
+"If you’ve heard the terms _shallow copy_ and _deep copy_ while working with "
+"other languages, the concept of copying the pointer, length, and capacity "
+"without copying the data probably sounds like making a shallow copy. But "
+"because Rust also invalidates the first variable, instead of being called a "
+"shallow copy, it’s known as a _move_. In this example, we would say that "
+"`s1` was _moved_ into `s2`. So, what actually happens is shown in Figure 4-4."
+msgstr ""
+
+#: src/ch04-01-what-is-ownership.md:391
+msgid ""
+""
+msgstr ""
+
+#: src/ch04-01-what-is-ownership.md:397
+msgid ""
+"Figure 4-4: Representation in memory after `s1` has "
+"been invalidated"
+msgstr ""
+
+#: src/ch04-01-what-is-ownership.md:400
+msgid ""
+"That solves our problem! With only `s2` valid, when it goes out of scope it "
+"alone will free the memory, and we’re done."
+msgstr ""
+
+#: src/ch04-01-what-is-ownership.md:403
+msgid ""
+"In addition, there’s a design choice that’s implied by this: Rust will never "
+"automatically create “deep” copies of your data. Therefore, any _automatic_ "
+"copying can be assumed to be inexpensive in terms of runtime performance."
+msgstr ""
+
+#: src/ch04-01-what-is-ownership.md:408
+msgid ""
+msgstr ""
+
+#: src/ch04-01-what-is-ownership.md:410
+msgid "Variables and Data Interacting with Clone"
+msgstr ""
+
+#: src/ch04-01-what-is-ownership.md:412
+msgid ""
+"If we _do_ want to deeply copy the heap data of the `String`, not just the "
+"stack data, we can use a common method called `clone`. We’ll discuss method "
+"syntax in Chapter 5, but because methods are a common feature in many "
+"programming languages, you’ve probably seen them before."
+msgstr ""
+
+#: src/ch04-01-what-is-ownership.md:417
+msgid "Here’s an example of the `clone` method in action:"
+msgstr ""
+
+#: src/ch04-01-what-is-ownership.md:424
+msgid "\"s1 = {s1}, s2 = {s2}\""
+msgstr ""
+
+#: src/ch04-01-what-is-ownership.md:428
+msgid ""
+"This works just fine and explicitly produces the behavior shown in Figure "
+"4-3, where the heap data _does_ get copied."
+msgstr ""
+
+#: src/ch04-01-what-is-ownership.md:431
+msgid ""
+"When you see a call to `clone`, you know that some arbitrary code is being "
+"executed and that code may be expensive. It’s a visual indicator that "
+"something different is going on."
+msgstr ""
+
+#: src/ch04-01-what-is-ownership.md:435
+msgid "Stack-Only Data: Copy"
+msgstr ""
+
+#: src/ch04-01-what-is-ownership.md:437
+msgid ""
+"There’s another wrinkle we haven’t talked about yet. This code using integers"
+"—part of which was shown in Listing 4-2—works and is valid:"
+msgstr ""
+
+#: src/ch04-01-what-is-ownership.md:445
+msgid "\"x = {x}, y = {y}\""
+msgstr ""
+
+#: src/ch04-01-what-is-ownership.md:449
+msgid ""
+"But this code seems to contradict what we just learned: we don’t have a call "
+"to `clone`, but `x` is still valid and wasn’t moved into `y`."
+msgstr ""
+
+#: src/ch04-01-what-is-ownership.md:452
+msgid ""
+"The reason is that types such as integers that have a known size at compile "
+"time are stored entirely on the stack, so copies of the actual values are "
+"quick to make. That means there’s no reason we would want to prevent `x` "
+"from being valid after we create the variable `y`. In other words, there’s "
+"no difference between deep and shallow copying here, so calling `clone` "
+"wouldn’t do anything different from the usual shallow copying, and we can "
+"leave it out."
+msgstr ""
+
+#: src/ch04-01-what-is-ownership.md:459
+msgid ""
+"Rust has a special annotation called the `Copy` trait that we can place on "
+"types that are stored on the stack, as integers are (we’ll talk more about "
+"traits in [Chapter 10](ch10-02-traits.html)). If a type "
+"implements the `Copy` trait, variables that use it do not move, but rather "
+"are trivially copied, making them still valid after assignment to another "
+"variable."
+msgstr ""
+
+#: src/ch04-01-what-is-ownership.md:465
+msgid ""
+"Rust won’t let us annotate a type with `Copy` if the type, or any of its "
+"parts, has implemented the `Drop` trait. If the type needs something special "
+"to happen when the value goes out of scope and we add the `Copy` annotation "
+"to that type, we’ll get a compile-time error. To learn about how to add the "
+"`Copy` annotation to your type to implement the trait, see [“Derivable "
+"Traits”](appendix-03-derivable-traits.html) in Appendix C."
+msgstr ""
+
+#: src/ch04-01-what-is-ownership.md:472
+msgid ""
+"So, what types implement the `Copy` trait? You can check the documentation "
+"for the given type to be sure, but as a general rule, any group of simple "
+"scalar values can implement `Copy`, and nothing that requires allocation or "
+"is some form of resource can implement `Copy`. Here are some of the types "
+"that implement `Copy`:"
+msgstr ""
+
+#: src/ch04-01-what-is-ownership.md:478
+msgid "All the integer types, such as `u32`."
+msgstr ""
+
+#: src/ch04-01-what-is-ownership.md:479
+msgid "The Boolean type, `bool`, with values `true` and `false`."
+msgstr ""
+
+#: src/ch04-01-what-is-ownership.md:480
+msgid "All the floating-point types, such as `f64`."
+msgstr ""
+
+#: src/ch04-01-what-is-ownership.md:481
+msgid "The character type, `char`."
+msgstr ""
+
+#: src/ch04-01-what-is-ownership.md:482
+msgid ""
+"Tuples, if they only contain types that also implement `Copy`. For example, "
+"`(i32, i32)` implements `Copy`, but `(i32, String)` does not."
+msgstr ""
+
+#: src/ch04-01-what-is-ownership.md:485
+msgid "Ownership and Functions"
+msgstr ""
+
+#: src/ch04-01-what-is-ownership.md:487
+msgid ""
+"The mechanics of passing a value to a function are similar to those when "
+"assigning a value to a variable. Passing a variable to a function will move "
+"or copy, just as assignment does. Listing 4-3 has an example with some "
+"annotations showing where variables go into and out of scope."
+msgstr ""
+
+#: src/ch04-01-what-is-ownership.md:496
+msgid "// s comes into scope\n"
+msgstr ""
+
+#: src/ch04-01-what-is-ownership.md:498
+msgid ""
+"// s's value moves into the function...\n"
+" // ... and so is no longer valid here\n"
+msgstr ""
+
+#: src/ch04-01-what-is-ownership.md:501
+msgid "// x comes into scope\n"
+msgstr ""
+
+#: src/ch04-01-what-is-ownership.md:503
+msgid ""
+"// x would move into the function,\n"
+" // but i32 is Copy, so it's okay to "
+"still\n"
+" // use x afterward\n"
+msgstr ""
+
+#: src/ch04-01-what-is-ownership.md:507
+msgid ""
+"// Here, x goes out of scope, then s. But because s's value was moved, "
+"nothing\n"
+" // special happens.\n"
+msgstr ""
+
+#: src/ch04-01-what-is-ownership.md:510 src/ch04-01-what-is-ownership.md:553
+msgid "// some_string comes into scope\n"
+msgstr ""
+
+#: src/ch04-01-what-is-ownership.md:511
+msgid "\"{some_string}\""
+msgstr ""
+
+#: src/ch04-01-what-is-ownership.md:512
+msgid ""
+"// Here, some_string goes out of scope and `drop` is called. The backing\n"
+" // memory is freed.\n"
+msgstr ""
+
+#: src/ch04-01-what-is-ownership.md:515
+msgid "// some_integer comes into scope\n"
+msgstr ""
+
+#: src/ch04-01-what-is-ownership.md:516
+msgid "\"{some_integer}\""
+msgstr ""
+
+#: src/ch04-01-what-is-ownership.md:517
+msgid "// Here, some_integer goes out of scope. Nothing special happens.\n"
+msgstr ""
+
+#: src/ch04-01-what-is-ownership.md:520
+msgid ""
+"Listing 4-3: Functions with ownership and scope "
+"annotated"
+msgstr ""
+
+#: src/ch04-01-what-is-ownership.md:523
+msgid ""
+"If we tried to use `s` after the call to `takes_ownership`, Rust would throw "
+"a compile-time error. These static checks protect us from mistakes. Try "
+"adding code to `main` that uses `s` and `x` to see where you can use them "
+"and where the ownership rules prevent you from doing so."
+msgstr ""
+
+#: src/ch04-01-what-is-ownership.md:528
+msgid "Return Values and Scope"
+msgstr ""
+
+#: src/ch04-01-what-is-ownership.md:530
+msgid ""
+"Returning values can also transfer ownership. Listing 4-4 shows an example "
+"of a function that returns some value, with similar annotations as those in "
+"Listing 4-3."
+msgstr ""
+
+#: src/ch04-01-what-is-ownership.md:538
+msgid ""
+"// gives_ownership moves its return\n"
+" // value into s1\n"
+msgstr ""
+
+#: src/ch04-01-what-is-ownership.md:541
+msgid "// s2 comes into scope\n"
+msgstr ""
+
+#: src/ch04-01-what-is-ownership.md:543
+msgid ""
+"// s2 is moved into\n"
+" // takes_and_gives_back, which also\n"
+" // moves its return value into s3\n"
+msgstr ""
+
+#: src/ch04-01-what-is-ownership.md:546
+msgid ""
+"// Here, s3 goes out of scope and is dropped. s2 was moved, so nothing\n"
+" // happens. s1 goes out of scope and is dropped.\n"
+msgstr ""
+
+#: src/ch04-01-what-is-ownership.md:549
+msgid ""
+"// gives_ownership will move its\n"
+" // return value into the "
+"function\n"
+" // that calls it\n"
+msgstr ""
+
+#: src/ch04-01-what-is-ownership.md:553
+msgid "\"yours\""
+msgstr ""
+
+#: src/ch04-01-what-is-ownership.md:555
+msgid ""
+"// some_string is returned and\n"
+" // moves out to the calling\n"
+" // function\n"
+msgstr ""
+
+#: src/ch04-01-what-is-ownership.md:559
+msgid "// This function takes a String and returns one\n"
+msgstr ""
+
+#: src/ch04-01-what-is-ownership.md:561
+msgid ""
+"// a_string comes into\n"
+" // scope\n"
+msgstr ""
+
+#: src/ch04-01-what-is-ownership.md:564
+msgid "// a_string is returned and moves out to the calling function\n"
+msgstr ""
+
+#: src/ch04-01-what-is-ownership.md:568
+msgid ""
+"Listing 4-4: Transferring ownership of return "
+"values"
+msgstr ""
+
+#: src/ch04-01-what-is-ownership.md:571
+msgid ""
+"The ownership of a variable follows the same pattern every time: assigning a "
+"value to another variable moves it. When a variable that includes data on "
+"the heap goes out of scope, the value will be cleaned up by `drop` unless "
+"ownership of the data has been moved to another variable."
+msgstr ""
+
+#: src/ch04-01-what-is-ownership.md:576
+msgid ""
+"While this works, taking ownership and then returning ownership with every "
+"function is a bit tedious. What if we want to let a function use a value but "
+"not take ownership? It’s quite annoying that anything we pass in also needs "
+"to be passed back if we want to use it again, in addition to any data "
+"resulting from the body of the function that we might want to return as well."
+msgstr ""
+
+#: src/ch04-01-what-is-ownership.md:582
+msgid ""
+"Rust does let us return multiple values using a tuple, as shown in Listing "
+"4-5."
+msgstr ""
+
+#: src/ch04-01-what-is-ownership.md:592
+msgid "\"The length of '{s2}' is {len}.\""
+msgstr ""
+
+#: src/ch04-01-what-is-ownership.md:596
+msgid "// len() returns the length of a String\n"
+msgstr ""
+
+#: src/ch04-01-what-is-ownership.md:602
+msgid ""
+"Listing 4-5: Returning ownership of parameters"
+msgstr ""
+
+#: src/ch04-01-what-is-ownership.md:604
+msgid ""
+"But this is too much ceremony and a lot of work for a concept that should be "
+"common. Luckily for us, Rust has a feature for using a value without "
+"transferring ownership, called _references_."
+msgstr ""
+
+#: src/ch04-02-references-and-borrowing.md:3
+msgid ""
+"The issue with the tuple code in Listing 4-5 is that we have to return the "
+"`String` to the calling function so we can still use the `String` after the "
+"call to `calculate_length`, because the `String` was moved into "
+"`calculate_length`. Instead, we can provide a reference to the `String` "
+"value. A _reference_ is like a pointer in that it’s an address we can follow "
+"to access the data stored at that address; that data is owned by some other "
+"variable. Unlike a pointer, a reference is guaranteed to point to a valid "
+"value of a particular type for the life of that reference."
+msgstr ""
+
+#: src/ch04-02-references-and-borrowing.md:12
+msgid ""
+"Here is how you would define and use a `calculate_length` function that has "
+"a reference to an object as a parameter instead of taking ownership of the "
+"value:"
+msgstr ""
+
+#: src/ch04-02-references-and-borrowing.md:23
+#: src/ch04-02-references-and-borrowing.md:57
+#: src/ch04-02-references-and-borrowing.md:78
+msgid "\"The length of '{s1}' is {len}.\""
+msgstr ""
+
+#: src/ch04-02-references-and-borrowing.md:31
+msgid ""
+"First, notice that all the tuple code in the variable declaration and the "
+"function return value is gone. Second, note that we pass `&s1` into "
+"`calculate_length` and, in its definition, we take `&String` rather than "
+"`String`. These ampersands represent _references_, and they allow you to "
+"refer to some value without taking ownership of it. Figure 4-5 depicts this "
+"concept."
+msgstr ""
+
+#: src/ch04-02-references-and-borrowing.md:37
+msgid ""
+""
+msgstr ""
+
+#: src/ch04-02-references-and-borrowing.md:41
+msgid ""
+"Figure 4-5: A diagram of `&String s` pointing at "
+"`String s1`"
+msgstr ""
+
+#: src/ch04-02-references-and-borrowing.md:44
+msgid ""
+"Note: The opposite of referencing by using `&` is _dereferencing_, which is "
+"accomplished with the dereference operator, `*`. We’ll see some uses of the "
+"dereference operator in Chapter 8 and discuss details of dereferencing in "
+"Chapter 15."
+msgstr ""
+
+#: src/ch04-02-references-and-borrowing.md:49
+msgid "Let’s take a closer look at the function call here:"
+msgstr ""
+
+#: src/ch04-02-references-and-borrowing.md:65
+msgid ""
+"The `&s1` syntax lets us create a reference that _refers_ to the value of "
+"`s1` but does not own it. Because it does not own it, the value it points to "
+"will not be dropped when the reference stops being used."
+msgstr ""
+
+#: src/ch04-02-references-and-borrowing.md:69
+msgid ""
+"Likewise, the signature of the function uses `&` to indicate that the type "
+"of the parameter `s` is a reference. Let’s add some explanatory annotations:"
+msgstr ""
+
+#: src/ch04-02-references-and-borrowing.md:81
+msgid "// s is a reference to a String\n"
+msgstr ""
+
+#: src/ch04-02-references-and-borrowing.md:83
+msgid ""
+"// Here, s goes out of scope. But because it does not have ownership of "
+"what\n"
+" // it refers to, it is not dropped.\n"
+msgstr ""
+
+#: src/ch04-02-references-and-borrowing.md:87
+msgid ""
+"The scope in which the variable `s` is valid is the same as any function "
+"parameter’s scope, but the value pointed to by the reference is not dropped "
+"when `s` stops being used, because `s` doesn’t have ownership. When "
+"functions have references as parameters instead of the actual values, we "
+"won’t need to return the values in order to give back ownership, because we "
+"never had ownership."
+msgstr ""
+
+#: src/ch04-02-references-and-borrowing.md:94
+msgid ""
+"We call the action of creating a reference _borrowing_. As in real life, if "
+"a person owns something, you can borrow it from them. When you’re done, you "
+"have to give it back. You don’t own it."
+msgstr ""
+
+#: src/ch04-02-references-and-borrowing.md:98
+msgid ""
+"So, what happens if we try to modify something we’re borrowing? Try the code "
+"in Listing 4-6. Spoiler alert: it doesn’t work!"
+msgstr ""
+
+#: src/ch04-02-references-and-borrowing.md:111
+#: src/ch04-02-references-and-borrowing.md:155
+msgid "\", world\""
+msgstr ""
+
+#: src/ch04-02-references-and-borrowing.md:115
+msgid ""
+"Listing 4-6: Attempting to modify a borrowed value"
+"span>"
+msgstr ""
+
+#: src/ch04-02-references-and-borrowing.md:117
+#: src/ch04-02-references-and-borrowing.md:181
+#: src/ch04-02-references-and-borrowing.md:252
+#: src/ch04-02-references-and-borrowing.md:338
+msgid "Here’s the error:"
+msgstr ""
+
+#: src/ch04-02-references-and-borrowing.md:119
+msgid ""
+"```console\n"
+"$ cargo run\n"
+" Compiling ownership v0.1.0 (file:///projects/ownership)\n"
+"error[E0596]: cannot borrow `*some_string` as mutable, as it is behind a `&` "
+"reference\n"
+" --> src/main.rs:8:5\n"
+" |\n"
+"8 | some_string.push_str(\", world\");\n"
+" | ^^^^^^^^^^^ `some_string` is a `&` reference, so the data it refers "
+"to cannot be borrowed as mutable\n"
+" |\n"
+"help: consider changing this to be a mutable reference\n"
+" |\n"
+"7 | fn change(some_string: &mut String) {\n"
+" | +++\n"
+"\n"
+"For more information about this error, try `rustc --explain E0596`.\n"
+"error: could not compile `ownership` (bin \"ownership\") due to 1 previous "
+"error\n"
+"```"
+msgstr ""
+
+#: src/ch04-02-references-and-borrowing.md:137
+msgid ""
+"Just as variables are immutable by default, so are references. We’re not "
+"allowed to modify something we have a reference to."
+msgstr ""
+
+#: src/ch04-02-references-and-borrowing.md:140
+msgid "Mutable References"
+msgstr ""
+
+#: src/ch04-02-references-and-borrowing.md:142
+msgid ""
+"We can fix the code from Listing 4-6 to allow us to modify a borrowed value "
+"with just a few small tweaks that use, instead, a _mutable reference_:"
+msgstr ""
+
+#: src/ch04-02-references-and-borrowing.md:159
+msgid ""
+"First we change `s` to be `mut`. Then we create a mutable reference with "
+"`&mut s` where we call the `change` function, and update the function "
+"signature to accept a mutable reference with `some_string: &mut String`. "
+"This makes it very clear that the `change` function will mutate the value it "
+"borrows."
+msgstr ""
+
+#: src/ch04-02-references-and-borrowing.md:164
+msgid ""
+"Mutable references have one big restriction: if you have a mutable reference "
+"to a value, you can have no other references to that value. This code that "
+"attempts to create two mutable references to `s` will fail:"
+msgstr ""
+
+#: src/ch04-02-references-and-borrowing.md:177
+msgid "\"{}, {}\""
+msgstr ""
+
+#: src/ch04-02-references-and-borrowing.md:183
+msgid ""
+"```console\n"
+"$ cargo run\n"
+" Compiling ownership v0.1.0 (file:///projects/ownership)\n"
+"error[E0499]: cannot borrow `s` as mutable more than once at a time\n"
+" --> src/main.rs:5:14\n"
+" |\n"
+"4 | let r1 = &mut s;\n"
+" | ------ first mutable borrow occurs here\n"
+"5 | let r2 = &mut s;\n"
+" | ^^^^^^ second mutable borrow occurs here\n"
+"6 |\n"
+"7 | println!(\"{}, {}\", r1, r2);\n"
+" | -- first borrow later used here\n"
+"\n"
+"For more information about this error, try `rustc --explain E0499`.\n"
+"error: could not compile `ownership` (bin \"ownership\") due to 1 previous "
+"error\n"
+"```"
+msgstr ""
+
+#: src/ch04-02-references-and-borrowing.md:201
+msgid ""
+"This error says that this code is invalid because we cannot borrow `s` as "
+"mutable more than once at a time. The first mutable borrow is in `r1` and "
+"must last until it’s used in the `println!`, but between the creation of "
+"that mutable reference and its usage, we tried to create another mutable "
+"reference in `r2` that borrows the same data as `r1`."
+msgstr ""
+
+#: src/ch04-02-references-and-borrowing.md:207
+msgid ""
+"The restriction preventing multiple mutable references to the same data at "
+"the same time allows for mutation but in a very controlled fashion. It’s "
+"something that new Rustaceans struggle with because most languages let you "
+"mutate whenever you’d like. The benefit of having this restriction is that "
+"Rust can prevent data races at compile time. A _data race_ is similar to a "
+"race condition and happens when these three behaviors occur:"
+msgstr ""
+
+#: src/ch04-02-references-and-borrowing.md:214
+msgid "Two or more pointers access the same data at the same time."
+msgstr ""
+
+#: src/ch04-02-references-and-borrowing.md:215
+msgid "At least one of the pointers is being used to write to the data."
+msgstr ""
+
+#: src/ch04-02-references-and-borrowing.md:216
+msgid "There’s no mechanism being used to synchronize access to the data."
+msgstr ""
+
+#: src/ch04-02-references-and-borrowing.md:218
+msgid ""
+"Data races cause undefined behavior and can be difficult to diagnose and fix "
+"when you’re trying to track them down at runtime; Rust prevents this problem "
+"by refusing to compile code with data races!"
+msgstr ""
+
+#: src/ch04-02-references-and-borrowing.md:222
+msgid ""
+"As always, we can use curly brackets to create a new scope, allowing for "
+"multiple mutable references, just not _simultaneous_ ones:"
+msgstr ""
+
+#: src/ch04-02-references-and-borrowing.md:231
+msgid ""
+"// r1 goes out of scope here, so we can make a new reference with no "
+"problems.\n"
+msgstr ""
+
+#: src/ch04-02-references-and-borrowing.md:237
+msgid ""
+"Rust enforces a similar rule for combining mutable and immutable references. "
+"This code results in an error:"
+msgstr ""
+
+#: src/ch04-02-references-and-borrowing.md:244
+#: src/ch04-02-references-and-borrowing.md:245
+#: src/ch04-02-references-and-borrowing.md:290
+#: src/ch04-02-references-and-borrowing.md:291
+#: src/ch04-02-references-and-borrowing.md:295
+msgid "// no problem\n"
+msgstr ""
+
+#: src/ch04-02-references-and-borrowing.md:246
+msgid "// BIG PROBLEM\n"
+msgstr ""
+
+#: src/ch04-02-references-and-borrowing.md:248
+msgid "\"{}, {}, and {}\""
+msgstr ""
+
+#: src/ch04-02-references-and-borrowing.md:254
+msgid ""
+"```console\n"
+"$ cargo run\n"
+" Compiling ownership v0.1.0 (file:///projects/ownership)\n"
+"error[E0502]: cannot borrow `s` as mutable because it is also borrowed as "
+"immutable\n"
+" --> src/main.rs:6:14\n"
+" |\n"
+"4 | let r1 = &s; // no problem\n"
+" | -- immutable borrow occurs here\n"
+"5 | let r2 = &s; // no problem\n"
+"6 | let r3 = &mut s; // BIG PROBLEM\n"
+" | ^^^^^^ mutable borrow occurs here\n"
+"7 |\n"
+"8 | println!(\"{}, {}, and {}\", r1, r2, r3);\n"
+" | -- immutable borrow later used here\n"
+"\n"
+"For more information about this error, try `rustc --explain E0502`.\n"
+"error: could not compile `ownership` (bin \"ownership\") due to 1 previous "
+"error\n"
+"```"
+msgstr ""
+
+#: src/ch04-02-references-and-borrowing.md:273
+msgid ""
+"Whew! We _also_ cannot have a mutable reference while we have an immutable "
+"one to the same value."
+msgstr ""
+
+#: src/ch04-02-references-and-borrowing.md:276
+msgid ""
+"Users of an immutable reference don’t expect the value to suddenly change "
+"out from under them! However, multiple immutable references are allowed "
+"because no one who is just reading the data has the ability to affect anyone "
+"else’s reading of the data."
+msgstr ""
+
+#: src/ch04-02-references-and-borrowing.md:281
+msgid ""
+"Note that a reference’s scope starts from where it is introduced and "
+"continues through the last time that reference is used. For instance, this "
+"code will compile because the last usage of the immutable references, the "
+"`println!`, occurs before the mutable reference is introduced:"
+msgstr ""
+
+#: src/ch04-02-references-and-borrowing.md:292
+msgid "\"{r1} and {r2}\""
+msgstr ""
+
+#: src/ch04-02-references-and-borrowing.md:293
+msgid "// variables r1 and r2 will not be used after this point\n"
+msgstr ""
+
+#: src/ch04-02-references-and-borrowing.md:296
+msgid "\"{r3}\""
+msgstr ""
+
+#: src/ch04-02-references-and-borrowing.md:300
+msgid ""
+"The scopes of the immutable references `r1` and `r2` end after the `println!"
+"` where they are last used, which is before the mutable reference `r3` is "
+"created. These scopes don’t overlap, so this code is allowed: the compiler "
+"can tell that the reference is no longer being used at a point before the "
+"end of the scope."
+msgstr ""
+
+#: src/ch04-02-references-and-borrowing.md:306
+msgid ""
+"Even though borrowing errors may be frustrating at times, remember that it’s "
+"the Rust compiler pointing out a potential bug early (at compile time rather "
+"than at runtime) and showing you exactly where the problem is. Then you "
+"don’t have to track down why your data isn’t what you thought it was."
+msgstr ""
+
+#: src/ch04-02-references-and-borrowing.md:311
+msgid "Dangling References"
+msgstr ""
+
+#: src/ch04-02-references-and-borrowing.md:313
+msgid ""
+"In languages with pointers, it’s easy to erroneously create a _dangling "
+"pointer_—a pointer that references a location in memory that may have been "
+"given to someone else—by freeing some memory while preserving a pointer to "
+"that memory. In Rust, by contrast, the compiler guarantees that references "
+"will never be dangling references: if you have a reference to some data, the "
+"compiler will ensure that the data will not go out of scope before the "
+"reference to the data does."
+msgstr ""
+
+#: src/ch04-02-references-and-borrowing.md:321
+msgid ""
+"Let’s try to create a dangling reference to see how Rust prevents them with "
+"a compile-time error:"
+msgstr ""
+
+#: src/ch04-02-references-and-borrowing.md:340
+msgid ""
+"```console\n"
+"$ cargo run\n"
+" Compiling ownership v0.1.0 (file:///projects/ownership)\n"
+"error[E0106]: missing lifetime specifier\n"
+" --> src/main.rs:5:16\n"
+" |\n"
+"5 | fn dangle() -> &String {\n"
+" | ^ expected named lifetime parameter\n"
+" |\n"
+" = help: this function's return type contains a borrowed value, but there "
+"is no value for it to be borrowed from\n"
+"help: consider using the `'static` lifetime, but this is uncommon unless "
+"you're returning a borrowed value from a `const` or a `static`\n"
+" |\n"
+"5 | fn dangle() -> &'static String {\n"
+" | +++++++\n"
+"help: instead, you are more likely to want to return an owned value\n"
+" |\n"
+"5 - fn dangle() -> &String {\n"
+"5 + fn dangle() -> String {\n"
+" |\n"
+"\n"
+"error[E0515]: cannot return reference to local variable `s`\n"
+" --> src/main.rs:8:5\n"
+" |\n"
+"8 | &s\n"
+" | ^^ returns a reference to data owned by the current function\n"
+"\n"
+"Some errors have detailed explanations: E0106, E0515.\n"
+"For more information about an error, try `rustc --explain E0106`.\n"
+"error: could not compile `ownership` (bin \"ownership\") due to 2 previous "
+"errors\n"
+"```"
+msgstr ""
+
+#: src/ch04-02-references-and-borrowing.md:371
+msgid ""
+"This error message refers to a feature we haven’t covered yet: lifetimes. "
+"We’ll discuss lifetimes in detail in Chapter 10. But, if you disregard the "
+"parts about lifetimes, the message does contain the key to why this code is "
+"a problem:"
+msgstr ""
+
+#: src/ch04-02-references-and-borrowing.md:380
+msgid ""
+"Let’s take a closer look at exactly what’s happening at each stage of our "
+"`dangle` code:"
+msgstr ""
+
+#: src/ch04-02-references-and-borrowing.md:390
+msgid "// dangle returns a reference to a String\n"
+msgstr ""
+
+#: src/ch04-02-references-and-borrowing.md:392
+msgid "// s is a new String\n"
+msgstr ""
+
+#: src/ch04-02-references-and-borrowing.md:394
+msgid "// we return a reference to the String, s\n"
+msgstr ""
+
+#: src/ch04-02-references-and-borrowing.md:395
+msgid ""
+"// Here, s goes out of scope, and is dropped. Its memory goes away.\n"
+" // Danger!\n"
+msgstr ""
+
+#: src/ch04-02-references-and-borrowing.md:399
+msgid ""
+"Because `s` is created inside `dangle`, when the code of `dangle` is "
+"finished, `s` will be deallocated. But we tried to return a reference to it. "
+"That means this reference would be pointing to an invalid `String`. That’s "
+"no good! Rust won’t let us do this."
+msgstr ""
+
+#: src/ch04-02-references-and-borrowing.md:404
+msgid "The solution here is to return the `String` directly:"
+msgstr ""
+
+#: src/ch04-02-references-and-borrowing.md:418
+msgid ""
+"This works without any problems. Ownership is moved out, and nothing is "
+"deallocated."
+msgstr ""
+
+#: src/ch04-02-references-and-borrowing.md:421
+msgid "The Rules of References"
+msgstr ""
+
+#: src/ch04-02-references-and-borrowing.md:423
+msgid "Let’s recap what we’ve discussed about references:"
+msgstr ""
+
+#: src/ch04-02-references-and-borrowing.md:425
+msgid ""
+"At any given time, you can have _either_ one mutable reference _or_ any "
+"number of immutable references."
+msgstr ""
+
+#: src/ch04-02-references-and-borrowing.md:427
+#: src/ch15-05-interior-mutability.md:27
+msgid "References must always be valid."
+msgstr ""
+
+#: src/ch04-02-references-and-borrowing.md:429
+msgid "Next, we’ll look at a different kind of reference: slices."
+msgstr ""
+
+#: src/ch04-03-slices.md:3
+msgid ""
+"_Slices_ let you reference a contiguous sequence of elements in a "
+"[collection](ch08-00-common-collections.md) rather than the whole "
+"collection. A slice is a kind of reference, so it does not have ownership."
+msgstr ""
+
+#: src/ch04-03-slices.md:7
+msgid ""
+"Here’s a small programming problem: write a function that takes a string of "
+"words separated by spaces and returns the first word it finds in that "
+"string. If the function doesn’t find a space in the string, the whole string "
+"must be one word, so the entire string should be returned."
+msgstr ""
+
+#: src/ch04-03-slices.md:12
+msgid ""
+"Let’s work through how we’d write the signature of this function without "
+"using slices, to understand the problem that slices will solve:"
+msgstr ""
+
+#: src/ch04-03-slices.md:19
+msgid ""
+"The `first_word` function has a `&String` as a parameter. We don’t want "
+"ownership, so this is fine. But what should we return? We don’t really have "
+"a way to talk about _part_ of a string. However, we could return the index "
+"of the end of the word, indicated by a space. Let’s try that, as shown in "
+"Listing 4-7."
+msgstr ""
+
+#: src/ch04-03-slices.md:31 src/ch04-03-slices.md:54 src/ch04-03-slices.md:72
+#: src/ch04-03-slices.md:106 src/ch04-03-slices.md:131
+#: src/ch04-03-slices.md:260 src/ch04-03-slices.md:303
+#: src/ch04-03-slices.md:386 src/ch04-03-slices.md:435
+#: src/ch10-03-lifetime-syntax.md:587
+msgid "b' '"
+msgstr ""
+
+#: src/ch04-03-slices.md:42
+msgid ""
+"Listing 4-7: The `first_word` function that returns "
+"a byte index value into the `String` parameter"
+msgstr ""
+
+#: src/ch04-03-slices.md:45
+msgid ""
+"Because we need to go through the `String` element by element and check "
+"whether a value is a space, we’ll convert our `String` to an array of bytes "
+"using the `as_bytes` method."
+msgstr ""
+
+#: src/ch04-03-slices.md:65
+msgid ""
+"Next, we create an iterator over the array of bytes using the `iter` method:"
+msgstr ""
+
+#: src/ch04-03-slices.md:83
+msgid ""
+"We’ll discuss iterators in more detail in [Chapter 13](ch13-02-iterators."
+"html). For now, know that `iter` is a method that returns "
+"each element in a collection and that `enumerate` wraps the result of `iter` "
+"and returns each element as part of a tuple instead. The first element of "
+"the tuple returned from `enumerate` is the index, and the second element is "
+"a reference to the element. This is a bit more convenient than calculating "
+"the index ourselves."
+msgstr ""
+
+#: src/ch04-03-slices.md:90
+msgid ""
+"Because the `enumerate` method returns a tuple, we can use patterns to "
+"destructure that tuple. We’ll be discussing patterns more in [Chapter 6]"
+"(ch06-02-match.html#patterns-that-bind-to-values). In the "
+"`for` loop, we specify a pattern that has `i` for the index in the tuple and "
+"`&item` for the single byte in the tuple. Because we get a reference to the "
+"element from `.iter().enumerate()`, we use `&` in the pattern."
+msgstr ""
+
+#: src/ch04-03-slices.md:97
+msgid ""
+"Inside the `for` loop, we search for the byte that represents the space by "
+"using the byte literal syntax. If we find a space, we return the position. "
+"Otherwise, we return the length of the string by using `s.len()`."
+msgstr ""
+
+#: src/ch04-03-slices.md:117
+msgid ""
+"We now have a way to find out the index of the end of the first word in the "
+"string, but there’s a problem. We’re returning a `usize` on its own, but "
+"it’s only a meaningful number in the context of the `&String`. In other "
+"words, because it’s a separate value from the `String`, there’s no guarantee "
+"that it will still be valid in the future. Consider the program in Listing "
+"4-8 that uses the `first_word` function from Listing 4-7."
+msgstr ""
+
+#: src/ch04-03-slices.md:140 src/ch04-03-slices.md:181
+#: src/ch04-03-slices.md:312 src/ch04-03-slices.md:395
+#: src/ch04-03-slices.md:404 src/ch04-03-slices.md:444
+#: src/ch04-03-slices.md:453 src/ch10-03-lifetime-syntax.md:596
+#: src/ch10-03-lifetime-syntax.md:601
+msgid "\"hello world\""
+msgstr ""
+
+#: src/ch04-03-slices.md:142
+msgid "// word will get the value 5\n"
+msgstr ""
+
+#: src/ch04-03-slices.md:144
+msgid "// this empties the String, making it equal to \"\"\n"
+msgstr ""
+
+#: src/ch04-03-slices.md:146
+msgid ""
+"// word still has the value 5 here, but there's no more string that\n"
+" // we could meaningfully use the value 5 with. word is now totally "
+"invalid!\n"
+msgstr ""
+
+#: src/ch04-03-slices.md:151
+msgid ""
+"Listing 4-8: Storing the result from calling the "
+"`first_word` function and then changing the `String` contents"
+msgstr ""
+
+#: src/ch04-03-slices.md:154
+msgid ""
+"This program compiles without any errors and would also do so if we used "
+"`word` after calling `s.clear()`. Because `word` isn’t connected to the "
+"state of `s` at all, `word` still contains the value `5`. We could use that "
+"value `5` with the variable `s` to try to extract the first word out, but "
+"this would be a bug because the contents of `s` have changed since we saved "
+"`5` in `word`."
+msgstr ""
+
+#: src/ch04-03-slices.md:160
+msgid ""
+"Having to worry about the index in `word` getting out of sync with the data "
+"in `s` is tedious and error prone! Managing these indices is even more "
+"brittle if we write a `second_word` function. Its signature would have to "
+"look like this:"
+msgstr ""
+
+#: src/ch04-03-slices.md:168
+msgid ""
+"Now we’re tracking a starting _and_ an ending index, and we have even more "
+"values that were calculated from data in a particular state but aren’t tied "
+"to that state at all. We have three unrelated variables floating around that "
+"need to be kept in sync."
+msgstr ""
+
+#: src/ch04-03-slices.md:173
+msgid "Luckily, Rust has a solution to this problem: string slices."
+msgstr ""
+
+#: src/ch04-03-slices.md:175
+msgid "String Slices"
+msgstr ""
+
+#: src/ch04-03-slices.md:177
+msgid ""
+"A _string slice_ is a reference to part of a `String`, and it looks like "
+"this:"
+msgstr ""
+
+#: src/ch04-03-slices.md:188
+msgid ""
+"Rather than a reference to the entire `String`, `hello` is a reference to a "
+"portion of the `String`, specified in the extra `[0..5]` bit. We create "
+"slices using a range within brackets by specifying `[starting_index.."
+"ending_index]`, where `starting_index` is the first position in the slice "
+"and `ending_index` is one more than the last position in the slice. "
+"Internally, the slice data structure stores the starting position and the "
+"length of the slice, which corresponds to `ending_index` minus "
+"`starting_index`. So, in the case of `let world = &s[6..11];`, `world` would "
+"be a slice that contains a pointer to the byte at index 6 of `s` with a "
+"length value of `5`."
+msgstr ""
+
+#: src/ch04-03-slices.md:198
+msgid "Figure 4-6 shows this in a diagram."
+msgstr ""
+
+#: src/ch04-03-slices.md:200
+msgid ""
+""
+msgstr ""
+
+#: src/ch04-03-slices.md:206
+msgid ""
+"Figure 4-6: String slice referring to part of a "
+"`String`"
+msgstr ""
+
+#: src/ch04-03-slices.md:209
+msgid ""
+"With Rust’s `..` range syntax, if you want to start at index 0, you can drop "
+"the value before the two periods. In other words, these are equal:"
+msgstr ""
+
+#: src/ch04-03-slices.md:219
+msgid ""
+"By the same token, if your slice includes the last byte of the `String`, you "
+"can drop the trailing number. That means these are equal:"
+msgstr ""
+
+#: src/ch04-03-slices.md:231
+msgid ""
+"You can also drop both values to take a slice of the entire string. So these "
+"are equal:"
+msgstr ""
+
+#: src/ch04-03-slices.md:243
+msgid ""
+"Note: String slice range indices must occur at valid UTF-8 character "
+"boundaries. If you attempt to create a string slice in the middle of a "
+"multibyte character, your program will exit with an error. For the purposes "
+"of introducing string slices, we are assuming ASCII only in this section; a "
+"more thorough discussion of UTF-8 handling is in the [“Storing UTF-8 Encoded "
+"Text with Strings”](ch08-02-strings.html#storing-utf-8-encoded-text-with-"
+"strings) section of Chapter 8."
+msgstr ""
+
+#: src/ch04-03-slices.md:250
+msgid ""
+"With all this information in mind, let’s rewrite `first_word` to return a "
+"slice. The type that signifies “string slice” is written as `&str`:"
+msgstr ""
+
+#: src/ch04-03-slices.md:271
+msgid ""
+"We get the index for the end of the word the same way we did in Listing 4-7, "
+"by looking for the first occurrence of a space. When we find a space, we "
+"return a string slice using the start of the string and the index of the "
+"space as the starting and ending indices."
+msgstr ""
+
+#: src/ch04-03-slices.md:276
+msgid ""
+"Now when we call `first_word`, we get back a single value that is tied to "
+"the underlying data. The value is made up of a reference to the starting "
+"point of the slice and the number of elements in the slice."
+msgstr ""
+
+#: src/ch04-03-slices.md:280
+msgid "Returning a slice would also work for a `second_word` function:"
+msgstr ""
+
+#: src/ch04-03-slices.md:286
+msgid ""
+"We now have a straightforward API that’s much harder to mess up because the "
+"compiler will ensure the references into the `String` remain valid. Remember "
+"the bug in the program in Listing 4-8, when we got the index to the end of "
+"the first word but then cleared the string so our index was invalid? That "
+"code was logically incorrect but didn’t show any immediate errors. The "
+"problems would show up later if we kept trying to use the first word index "
+"with an emptied string. Slices make this bug impossible and let us know we "
+"have a problem with our code much sooner. Using the slice version of "
+"`first_word` will throw a compile-time error:"
+msgstr ""
+
+#: src/ch04-03-slices.md:316
+msgid "// error!\n"
+msgstr ""
+
+#: src/ch04-03-slices.md:318
+msgid "\"the first word is: {word}\""
+msgstr ""
+
+#: src/ch04-03-slices.md:322
+msgid "Here’s the compiler error:"
+msgstr ""
+
+#: src/ch04-03-slices.md:324
+msgid ""
+"```console\n"
+"$ cargo run\n"
+" Compiling ownership v0.1.0 (file:///projects/ownership)\n"
+"error[E0502]: cannot borrow `s` as mutable because it is also borrowed as "
+"immutable\n"
+" --> src/main.rs:18:5\n"
+" |\n"
+"16 | let word = first_word(&s);\n"
+" | -- immutable borrow occurs here\n"
+"17 |\n"
+"18 | s.clear(); // error!\n"
+" | ^^^^^^^^^ mutable borrow occurs here\n"
+"19 |\n"
+"20 | println!(\"the first word is: {word}\");\n"
+" | ------ immutable borrow later used "
+"here\n"
+"\n"
+"For more information about this error, try `rustc --explain E0502`.\n"
+"error: could not compile `ownership` (bin \"ownership\") due to 1 previous "
+"error\n"
+"```"
+msgstr ""
+
+#: src/ch04-03-slices.md:343
+msgid ""
+"Recall from the borrowing rules that if we have an immutable reference to "
+"something, we cannot also take a mutable reference. Because `clear` needs to "
+"truncate the `String`, it needs to get a mutable reference. The `println!` "
+"after the call to `clear` uses the reference in `word`, so the immutable "
+"reference must still be active at that point. Rust disallows the mutable "
+"reference in `clear` and the immutable reference in `word` from existing at "
+"the same time, and compilation fails. Not only has Rust made our API easier "
+"to use, but it has also eliminated an entire class of errors at compile time!"
+msgstr ""
+
+#: src/ch04-03-slices.md:353
+msgid ""
+msgstr ""
+
+#: src/ch04-03-slices.md:355
+msgid "String Literals as Slices"
+msgstr ""
+
+#: src/ch04-03-slices.md:357
+msgid ""
+"Recall that we talked about string literals being stored inside the binary. "
+"Now that we know about slices, we can properly understand string literals:"
+msgstr ""
+
+#: src/ch04-03-slices.md:364
+msgid ""
+"The type of `s` here is `&str`: it’s a slice pointing to that specific point "
+"of the binary. This is also why string literals are immutable; `&str` is an "
+"immutable reference."
+msgstr ""
+
+#: src/ch04-03-slices.md:368
+msgid "String Slices as Parameters"
+msgstr ""
+
+#: src/ch04-03-slices.md:370
+msgid ""
+"Knowing that you can take slices of literals and `String` values leads us to "
+"one more improvement on `first_word`, and that’s its signature:"
+msgstr ""
+
+#: src/ch04-03-slices.md:377
+msgid ""
+"A more experienced Rustacean would write the signature shown in Listing 4-9 "
+"instead because it allows us to use the same function on both `&String` "
+"values and `&str` values."
+msgstr ""
+
+#: src/ch04-03-slices.md:397 src/ch04-03-slices.md:446
+msgid ""
+"// `first_word` works on slices of `String`s, whether partial or whole\n"
+msgstr ""
+
+#: src/ch04-03-slices.md:400
+msgid ""
+"// `first_word` also works on references to `String`s, which are equivalent\n"
+msgstr ""
+
+#: src/ch04-03-slices.md:401
+msgid "// to whole slices of `String`s\n"
+msgstr ""
+
+#: src/ch04-03-slices.md:406 src/ch04-03-slices.md:455
+msgid ""
+"// `first_word` works on slices of string literals, whether partial or "
+"whole\n"
+msgstr ""
+
+#: src/ch04-03-slices.md:410 src/ch10-03-lifetime-syntax.md:606
+msgid "// Because string literals *are* string slices already,\n"
+msgstr ""
+
+#: src/ch04-03-slices.md:411 src/ch10-03-lifetime-syntax.md:607
+msgid "// this works too, without the slice syntax!\n"
+msgstr ""
+
+#: src/ch04-03-slices.md:416
+msgid ""
+"Listing 4-9: Improving the `first_word` function by "
+"using a string slice for the type of the `s` parameter"
+msgstr ""
+
+#: src/ch04-03-slices.md:419
+msgid ""
+"If we have a string slice, we can pass that directly. If we have a `String`, "
+"we can pass a slice of the `String` or a reference to the `String`. This "
+"flexibility takes advantage of _deref coercions_, a feature we will cover in "
+"the [“Implicit Deref Coercions with Functions and Methods”](ch15-02-deref."
+"html#implicit-deref-coercions-with-functions-and-methods) "
+"section of Chapter 15."
+msgstr ""
+
+#: src/ch04-03-slices.md:425
+msgid ""
+"Defining a function to take a string slice instead of a reference to a "
+"`String` makes our API more general and useful without losing any "
+"functionality:"
+msgstr ""
+
+#: src/ch04-03-slices.md:449
+msgid ""
+"// `first_word` also works on references to `String`s, which are equivalent\n"
+" // to whole slices of `String`s\n"
+msgstr ""
+
+#: src/ch04-03-slices.md:459
+msgid ""
+"// Because string literals *are* string slices already,\n"
+" // this works too, without the slice syntax!\n"
+msgstr ""
+
+#: src/ch04-03-slices.md:465
+msgid "Other Slices"
+msgstr ""
+
+#: src/ch04-03-slices.md:467
+msgid ""
+"String slices, as you might imagine, are specific to strings. But there’s a "
+"more general slice type too. Consider this array:"
+msgstr ""
+
+#: src/ch04-03-slices.md:474
+msgid ""
+"Just as we might want to refer to part of a string, we might want to refer "
+"to part of an array. We’d do so like this:"
+msgstr ""
+
+#: src/ch04-03-slices.md:485
+msgid ""
+"This slice has the type `&[i32]`. It works the same way as string slices do, "
+"by storing a reference to the first element and a length. You’ll use this "
+"kind of slice for all sorts of other collections. We’ll discuss these "
+"collections in detail when we talk about vectors in Chapter 8."
+msgstr ""
+
+#: src/ch04-03-slices.md:492
+msgid ""
+"The concepts of ownership, borrowing, and slices ensure memory safety in "
+"Rust programs at compile time. The Rust language gives you control over your "
+"memory usage in the same way as other systems programming languages, but "
+"having the owner of data automatically clean up that data when the owner "
+"goes out of scope means you don’t have to write and debug extra code to get "
+"this control."
+msgstr ""
+
+#: src/ch04-03-slices.md:498
+msgid ""
+"Ownership affects how lots of other parts of Rust work, so we’ll talk about "
+"these concepts further throughout the rest of the book. Let’s move on to "
+"Chapter 5 and look at grouping pieces of data together in a `struct`."
+msgstr ""
+
+#: src/ch05-00-structs.md:3
+msgid ""
+"A _struct_, or _structure_, is a custom data type that lets you package "
+"together and name multiple related values that make up a meaningful group. "
+"If you’re familiar with an object-oriented language, a _struct_ is like an "
+"object’s data attributes. In this chapter, we’ll compare and contrast tuples "
+"with structs to build on what you already know and demonstrate when structs "
+"are a better way to group data."
+msgstr ""
+
+#: src/ch05-00-structs.md:10
+msgid ""
+"We’ll demonstrate how to define and instantiate structs. We’ll discuss how "
+"to define associated functions, especially the kind of associated functions "
+"called _methods_, to specify behavior associated with a struct type. Structs "
+"and enums (discussed in Chapter 6) are the building blocks for creating new "
+"types in your program’s domain to take full advantage of Rust’s compile-time "
+"type checking."
+msgstr ""
+
+#: src/ch05-01-defining-structs.md:3
+msgid ""
+"Structs are similar to tuples, discussed in [“The Tuple Type”](ch03-02-data-"
+"types.html#the-tuple-type) section, in that both hold multiple related values. Like tuples, "
+"the pieces of a struct can be different types. Unlike with tuples, in a "
+"struct you’ll name each piece of data so it’s clear what the values mean. "
+"Adding these names means that structs are more flexible than tuples: you "
+"don’t have to rely on the order of the data to specify or access the values "
+"of an instance."
+msgstr ""
+
+#: src/ch05-01-defining-structs.md:10
+msgid ""
+"To define a struct, we enter the keyword `struct` and name the entire "
+"struct. A struct’s name should describe the significance of the pieces of "
+"data being grouped together. Then, inside curly brackets, we define the "
+"names and types of the pieces of data, which we call _fields_. For example, "
+"Listing 5-1 shows a struct that stores information about a user account."
+msgstr ""
+
+#: src/ch05-01-defining-structs.md:29
+msgid "Listing 5-1: A `User` struct definition"
+msgstr ""
+
+#: src/ch05-01-defining-structs.md:31
+msgid ""
+"To use a struct after we’ve defined it, we create an _instance_ of that "
+"struct by specifying concrete values for each of the fields. We create an "
+"instance by stating the name of the struct and then add curly brackets "
+"containing _key: value_ pairs, where the keys are the names of the fields "
+"and the values are the data we want to store in those fields. We don’t have "
+"to specify the fields in the same order in which we declared them in the "
+"struct. In other words, the struct definition is like a general template for "
+"the type, and instances fill in that template with particular data to create "
+"values of the type. For example, we can declare a particular user as shown "
+"in Listing 5-2."
+msgstr ""
+
+#: src/ch05-01-defining-structs.md:54 src/ch05-01-defining-structs.md:83
+#: src/ch05-01-defining-structs.md:126 src/ch05-01-defining-structs.md:171
+#: src/ch05-01-defining-structs.md:211 src/ch05-01-defining-structs.md:247
+#: src/ch05-01-defining-structs.md:374
+msgid "\"someusername123\""
+msgstr ""
+
+#: src/ch05-01-defining-structs.md:55 src/ch05-01-defining-structs.md:84
+#: src/ch05-01-defining-structs.md:125 src/ch05-01-defining-structs.md:170
+#: src/ch05-01-defining-structs.md:210 src/ch05-01-defining-structs.md:246
+#: src/ch05-01-defining-structs.md:375
+msgid "\"someone@example.com\""
+msgstr ""
+
+#: src/ch05-01-defining-structs.md:61
+msgid ""
+"Listing 5-2: Creating an instance of the `User` "
+"struct"
+msgstr ""
+
+#: src/ch05-01-defining-structs.md:64
+msgid ""
+"To get a specific value from a struct, we use dot notation. For example, to "
+"access this user’s email address, we use `user1.email`. If the instance is "
+"mutable, we can change a value by using the dot notation and assigning into "
+"a particular field. Listing 5-3 shows how to change the value in the `email` "
+"field of a mutable `User` instance."
+msgstr ""
+
+#: src/ch05-01-defining-structs.md:88
+msgid "\"anotheremail@example.com\""
+msgstr ""
+
+#: src/ch05-01-defining-structs.md:92
+msgid ""
+"Listing 5-3: Changing the value in the `email` field "
+"of a `User` instance"
+msgstr ""
+
+#: src/ch05-01-defining-structs.md:95
+msgid ""
+"Note that the entire instance must be mutable; Rust doesn’t allow us to mark "
+"only certain fields as mutable. As with any expression, we can construct a "
+"new instance of the struct as the last expression in the function body to "
+"implicitly return that new instance."
+msgstr ""
+
+#: src/ch05-01-defining-structs.md:100
+msgid ""
+"Listing 5-4 shows a `build_user` function that returns a `User` instance "
+"with the given email and username. The `active` field gets the value of "
+"`true`, and the `sign_in_count` gets a value of `1`."
+msgstr ""
+
+#: src/ch05-01-defining-structs.md:131
+msgid ""
+"Listing 5-4: A `build_user` function that takes an "
+"email and username and returns a `User` instance"
+msgstr ""
+
+#: src/ch05-01-defining-structs.md:134
+msgid ""
+"It makes sense to name the function parameters with the same name as the "
+"struct fields, but having to repeat the `email` and `username` field names "
+"and variables is a bit tedious. If the struct had more fields, repeating "
+"each name would get even more annoying. Luckily, there’s a convenient "
+"shorthand!"
+msgstr ""
+
+#: src/ch05-01-defining-structs.md:140
+msgid ""
+""
+msgstr ""
+
+#: src/ch05-01-defining-structs.md:142
+msgid "Using the Field Init Shorthand"
+msgstr ""
+
+#: src/ch05-01-defining-structs.md:144
+msgid ""
+"Because the parameter names and the struct field names are exactly the same "
+"in Listing 5-4, we can use the _field init shorthand_ syntax to rewrite "
+"`build_user` so it behaves exactly the same but doesn’t have the repetition "
+"of `username` and `email`, as shown in Listing 5-5."
+msgstr ""
+
+#: src/ch05-01-defining-structs.md:176
+msgid ""
+"Listing 5-5: A `build_user` function that uses field "
+"init shorthand because the `username` and `email` parameters have the same "
+"name as struct fields"
+msgstr ""
+
+#: src/ch05-01-defining-structs.md:180
+msgid ""
+"Here, we’re creating a new instance of the `User` struct, which has a field "
+"named `email`. We want to set the `email` field’s value to the value in the "
+"`email` parameter of the `build_user` function. Because the `email` field "
+"and the `email` parameter have the same name, we only need to write `email` "
+"rather than `email: email`."
+msgstr ""
+
+#: src/ch05-01-defining-structs.md:186
+msgid "Creating Instances from Other Instances with Struct Update Syntax"
+msgstr ""
+
+#: src/ch05-01-defining-structs.md:188
+msgid ""
+"It’s often useful to create a new instance of a struct that includes most of "
+"the values from another instance, but changes some. You can do this using "
+"_struct update syntax_."
+msgstr ""
+
+#: src/ch05-01-defining-structs.md:192
+msgid ""
+"First, in Listing 5-6 we show how to create a new `User` instance in `user2` "
+"regularly, without the update syntax. We set a new value for `email` but "
+"otherwise use the same values from `user1` that we created in Listing 5-2."
+msgstr ""
+
+#: src/ch05-01-defining-structs.md:219 src/ch05-01-defining-structs.md:253
+msgid "\"another@example.com\""
+msgstr ""
+
+#: src/ch05-01-defining-structs.md:225
+msgid ""
+"Listing 5-6: Creating a new `User` instance using "
+"all but one of the values from `user1`"
+msgstr ""
+
+#: src/ch05-01-defining-structs.md:228
+msgid ""
+"Using struct update syntax, we can achieve the same effect with less code, "
+"as shown in Listing 5-7. The syntax `..` specifies that the remaining fields "
+"not explicitly set should have the same value as the fields in the given "
+"instance."
+msgstr ""
+
+#: src/ch05-01-defining-structs.md:259
+msgid ""
+"Listing 5-7: Using struct update syntax to set a new "
+"`email` value for a `User` instance but to use the rest of the values from "
+"`user1`"
+msgstr ""
+
+#: src/ch05-01-defining-structs.md:263
+msgid ""
+"The code in Listing 5-7 also creates an instance in `user2` that has a "
+"different value for `email` but has the same values for the `username`, "
+"`active`, and `sign_in_count` fields from `user1`. The `..user1` must come "
+"last to specify that any remaining fields should get their values from the "
+"corresponding fields in `user1`, but we can choose to specify values for as "
+"many fields as we want in any order, regardless of the order of the fields "
+"in the struct’s definition."
+msgstr ""
+
+#: src/ch05-01-defining-structs.md:271
+msgid ""
+"Note that the struct update syntax uses `=` like an assignment; this is "
+"because it moves the data, just as we saw in the [“Variables and Data "
+"Interacting with Move”](ch04-01-what-is-ownership.html#variables-and-data-"
+"interacting-with-move) section. In this example, we can no "
+"longer use `user1` as a whole after creating `user2` because the `String` in "
+"the `username` field of `user1` was moved into `user2`. If we had given "
+"`user2` new `String` values for both `email` and `username`, and thus only "
+"used the `active` and `sign_in_count` values from `user1`, then `user1` "
+"would still be valid after creating `user2`. Both `active` and "
+"`sign_in_count` are types that implement the `Copy` trait, so the behavior "
+"we discussed in the [“Stack-Only Data: Copy”](ch04-01-what-is-ownership."
+"html#stack-only-data-copy) section would apply."
+msgstr ""
+
+#: src/ch05-01-defining-structs.md:282
+msgid "Using Tuple Structs Without Named Fields to Create Different Types"
+msgstr ""
+
+#: src/ch05-01-defining-structs.md:284
+msgid ""
+"Rust also supports structs that look similar to tuples, called _tuple "
+"structs_. Tuple structs have the added meaning the struct name provides but "
+"don’t have names associated with their fields; rather, they just have the "
+"types of the fields. Tuple structs are useful when you want to give the "
+"whole tuple a name and make the tuple a different type from other tuples, "
+"and when naming each field as in a regular struct would be verbose or "
+"redundant."
+msgstr ""
+
+#: src/ch05-01-defining-structs.md:291
+msgid ""
+"To define a tuple struct, start with the `struct` keyword and the struct "
+"name followed by the types in the tuple. For example, here we define and use "
+"two tuple structs named `Color` and `Point`:"
+msgstr ""
+
+#: src/ch05-01-defining-structs.md:307
+msgid ""
+"Note that the `black` and `origin` values are different types because "
+"they’re instances of different tuple structs. Each struct you define is its "
+"own type, even though the fields within the struct might have the same "
+"types. For example, a function that takes a parameter of type `Color` cannot "
+"take a `Point` as an argument, even though both types are made up of three "
+"`i32` values. Otherwise, tuple struct instances are similar to tuples in "
+"that you can destructure them into their individual pieces, and you can use "
+"a `.` followed by the index to access an individual value."
+msgstr ""
+
+#: src/ch05-01-defining-structs.md:316
+msgid "Unit-Like Structs Without Any Fields"
+msgstr ""
+
+#: src/ch05-01-defining-structs.md:318
+msgid ""
+"You can also define structs that don’t have any fields! These are called "
+"_unit-like structs_ because they behave similarly to `()`, the unit type "
+"that we mentioned in [“The Tuple Type”](ch03-02-data-types.html#the-tuple-"
+"type) section. Unit-like structs can be useful when you need "
+"to implement a trait on some type but don’t have any data that you want to "
+"store in the type itself. We’ll discuss traits in Chapter 10. Here’s an "
+"example of declaring and instantiating a unit struct named `AlwaysEqual`:"
+msgstr ""
+
+#: src/ch05-01-defining-structs.md:336
+msgid ""
+"To define `AlwaysEqual`, we use the `struct` keyword, the name we want, and "
+"then a semicolon. No need for curly brackets or parentheses! Then we can get "
+"an instance of `AlwaysEqual` in the `subject` variable in a similar way: "
+"using the name we defined, without any curly brackets or parentheses. "
+"Imagine that later we’ll implement behavior for this type such that every "
+"instance of `AlwaysEqual` is always equal to every instance of any other "
+"type, perhaps to have a known result for testing purposes. We wouldn’t need "
+"any data to implement that behavior! You’ll see in Chapter 10 how to define "
+"traits and implement them on any type, including unit-like structs."
+msgstr ""
+
+#: src/ch05-01-defining-structs.md:346
+msgid "Ownership of Struct Data"
+msgstr ""
+
+#: src/ch05-01-defining-structs.md:348
+msgid ""
+"In the `User` struct definition in Listing 5-1, we used the owned `String` "
+"type rather than the `&str` string slice type. This is a deliberate choice "
+"because we want each instance of this struct to own all of its data and for "
+"that data to be valid for as long as the entire struct is valid."
+msgstr ""
+
+#: src/ch05-01-defining-structs.md:353
+msgid ""
+"It’s also possible for structs to store references to data owned by "
+"something else, but to do so requires the use of _lifetimes_, a Rust feature "
+"that we’ll discuss in Chapter 10. Lifetimes ensure that the data referenced "
+"by a struct is valid for as long as the struct is. Let’s say you try to "
+"store a reference in a struct without specifying lifetimes, like the "
+"following; this won’t work:"
+msgstr ""
+
+#: src/ch05-01-defining-structs.md:381
+msgid "The compiler will complain that it needs lifetime specifiers:"
+msgstr ""
+
+#: src/ch05-01-defining-structs.md:383
+msgid ""
+"```console\n"
+"$ cargo run\n"
+" Compiling structs v0.1.0 (file:///projects/structs)\n"
+"error[E0106]: missing lifetime specifier\n"
+" --> src/main.rs:3:15\n"
+" |\n"
+"3 | username: &str,\n"
+" | ^ expected named lifetime parameter\n"
+" |\n"
+"help: consider introducing a named lifetime parameter\n"
+" |\n"
+"1 ~ struct User<'a> {\n"
+"2 | active: bool,\n"
+"3 ~ username: &'a str,\n"
+" |\n"
+"\n"
+"error[E0106]: missing lifetime specifier\n"
+" --> src/main.rs:4:12\n"
+" |\n"
+"4 | email: &str,\n"
+" | ^ expected named lifetime parameter\n"
+" |\n"
+"help: consider introducing a named lifetime parameter\n"
+" |\n"
+"1 ~ struct User<'a> {\n"
+"2 | active: bool,\n"
+"3 | username: &str,\n"
+"4 ~ email: &'a str,\n"
+" |\n"
+"\n"
+"For more information about this error, try `rustc --explain E0106`.\n"
+"error: could not compile `structs` (bin \"structs\") due to 2 previous "
+"errors\n"
+"```"
+msgstr ""
+
+#: src/ch05-01-defining-structs.md:417
+msgid ""
+"In Chapter 10, we’ll discuss how to fix these errors so you can store "
+"references in structs, but for now, we’ll fix errors like these using owned "
+"types like `String` instead of references like `&str`."
+msgstr ""
+
+#: src/ch05-02-example-structs.md:3
+msgid ""
+"To understand when we might want to use structs, let’s write a program that "
+"calculates the area of a rectangle. We’ll start by using single variables, "
+"and then refactor the program until we’re using structs instead."
+msgstr ""
+
+#: src/ch05-02-example-structs.md:7
+msgid ""
+"Let’s make a new binary project with Cargo called _rectangles_ that will "
+"take the width and height of a rectangle specified in pixels and calculate "
+"the area of the rectangle. Listing 5-8 shows a short program with one way of "
+"doing exactly that in our project’s _src/main.rs_."
+msgstr ""
+
+#: src/ch05-02-example-structs.md:20 src/ch05-02-example-structs.md:55
+#: src/ch05-02-example-structs.md:83 src/ch05-02-example-structs.md:129
+#: src/ch05-03-method-syntax.md:40
+msgid "\"The area of the rectangle is {} square pixels.\""
+msgstr ""
+
+#: src/ch05-02-example-structs.md:30
+msgid ""
+"Listing 5-8: Calculating the area of a rectangle "
+"specified by separate width and height variables"
+msgstr ""
+
+#: src/ch05-02-example-structs.md:33
+msgid "Now, run this program using `cargo run`:"
+msgstr ""
+
+#: src/ch05-02-example-structs.md:35
+msgid ""
+"```console\n"
+"$ cargo run\n"
+" Compiling rectangles v0.1.0 (file:///projects/rectangles)\n"
+" Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.42s\n"
+" Running `target/debug/rectangles`\n"
+"The area of the rectangle is 1500 square pixels.\n"
+"```"
+msgstr ""
+
+#: src/ch05-02-example-structs.md:43
+msgid ""
+"This code succeeds in figuring out the area of the rectangle by calling the "
+"`area` function with each dimension, but we can do more to make this code "
+"clear and readable."
+msgstr ""
+
+#: src/ch05-02-example-structs.md:47
+msgid "The issue with this code is evident in the signature of `area`:"
+msgstr ""
+
+#: src/ch05-02-example-structs.md:65
+msgid ""
+"The `area` function is supposed to calculate the area of one rectangle, but "
+"the function we wrote has two parameters, and it’s not clear anywhere in our "
+"program that the parameters are related. It would be more readable and more "
+"manageable to group width and height together. We’ve already discussed one "
+"way we might do that in [“The Tuple Type”](ch03-02-data-types.html#the-tuple-"
+"type) section of Chapter 3: by using tuples."
+msgstr ""
+
+#: src/ch05-02-example-structs.md:72
+msgid "Refactoring with Tuples"
+msgstr ""
+
+#: src/ch05-02-example-structs.md:74
+msgid "Listing 5-9 shows another version of our program that uses tuples."
+msgstr ""
+
+#: src/ch05-02-example-structs.md:93
+msgid ""
+"Listing 5-9: Specifying the width and height of the "
+"rectangle with a tuple"
+msgstr ""
+
+#: src/ch05-02-example-structs.md:96
+msgid ""
+"In one way, this program is better. Tuples let us add a bit of structure, "
+"and we’re now passing just one argument. But in another way, this version is "
+"less clear: tuples don’t name their elements, so we have to index into the "
+"parts of the tuple, making our calculation less obvious."
+msgstr ""
+
+#: src/ch05-02-example-structs.md:101
+msgid ""
+"Mixing up the width and height wouldn’t matter for the area calculation, but "
+"if we want to draw the rectangle on the screen, it would matter! We would "
+"have to keep in mind that `width` is the tuple index `0` and `height` is the "
+"tuple index `1`. This would be even harder for someone else to figure out "
+"and keep in mind if they were to use our code. Because we haven’t conveyed "
+"the meaning of our data in our code, it’s now easier to introduce errors."
+msgstr ""
+
+#: src/ch05-02-example-structs.md:108
+msgid "Refactoring with Structs: Adding More Meaning"
+msgstr ""
+
+#: src/ch05-02-example-structs.md:110
+msgid ""
+"We use structs to add meaning by labeling the data. We can transform the "
+"tuple we’re using into a struct with a name for the whole as well as names "
+"for the parts, as shown in Listing 5-10."
+msgstr ""
+
+#: src/ch05-02-example-structs.md:139
+msgid ""
+"Listing 5-10: Defining a `Rectangle` struct"
+msgstr ""
+
+#: src/ch05-02-example-structs.md:141
+msgid ""
+"Here we’ve defined a struct and named it `Rectangle`. Inside the curly "
+"brackets, we defined the fields as `width` and `height`, both of which have "
+"type `u32`. Then, in `main`, we created a particular instance of `Rectangle` "
+"that has a width of `30` and a height of `50`."
+msgstr ""
+
+#: src/ch05-02-example-structs.md:146
+msgid ""
+"Our `area` function is now defined with one parameter, which we’ve named "
+"`rectangle`, whose type is an immutable borrow of a struct `Rectangle` "
+"instance. As mentioned in Chapter 4, we want to borrow the struct rather "
+"than take ownership of it. This way, `main` retains its ownership and can "
+"continue using `rect1`, which is the reason we use the `&` in the function "
+"signature and where we call the function."
+msgstr ""
+
+#: src/ch05-02-example-structs.md:153
+msgid ""
+"The `area` function accesses the `width` and `height` fields of the "
+"`Rectangle` instance (note that accessing fields of a borrowed struct "
+"instance does not move the field values, which is why you often see borrows "
+"of structs). Our function signature for `area` now says exactly what we "
+"mean: calculate the area of `Rectangle`, using its `width` and `height` "
+"fields. This conveys that the width and height are related to each other, "
+"and it gives descriptive names to the values rather than using the tuple "
+"index values of `0` and `1`. This is a win for clarity."
+msgstr ""
+
+#: src/ch05-02-example-structs.md:162
+msgid "Adding Useful Functionality with Derived Traits"
+msgstr ""
+
+#: src/ch05-02-example-structs.md:164
+msgid ""
+"It’d be useful to be able to print an instance of `Rectangle` while we’re "
+"debugging our program and see the values for all its fields. Listing 5-11 "
+"tries using the [`println!` macro](../std/macro.println.html) "
+"as we have used in previous chapters. This won’t work, however."
+msgstr ""
+
+#: src/ch05-02-example-structs.md:183
+msgid "\"rect1 is {}\""
+msgstr ""
+
+#: src/ch05-02-example-structs.md:187
+msgid ""
+"Listing 5-11: Attempting to print a `Rectangle` "
+"instance"
+msgstr ""
+
+#: src/ch05-02-example-structs.md:190
+msgid "When we compile this code, we get an error with this core message:"
+msgstr ""
+
+#: src/ch05-02-example-structs.md:196
+msgid ""
+"The `println!` macro can do many kinds of formatting, and by default, the "
+"curly brackets tell `println!` to use formatting known as `Display`: output "
+"intended for direct end user consumption. The primitive types we’ve seen so "
+"far implement `Display` by default because there’s only one way you’d want "
+"to show a `1` or any other primitive type to a user. But with structs, the "
+"way `println!` should format the output is less clear because there are more "
+"display possibilities: Do you want commas or not? Do you want to print the "
+"curly brackets? Should all the fields be shown? Due to this ambiguity, Rust "
+"doesn’t try to guess what we want, and structs don’t have a provided "
+"implementation of `Display` to use with `println!` and the `{}` placeholder."
+msgstr ""
+
+#: src/ch05-02-example-structs.md:207
+msgid "If we continue reading the errors, we’ll find this helpful note:"
+msgstr ""
+
+#: src/ch05-02-example-structs.md:214
+msgid ""
+"Let’s try it! The `println!` macro call will now look like `println!(\"rect1 "
+"is {rect1:?}\");`. Putting the specifier `:?` inside the curly brackets "
+"tells `println!` we want to use an output format called `Debug`. The `Debug` "
+"trait enables us to print our struct in a way that is useful for developers "
+"so we can see its value while we’re debugging our code."
+msgstr ""
+
+#: src/ch05-02-example-structs.md:220
+msgid "Compile the code with this change. Drat! We still get an error:"
+msgstr ""
+
+#: src/ch05-02-example-structs.md:226
+msgid "But again, the compiler gives us a helpful note:"
+msgstr ""
+
+#: src/ch05-02-example-structs.md:233
+msgid ""
+"Rust _does_ include functionality to print out debugging information, but we "
+"have to explicitly opt in to make that functionality available for our "
+"struct. To do that, we add the outer attribute `#[derive(Debug)]` just "
+"before the struct definition, as shown in Listing 5-12."
+msgstr ""
+
+#: src/ch05-02-example-structs.md:253
+msgid "\"rect1 is {rect1:?}\""
+msgstr ""
+
+#: src/ch05-02-example-structs.md:257
+msgid ""
+"Listing 5-12: Adding the attribute to derive the "
+"`Debug` trait and printing the `Rectangle` instance using debug formatting"
+"span>"
+msgstr ""
+
+#: src/ch05-02-example-structs.md:260
+msgid ""
+"Now when we run the program, we won’t get any errors, and we’ll see the "
+"following output:"
+msgstr ""
+
+#: src/ch05-02-example-structs.md:263
+msgid ""
+"```console\n"
+"$ cargo run\n"
+" Compiling rectangles v0.1.0 (file:///projects/rectangles)\n"
+" Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.48s\n"
+" Running `target/debug/rectangles`\n"
+"rect1 is Rectangle { width: 30, height: 50 }\n"
+"```"
+msgstr ""
+
+#: src/ch05-02-example-structs.md:271
+msgid ""
+"Nice! It’s not the prettiest output, but it shows the values of all the "
+"fields for this instance, which would definitely help during debugging. When "
+"we have larger structs, it’s useful to have output that’s a bit easier to "
+"read; in those cases, we can use `{:#?}` instead of `{:?}` in the `println!` "
+"string. In this example, using the `{:#?}` style will output the following:"
+msgstr ""
+
+#: src/ch05-02-example-structs.md:277
+msgid ""
+"```console\n"
+"$ cargo run\n"
+" Compiling rectangles v0.1.0 (file:///projects/rectangles)\n"
+" Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.48s\n"
+" Running `target/debug/rectangles`\n"
+"rect1 is Rectangle {\n"
+" width: 30,\n"
+" height: 50,\n"
+"}\n"
+"```"
+msgstr ""
+
+#: src/ch05-02-example-structs.md:288
+msgid ""
+"Another way to print out a value using the `Debug` format is to use the "
+"[`dbg!` macro](../std/macro.dbg.html), which takes ownership "
+"of an expression (as opposed to `println!`, which takes a reference), prints "
+"the file and line number of where that `dbg!` macro call occurs in your code "
+"along with the resultant value of that expression, and returns ownership of "
+"the value."
+msgstr ""
+
+#: src/ch05-02-example-structs.md:294
+msgid ""
+"Note: Calling the `dbg!` macro prints to the standard error console stream "
+"(`stderr`), as opposed to `println!`, which prints to the standard output "
+"console stream (`stdout`). We’ll talk more about `stderr` and `stdout` in "
+"the [“Writing Error Messages to Standard Error Instead of Standard Output” "
+"section in Chapter 12](ch12-06-writing-to-stderr-instead-of-stdout.html)."
+msgstr ""
+
+#: src/ch05-02-example-structs.md:300
+msgid ""
+"Here’s an example where we’re interested in the value that gets assigned to "
+"the `width` field, as well as the value of the whole struct in `rect1`:"
+msgstr ""
+
+#: src/ch05-02-example-structs.md:321
+msgid ""
+"We can put `dbg!` around the expression `30 * scale` and, because `dbg!` "
+"returns ownership of the expression’s value, the `width` field will get the "
+"same value as if we didn’t have the `dbg!` call there. We don’t want `dbg!` "
+"to take ownership of `rect1`, so we use a reference to `rect1` in the next "
+"call. Here’s what the output of this example looks like:"
+msgstr ""
+
+#: src/ch05-02-example-structs.md:327
+msgid ""
+"```console\n"
+"$ cargo run\n"
+" Compiling rectangles v0.1.0 (file:///projects/rectangles)\n"
+" Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.61s\n"
+" Running `target/debug/rectangles`\n"
+"[src/main.rs:10:16] 30 * scale = 60\n"
+"[src/main.rs:14:5] &rect1 = Rectangle {\n"
+" width: 60,\n"
+" height: 50,\n"
+"}\n"
+"```"
+msgstr ""
+
+#: src/ch05-02-example-structs.md:339
+msgid ""
+"We can see the first bit of output came from _src/main.rs_ line 10 where "
+"we’re debugging the expression `30 * scale`, and its resultant value is `60` "
+"(the `Debug` formatting implemented for integers is to print only their "
+"value). The `dbg!` call on line 14 of _src/main.rs_ outputs the value of "
+"`&rect1`, which is the `Rectangle` struct. This output uses the pretty "
+"`Debug` formatting of the `Rectangle` type. The `dbg!` macro can be really "
+"helpful when you’re trying to figure out what your code is doing!"
+msgstr ""
+
+#: src/ch05-02-example-structs.md:347
+msgid ""
+"In addition to the `Debug` trait, Rust has provided a number of traits for "
+"us to use with the `derive` attribute that can add useful behavior to our "
+"custom types. Those traits and their behaviors are listed in [Appendix C]"
+"(appendix-03-derivable-traits.md). We’ll cover how to implement these traits with custom behavior "
+"as well as how to create your own traits in Chapter 10. There are also many "
+"attributes other than `derive`; for more information, see [the “Attributes” "
+"section of the Rust Reference](../reference/attributes.html)."
+msgstr ""
+
+#: src/ch05-02-example-structs.md:355
+msgid ""
+"Our `area` function is very specific: it only computes the area of "
+"rectangles. It would be helpful to tie this behavior more closely to our "
+"`Rectangle` struct because it won’t work with any other type. Let’s look at "
+"how we can continue to refactor this code by turning the `area` function "
+"into an `area` _method_ defined on our `Rectangle` type."
+msgstr ""
+
+#: src/ch05-03-method-syntax.md:3
+msgid ""
+"_Methods_ are similar to functions: we declare them with the `fn` keyword "
+"and a name, they can have parameters and a return value, and they contain "
+"some code that’s run when the method is called from somewhere else. Unlike "
+"functions, methods are defined within the context of a struct (or an enum or "
+"a trait object, which we cover in [Chapter 6](ch06-00-enums.html) and [Chapter 17](ch17-02-trait-objects.md), "
+"respectively), and their first parameter is always `self`, which represents "
+"the instance of the struct the method is being called on."
+msgstr ""
+
+#: src/ch05-03-method-syntax.md:12
+msgid "Defining Methods"
+msgstr ""
+
+#: src/ch05-03-method-syntax.md:14
+msgid ""
+"Let’s change the `area` function that has a `Rectangle` instance as a "
+"parameter and instead make an `area` method defined on the `Rectangle` "
+"struct, as shown in Listing 5-13."
+msgstr ""
+
+#: src/ch05-03-method-syntax.md:46
+msgid ""
+"Listing 5-13: Defining an `area` method on the "
+"`Rectangle` struct"
+msgstr ""
+
+#: src/ch05-03-method-syntax.md:49
+msgid ""
+"To define the function within the context of `Rectangle`, we start an `impl` "
+"(implementation) block for `Rectangle`. Everything within this `impl` block "
+"will be associated with the `Rectangle` type. Then we move the `area` "
+"function within the `impl` curly brackets and change the first (and in this "
+"case, only) parameter to be `self` in the signature and everywhere within "
+"the body. In `main`, where we called the `area` function and passed `rect1` "
+"as an argument, we can instead use _method syntax_ to call the `area` method "
+"on our `Rectangle` instance. The method syntax goes after an instance: we "
+"add a dot followed by the method name, parentheses, and any arguments."
+msgstr ""
+
+#: src/ch05-03-method-syntax.md:59
+msgid ""
+"In the signature for `area`, we use `&self` instead of `rectangle: "
+"&Rectangle`. The `&self` is actually short for `self: &Self`. Within an "
+"`impl` block, the type `Self` is an alias for the type that the `impl` block "
+"is for. Methods must have a parameter named `self` of type `Self` for their "
+"first parameter, so Rust lets you abbreviate this with only the name `self` "
+"in the first parameter spot. Note that we still need to use the `&` in front "
+"of the `self` shorthand to indicate that this method borrows the `Self` "
+"instance, just as we did in `rectangle: &Rectangle`. Methods can take "
+"ownership of `self`, borrow `self` immutably, as we’ve done here, or borrow "
+"`self` mutably, just as they can any other parameter."
+msgstr ""
+
+#: src/ch05-03-method-syntax.md:70
+msgid ""
+"We chose `&self` here for the same reason we used `&Rectangle` in the "
+"function version: we don’t want to take ownership, and we just want to read "
+"the data in the struct, not write to it. If we wanted to change the instance "
+"that we’ve called the method on as part of what the method does, we’d use "
+"`&mut self` as the first parameter. Having a method that takes ownership of "
+"the instance by using just `self` as the first parameter is rare; this "
+"technique is usually used when the method transforms `self` into something "
+"else and you want to prevent the caller from using the original instance "
+"after the transformation."
+msgstr ""
+
+#: src/ch05-03-method-syntax.md:79
+msgid ""
+"The main reason for using methods instead of functions, in addition to "
+"providing method syntax and not having to repeat the type of `self` in every "
+"method’s signature, is for organization. We’ve put all the things we can do "
+"with an instance of a type in one `impl` block rather than making future "
+"users of our code search for capabilities of `Rectangle` in various places "
+"in the library we provide."
+msgstr ""
+
+#: src/ch05-03-method-syntax.md:86
+msgid ""
+"Note that we can choose to give a method the same name as one of the "
+"struct’s fields. For example, we can define a method on `Rectangle` that is "
+"also named `width`:"
+msgstr ""
+
+#: src/ch05-03-method-syntax.md:112
+msgid "\"The rectangle has a nonzero width; it is {}\""
+msgstr ""
+
+#: src/ch05-03-method-syntax.md:117
+msgid ""
+"Here, we’re choosing to make the `width` method return `true` if the value "
+"in the instance’s `width` field is greater than `0` and `false` if the value "
+"is `0`: we can use a field within a method of the same name for any purpose. "
+"In `main`, when we follow `rect1.width` with parentheses, Rust knows we mean "
+"the method `width`. When we don’t use parentheses, Rust knows we mean the "
+"field `width`."
+msgstr ""
+
+#: src/ch05-03-method-syntax.md:124
+msgid ""
+"Often, but not always, when we give a method the same name as a field we "
+"want it to only return the value in the field and do nothing else. Methods "
+"like this are called _getters_, and Rust does not implement them "
+"automatically for struct fields as some other languages do. Getters are "
+"useful because you can make the field private but the method public, and "
+"thus enable read-only access to that field as part of the type’s public API. "
+"We will discuss what public and private are and how to designate a field or "
+"method as public or private in [Chapter 7](ch07-03-paths-for-referring-to-an-"
+"item-in-the-module-tree.html#exposing-paths-with-the-pub-keyword)."
+msgstr ""
+
+#: src/ch05-03-method-syntax.md:133
+msgid "Where’s the `->` Operator?"
+msgstr ""
+
+#: src/ch05-03-method-syntax.md:135
+msgid ""
+"In C and C++, two different operators are used for calling methods: you use "
+"`.` if you’re calling a method on the object directly and `->` if you’re "
+"calling the method on a pointer to the object and need to dereference the "
+"pointer first. In other words, if `object` is a pointer, `object-"
+">something()` is similar to `(*object).something()`."
+msgstr ""
+
+#: src/ch05-03-method-syntax.md:141
+msgid ""
+"Rust doesn’t have an equivalent to the `->` operator; instead, Rust has a "
+"feature called _automatic referencing and dereferencing_. Calling methods is "
+"one of the few places in Rust that has this behavior."
+msgstr ""
+
+#: src/ch05-03-method-syntax.md:145
+msgid ""
+"Here’s how it works: when you call a method with `object.something()`, Rust "
+"automatically adds in `&`, `&mut`, or `*` so `object` matches the signature "
+"of the method. In other words, the following are the same:"
+msgstr ""
+
+#: src/ch05-03-method-syntax.md:171
+msgid ""
+"The first one looks much cleaner. This automatic referencing behavior works "
+"because methods have a clear receiver—the type of `self`. Given the receiver "
+"and name of a method, Rust can figure out definitively whether the method is "
+"reading (`&self`), mutating (`&mut self`), or consuming (`self`). The fact "
+"that Rust makes borrowing implicit for method receivers is a big part of "
+"making ownership ergonomic in practice."
+msgstr ""
+
+#: src/ch05-03-method-syntax.md:178
+msgid "Methods with More Parameters"
+msgstr ""
+
+#: src/ch05-03-method-syntax.md:180
+msgid ""
+"Let’s practice using methods by implementing a second method on the "
+"`Rectangle` struct. This time we want an instance of `Rectangle` to take "
+"another instance of `Rectangle` and return `true` if the second `Rectangle` "
+"can fit completely within `self` (the first `Rectangle`); otherwise, it "
+"should return `false`. That is, once we’ve defined the `can_hold` method, we "
+"want to be able to write the program shown in Listing 5-14."
+msgstr ""
+
+#: src/ch05-03-method-syntax.md:204 src/ch05-03-method-syntax.md:268
+#: src/ch05-03-method-syntax.md:370
+msgid "\"Can rect1 hold rect2? {}\""
+msgstr ""
+
+#: src/ch05-03-method-syntax.md:205 src/ch05-03-method-syntax.md:269
+#: src/ch05-03-method-syntax.md:371
+msgid "\"Can rect1 hold rect3? {}\""
+msgstr ""
+
+#: src/ch05-03-method-syntax.md:209
+msgid ""
+"Listing 5-14: Using the as-yet-unwritten `can_hold` "
+"method"
+msgstr ""
+
+#: src/ch05-03-method-syntax.md:212
+msgid ""
+"The expected output would look like the following because both dimensions of "
+"`rect2` are smaller than the dimensions of `rect1`, but `rect3` is wider "
+"than `rect1`:"
+msgstr ""
+
+#: src/ch05-03-method-syntax.md:221
+msgid ""
+"We know we want to define a method, so it will be within the `impl "
+"Rectangle` block. The method name will be `can_hold`, and it will take an "
+"immutable borrow of another `Rectangle` as a parameter. We can tell what the "
+"type of the parameter will be by looking at the code that calls the method: "
+"`rect1.can_hold(&rect2)` passes in `&rect2`, which is an immutable borrow to "
+"`rect2`, an instance of `Rectangle`. This makes sense because we only need "
+"to read `rect2` (rather than write, which would mean we’d need a mutable "
+"borrow), and we want `main` to retain ownership of `rect2` so we can use it "
+"again after calling the `can_hold` method. The return value of `can_hold` "
+"will be a Boolean, and the implementation will check whether the width and "
+"height of `self` are greater than the width and height of the other "
+"`Rectangle`, respectively. Let’s add the new `can_hold` method to the `impl` "
+"block from Listing 5-13, shown in Listing 5-15."
+msgstr ""
+
+#: src/ch05-03-method-syntax.md:273
+msgid ""
+"Listing 5-15: Implementing the `can_hold` method on "
+"`Rectangle` that takes another `Rectangle` instance as a parameter"
+msgstr ""
+
+#: src/ch05-03-method-syntax.md:276
+msgid ""
+"When we run this code with the `main` function in Listing 5-14, we’ll get "
+"our desired output. Methods can take multiple parameters that we add to the "
+"signature after the `self` parameter, and those parameters work just like "
+"parameters in functions."
+msgstr ""
+
+#: src/ch05-03-method-syntax.md:281
+msgid "Associated Functions"
+msgstr ""
+
+#: src/ch05-03-method-syntax.md:283
+msgid ""
+"All functions defined within an `impl` block are called _associated "
+"functions_ because they’re associated with the type named after the `impl`. "
+"We can define associated functions that don’t have `self` as their first "
+"parameter (and thus are not methods) because they don’t need an instance of "
+"the type to work with. We’ve already used one function like this: the "
+"`String::from` function that’s defined on the `String` type."
+msgstr ""
+
+#: src/ch05-03-method-syntax.md:290
+msgid ""
+"Associated functions that aren’t methods are often used for constructors "
+"that will return a new instance of the struct. These are often called `new`, "
+"but `new` isn’t a special name and isn’t built into the language. For "
+"example, we could choose to provide an associated function named `square` "
+"that would have one dimension parameter and use that as both width and "
+"height, thus making it easier to create a square `Rectangle` rather than "
+"having to specify the same value twice:"
+msgstr ""
+
+#: src/ch05-03-method-syntax.md:321
+msgid ""
+"The `Self` keywords in the return type and in the body of the function are "
+"aliases for the type that appears after the `impl` keyword, which in this "
+"case is `Rectangle`."
+msgstr ""
+
+#: src/ch05-03-method-syntax.md:325
+msgid ""
+"To call this associated function, we use the `::` syntax with the struct "
+"name; `let sq = Rectangle::square(3);` is an example. This function is "
+"namespaced by the struct: the `::` syntax is used for both associated "
+"functions and namespaces created by modules. We’ll discuss modules in "
+"[Chapter 7](ch07-02-defining-modules-to-control-scope-and-privacy.html)."
+msgstr ""
+
+#: src/ch05-03-method-syntax.md:331
+msgid "Multiple `impl` Blocks"
+msgstr ""
+
+#: src/ch05-03-method-syntax.md:333
+msgid ""
+"Each struct is allowed to have multiple `impl` blocks. For example, Listing "
+"5-15 is equivalent to the code shown in Listing 5-16, which has each method "
+"in its own `impl` block."
+msgstr ""
+
+#: src/ch05-03-method-syntax.md:375
+msgid ""
+"Listing 5-16: Rewriting Listing 5-15 using multiple "
+"`impl` blocks"
+msgstr ""
+
+#: src/ch05-03-method-syntax.md:378
+msgid ""
+"There’s no reason to separate these methods into multiple `impl` blocks "
+"here, but this is valid syntax. We’ll see a case in which multiple `impl` "
+"blocks are useful in Chapter 10, where we discuss generic types and traits."
+msgstr ""
+
+#: src/ch05-03-method-syntax.md:384
+msgid ""
+"Structs let you create custom types that are meaningful for your domain. By "
+"using structs, you can keep associated pieces of data connected to each "
+"other and name each piece to make your code clear. In `impl` blocks, you can "
+"define functions that are associated with your type, and methods are a kind "
+"of associated function that let you specify the behavior that instances of "
+"your structs have."
+msgstr ""
+
+#: src/ch05-03-method-syntax.md:391
+msgid ""
+"But structs aren’t the only way you can create custom types: let’s turn to "
+"Rust’s enum feature to add another tool to your toolbox."
+msgstr ""
+
+#: src/ch06-00-enums.md:3
+msgid ""
+"In this chapter, we’ll look at _enumerations_, also referred to as _enums_. "
+"Enums allow you to define a type by enumerating its possible _variants_. "
+"First we’ll define and use an enum to show how an enum can encode meaning "
+"along with data. Next, we’ll explore a particularly useful enum, called "
+"`Option`, which expresses that a value can be either something or nothing. "
+"Then we’ll look at how pattern matching in the `match` expression makes it "
+"easy to run different code for different values of an enum. Finally, we’ll "
+"cover how the `if let` construct is another convenient and concise idiom "
+"available to handle enums in your code."
+msgstr ""
+
+#: src/ch06-01-defining-an-enum.md:3
+msgid ""
+"Where structs give you a way of grouping together related fields and data, "
+"like a `Rectangle` with its `width` and `height`, enums give you a way of "
+"saying a value is one of a possible set of values. For example, we may want "
+"to say that `Rectangle` is one of a set of possible shapes that also "
+"includes `Circle` and `Triangle`. To do this, Rust allows us to encode these "
+"possibilities as an enum."
+msgstr ""
+
+#: src/ch06-01-defining-an-enum.md:9
+msgid ""
+"Let’s look at a situation we might want to express in code and see why enums "
+"are useful and more appropriate than structs in this case. Say we need to "
+"work with IP addresses. Currently, two major standards are used for IP "
+"addresses: version four and version six. Because these are the only "
+"possibilities for an IP address that our program will come across, we can "
+"_enumerate_ all possible variants, which is where enumeration gets its name."
+msgstr ""
+
+#: src/ch06-01-defining-an-enum.md:16
+msgid ""
+"Any IP address can be either a version four or a version six address, but "
+"not both at the same time. That property of IP addresses makes the enum data "
+"structure appropriate because an enum value can only be one of its variants. "
+"Both version four and version six addresses are still fundamentally IP "
+"addresses, so they should be treated as the same type when the code is "
+"handling situations that apply to any kind of IP address."
+msgstr ""
+
+#: src/ch06-01-defining-an-enum.md:23
+msgid ""
+"We can express this concept in code by defining an `IpAddrKind` enumeration "
+"and listing the possible kinds an IP address can be, `V4` and `V6`. These "
+"are the variants of the enum:"
+msgstr ""
+
+#: src/ch06-01-defining-an-enum.md:44
+msgid ""
+"`IpAddrKind` is now a custom data type that we can use elsewhere in our code."
+msgstr ""
+
+#: src/ch06-01-defining-an-enum.md:46
+msgid "Enum Values"
+msgstr ""
+
+#: src/ch06-01-defining-an-enum.md:48
+msgid ""
+"We can create instances of each of the two variants of `IpAddrKind` like "
+"this:"
+msgstr ""
+
+#: src/ch06-01-defining-an-enum.md:67
+msgid ""
+"Note that the variants of the enum are namespaced under its identifier, and "
+"we use a double colon to separate the two. This is useful because now both "
+"values `IpAddrKind::V4` and `IpAddrKind::V6` are of the same type: "
+"`IpAddrKind`. We can then, for instance, define a function that takes any "
+"`IpAddrKind`:"
+msgstr ""
+
+#: src/ch06-01-defining-an-enum.md:89
+msgid "And we can call this function with either variant:"
+msgstr ""
+
+#: src/ch06-01-defining-an-enum.md:108
+msgid ""
+"Using enums has even more advantages. Thinking more about our IP address "
+"type, at the moment we don’t have a way to store the actual IP address "
+"_data_; we 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."
+msgstr ""
+
+#: src/ch06-01-defining-an-enum.md:128 src/ch06-01-defining-an-enum.md:162
+#: src/ch09-03-to-panic-or-not-to-panic.md:53
+msgid "\"127.0.0.1\""
+msgstr ""
+
+#: src/ch06-01-defining-an-enum.md:133 src/ch06-01-defining-an-enum.md:164
+#: src/ch06-01-defining-an-enum.md:192
+msgid "\"::1\""
+msgstr ""
+
+#: src/ch06-01-defining-an-enum.md:138
+msgid ""
+"Listing 6-1: Storing the data and `IpAddrKind` "
+"variant of an IP address using a `struct`"
+msgstr ""
+
+#: src/ch06-01-defining-an-enum.md:141
+msgid ""
+"Here, we’ve defined a struct `IpAddr` that has two fields: a `kind` field "
+"that is of type `IpAddrKind` (the enum we defined previously) and an "
+"`address` field of type `String`. We have two instances of this struct. The "
+"first is `home`, and it has the value `IpAddrKind::V4` as its `kind` with "
+"associated address data of `127.0.0.1`. The second instance is `loopback`. "
+"It has the other variant of `IpAddrKind` as its `kind` value, `V6`, and has "
+"address `::1` associated with it. We’ve used a struct to bundle the `kind` "
+"and `address` values together, so now the variant is associated with the "
+"value."
+msgstr ""
+
+#: src/ch06-01-defining-an-enum.md:150
+msgid ""
+"However, representing the same concept using just an enum is more concise: "
+"rather than an enum inside a struct, we can put data directly into each enum "
+"variant. This new definition of the `IpAddr` enum says that both `V4` and "
+"`V6` variants will have associated `String` values:"
+msgstr ""
+
+#: src/ch06-01-defining-an-enum.md:168
+msgid ""
+"We attach data to each variant of the enum directly, so there is no need for "
+"an extra struct. Here, it’s also easier to see another detail of how enums "
+"work: the name of each enum variant that we define also becomes a function "
+"that constructs an instance of the enum. That is, `IpAddr::V4()` is a "
+"function call that takes a `String` argument and returns an instance of the "
+"`IpAddr` type. We automatically get this constructor function defined as a "
+"result of defining the enum."
+msgstr ""
+
+#: src/ch06-01-defining-an-enum.md:176
+msgid ""
+"There’s another advantage to using an enum rather than a struct: each "
+"variant can have different types and amounts of associated data. Version "
+"four IP addresses will always have four numeric components that will have "
+"values between 0 and 255. If we wanted to store `V4` addresses as four `u8` "
+"values but still express `V6` addresses as one `String` value, we wouldn’t "
+"be able to with a struct. Enums handle this case with ease:"
+msgstr ""
+
+#: src/ch06-01-defining-an-enum.md:196
+msgid ""
+"We’ve shown several different ways to define data structures to store "
+"version four and version six IP addresses. However, as it turns out, wanting "
+"to store IP addresses and encode which kind they are is so common that [the "
+"standard library has a definition we can use!](../std/net/enum.IpAddr."
+"html) Let’s look at how the standard library defines "
+"`IpAddr`: it has the exact enum and variants that we’ve defined and used, "
+"but it embeds the address data inside the variants in the form of two "
+"different structs, which are defined differently for each variant:"
+msgstr ""
+
+#: src/ch06-01-defining-an-enum.md:220
+msgid ""
+"This code illustrates that you can put any kind of data inside an enum "
+"variant: strings, numeric types, or structs, for example. You can even "
+"include another enum! Also, standard library types are often not much more "
+"complicated than what you might come up with."
+msgstr ""
+
+#: src/ch06-01-defining-an-enum.md:225
+msgid ""
+"Note that even though the standard library contains a definition for "
+"`IpAddr`, we can still create and use our own definition without conflict "
+"because we haven’t brought the standard library’s definition into our scope. "
+"We’ll talk more about bringing types into scope in Chapter 7."
+msgstr ""
+
+#: src/ch06-01-defining-an-enum.md:230
+msgid ""
+"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."
+msgstr ""
+
+#: src/ch06-01-defining-an-enum.md:244
+msgid ""
+"Listing 6-2: A `Message` enum whose variants each "
+"store different amounts and types of values"
+msgstr ""
+
+#: src/ch06-01-defining-an-enum.md:247
+msgid "This enum has four variants with different types:"
+msgstr ""
+
+#: src/ch06-01-defining-an-enum.md:249
+msgid "`Quit` has no data associated with it at all."
+msgstr ""
+
+#: src/ch06-01-defining-an-enum.md:250
+msgid "`Move` has named fields, like a struct does."
+msgstr ""
+
+#: src/ch06-01-defining-an-enum.md:251
+msgid "`Write` includes a single `String`."
+msgstr ""
+
+#: src/ch06-01-defining-an-enum.md:252
+msgid "`ChangeColor` includes three `i32` values."
+msgstr ""
+
+#: src/ch06-01-defining-an-enum.md:254
+msgid ""
+"Defining an enum with variants such as the ones in Listing 6-2 is similar to "
+"defining different kinds of struct definitions, except the enum doesn’t use "
+"the `struct` keyword and all the variants are grouped together under the "
+"`Message` type. The following structs could hold the same data that the "
+"preceding enum variants hold:"
+msgstr ""
+
+#: src/ch06-01-defining-an-enum.md:261
+msgid "// unit struct\n"
+msgstr ""
+
+#: src/ch06-01-defining-an-enum.md:266 src/ch06-01-defining-an-enum.md:267
+msgid "// tuple struct\n"
+msgstr ""
+
+#: src/ch06-01-defining-an-enum.md:272
+msgid ""
+"But if we used the different structs, each of which has its own type, we "
+"couldn’t as easily define a function to take any of these kinds of messages "
+"as we could with the `Message` enum defined in Listing 6-2, which is a "
+"single type."
+msgstr ""
+
+#: src/ch06-01-defining-an-enum.md:276
+msgid ""
+"There is one more similarity between enums and structs: just as we’re able "
+"to define methods on structs using `impl`, we’re also able to define methods "
+"on enums. Here’s a method named `call` that we could define on our `Message` "
+"enum:"
+msgstr ""
+
+#: src/ch06-01-defining-an-enum.md:291
+msgid "// method body would be defined here\n"
+msgstr ""
+
+#: src/ch06-01-defining-an-enum.md:300
+msgid ""
+"The body of the method would use `self` to get the value that we called the "
+"method on. In this example, we’ve created a variable `m` that has the value "
+"`Message::Write(String::from(\"hello\"))`, and that is what `self` will be "
+"in the body of the `call` method when `m.call()` runs."
+msgstr ""
+
+#: src/ch06-01-defining-an-enum.md:305
+msgid ""
+"Let’s look at another enum in the standard library that is very common and "
+"useful: `Option`."
+msgstr ""
+
+#: src/ch06-01-defining-an-enum.md:308
+msgid "The `Option` Enum and Its Advantages Over Null Values"
+msgstr ""
+
+#: src/ch06-01-defining-an-enum.md:310
+msgid ""
+"This section explores a case study of `Option`, which is another enum "
+"defined by the standard library. The `Option` type encodes the very common "
+"scenario in which a value could be something or it could be nothing."
+msgstr ""
+
+#: src/ch06-01-defining-an-enum.md:314
+msgid ""
+"For example, if you request the first item in a non-empty list, you would "
+"get a value. If you request the first item in an empty list, you would get "
+"nothing. Expressing this concept in terms of the type system means the "
+"compiler can check whether you’ve handled all the cases you should be "
+"handling; this functionality can prevent bugs that are extremely common in "
+"other programming languages."
+msgstr ""
+
+#: src/ch06-01-defining-an-enum.md:321
+msgid ""
+"Programming language design is often thought of in terms of which features "
+"you include, but the features you exclude are important too. Rust doesn’t "
+"have the null feature that many other languages have. _Null_ is a value that "
+"means there is no value there. In languages with null, variables can always "
+"be in one of two states: null or not-null."
+msgstr ""
+
+#: src/ch06-01-defining-an-enum.md:327
+msgid ""
+"In his 2009 presentation “Null References: The Billion Dollar Mistake,” Tony "
+"Hoare, the inventor of null, has this to say:"
+msgstr ""
+
+#: src/ch06-01-defining-an-enum.md:330
+msgid ""
+"I call it my billion-dollar mistake. At that time, I was designing the first "
+"comprehensive type system for references in an object-oriented language. My "
+"goal was to ensure that all use of references should be absolutely safe, "
+"with checking performed automatically by the compiler. But I couldn’t resist "
+"the temptation to put in a null reference, simply because it was so easy to "
+"implement. This has led to innumerable errors, vulnerabilities, and system "
+"crashes, which have probably caused a billion dollars of pain and damage in "
+"the last forty years."
+msgstr ""
+
+#: src/ch06-01-defining-an-enum.md:339
+msgid ""
+"The problem with null values is that if you try to use a null value as a not-"
+"null value, you’ll get an error of some kind. Because this null or not-null "
+"property is pervasive, it’s extremely easy to make this kind of error."
+msgstr ""
+
+#: src/ch06-01-defining-an-enum.md:343
+msgid ""
+"However, the concept that null is trying to express is still a useful one: a "
+"null is a value that is currently invalid or absent for some reason."
+msgstr ""
+
+#: src/ch06-01-defining-an-enum.md:346
+msgid ""
+"The problem isn’t really with the concept but with the particular "
+"implementation. As such, Rust does not have nulls, but it does have an enum "
+"that can encode the concept of a value being present or absent. This enum is "
+"`Option`, and it is [defined by the standard library](../std/option/enum."
+"Option.html) as follows:"
+msgstr ""
+
+#: src/ch06-01-defining-an-enum.md:359
+msgid ""
+"The `Option` enum is so useful that it’s even included in the prelude; "
+"you don’t need to bring it into scope explicitly. Its variants are also "
+"included in the prelude: you can use `Some` and `None` directly without the "
+"`Option::` prefix. The `Option` enum is still just a regular enum, and "
+"`Some(T)` and `None` are still variants of type `Option`."
+msgstr ""
+
+#: src/ch06-01-defining-an-enum.md:365
+msgid ""
+"The `` syntax is a feature of Rust we haven’t talked about yet. It’s a "
+"generic type parameter, and we’ll cover generics in more detail in Chapter "
+"10. For now, all you need to know is that `` means that the `Some` "
+"variant of the `Option` enum can hold one piece of data of any type, and "
+"that each concrete type that gets used in place of `T` makes the overall "
+"`Option` type a different type. Here are some examples of using `Option` "
+"values to hold number types and string types:"
+msgstr ""
+
+#: src/ch06-01-defining-an-enum.md:376
+msgid "'e'"
+msgstr ""
+
+#: src/ch06-01-defining-an-enum.md:382
+msgid ""
+"The type of `some_number` is `Option`. The type of `some_char` is "
+"`Option`, which is a different type. Rust can infer these types "
+"because we’ve specified a value inside the `Some` variant. For "
+"`absent_number`, Rust requires us to annotate the overall `Option` type: the "
+"compiler can’t infer the type that the corresponding `Some` variant will "
+"hold by looking only at a `None` value. Here, we tell Rust that we mean for "
+"`absent_number` to be of type `Option`."
+msgstr ""
+
+#: src/ch06-01-defining-an-enum.md:390
+msgid ""
+"When we have a `Some` value, we know that a value is present and the value "
+"is held within the `Some`. When we have a `None` value, in some sense it "
+"means the same thing as null: we don’t have a valid value. So why is having "
+"`Option` any better than having null?"
+msgstr ""
+
+#: src/ch06-01-defining-an-enum.md:395
+msgid ""
+"In short, because `Option` and `T` (where `T` can be any type) are "
+"different types, the compiler won’t let us use an `Option` value as if it "
+"were definitely a valid value. For example, this code won’t compile, because "
+"it’s trying to add an `i8` to an `Option`:"
+msgstr ""
+
+#: src/ch06-01-defining-an-enum.md:409
+msgid "If we run this code, we get an error message like this one:"
+msgstr ""
+
+#: src/ch06-01-defining-an-enum.md:411
+msgid ""
+"```console\n"
+"$ cargo run\n"
+" Compiling enums v0.1.0 (file:///projects/enums)\n"
+"error[E0277]: cannot add `Option` to `i8`\n"
+" --> src/main.rs:5:17\n"
+" |\n"
+"5 | let sum = x + y;\n"
+" | ^ no implementation for `i8 + Option`\n"
+" |\n"
+" = help: the trait `Add