msgid ""
msgstr ""
"Project-Id-Version: Comprehensive Rust 🦀\n"
"POT-Creation-Date: \n"
"PO-Revision-Date: \n"
"Last-Translator: \n"
"Language-Team: \n"
"Language: da\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
#: src/SUMMARY.md:4 src/index.md:1
msgid "Welcome to Comprehensive Rust 🦀"
msgstr "Velkommen til Comprehensive Rust 🦀"
#: src/SUMMARY.md:5 src/running-the-course.md:1
msgid "Running the Course"
msgstr "Afvikling af kurset"
#: src/SUMMARY.md:6 src/running-the-course/course-structure.md:1
msgid "Course Structure"
msgstr "Kursets struktur"
#: src/SUMMARY.md:7 src/running-the-course/keyboard-shortcuts.md:1
msgid "Keyboard Shortcuts"
msgstr "Genvejstaster"
#: src/SUMMARY.md:8 src/running-the-course/translations.md:1
msgid "Translations"
msgstr "Oversættelser"
#: src/SUMMARY.md:9 src/cargo.md:1
msgid "Using Cargo"
msgstr "Brug af Cargo"
#: src/SUMMARY.md:10
msgid "Rust Ecosystem"
msgstr "Rust's økosystem"
#: src/SUMMARY.md:11
msgid "Code Samples"
msgstr "Kodeeksempler"
#: src/SUMMARY.md:12
msgid "Running Cargo Locally"
msgstr ""
#: src/SUMMARY.md:15
msgid "Day 1: Morning"
msgstr "Dag 1: Formiddag"
#: src/SUMMARY.md:19 src/SUMMARY.md:76 src/SUMMARY.md:130 src/SUMMARY.md:187
#: src/SUMMARY.md:213 src/SUMMARY.md:263
msgid "Welcome"
msgstr "Velkommen"
#: src/SUMMARY.md:20 src/welcome-day-1/what-is-rust.md:1
msgid "What is Rust?"
msgstr "Hvad er Rust?"
#: src/SUMMARY.md:21 src/hello-world.md:1
msgid "Hello World!"
msgstr "Hej verden!"
#: src/SUMMARY.md:22 src/hello-world/small-example.md:1
msgid "Small Example"
msgstr "Et little eksempel"
#: src/SUMMARY.md:23 src/why-rust.md:1
msgid "Why Rust?"
msgstr "Hvorfor bruge Rust?"
#: src/SUMMARY.md:24 src/why-rust/compile-time.md:1
msgid "Compile Time Guarantees"
msgstr "Garantier før programudføring"
#: src/SUMMARY.md:25 src/why-rust/runtime.md:1
msgid "Runtime Guarantees"
msgstr "Garantier under programudføring"
#: src/SUMMARY.md:26 src/why-rust/modern.md:1
msgid "Modern Features"
msgstr "Moderne faciliteter"
#: src/SUMMARY.md:27 src/basic-syntax.md:1
msgid "Basic Syntax"
msgstr "Grundlæggende syntaks"
#: src/SUMMARY.md:28 src/basic-syntax/scalar-types.md:1
msgid "Scalar Types"
msgstr "Skalartyper"
#: src/SUMMARY.md:29 src/basic-syntax/compound-types.md:1
msgid "Compound Types"
msgstr "Sammensatte typer"
#: src/SUMMARY.md:30 src/basic-syntax/references.md:1
msgid "References"
msgstr "Referencer"
#: src/SUMMARY.md:31 src/basic-syntax/references-dangling.md:1
msgid "Dangling References"
msgstr "Hængende referencer"
#: src/SUMMARY.md:32 src/basic-syntax/slices.md:1
msgid "Slices"
msgstr "Arraysegmenter"
#: src/SUMMARY.md:33
msgid "String vs str"
msgstr "String og str"
#: src/SUMMARY.md:34 src/basic-syntax/functions.md:1
msgid "Functions"
msgstr "Funktioner"
#: src/SUMMARY.md:35 src/basic-syntax/rustdoc.md:1
msgid "Rustdoc"
msgstr ""
#: src/SUMMARY.md:36 src/SUMMARY.md:83 src/basic-syntax/methods.md:1
#: src/methods.md:1
msgid "Methods"
msgstr "Metoder"
#: src/SUMMARY.md:37
msgid "Overloading"
msgstr "Funktionsoverlæsning"
#: src/SUMMARY.md:38 src/SUMMARY.md:67 src/SUMMARY.md:91 src/SUMMARY.md:121
#: src/SUMMARY.md:150 src/SUMMARY.md:179 src/SUMMARY.md:206 src/SUMMARY.md:227
#: src/SUMMARY.md:255 src/SUMMARY.md:277 src/SUMMARY.md:298
#: src/exercises/android/morning.md:1 src/exercises/bare-metal/morning.md:1
#: src/exercises/bare-metal/afternoon.md:1
#: src/exercises/concurrency/morning.md:1
#: src/exercises/concurrency/afternoon.md:1
msgid "Exercises"
msgstr "Øvelser"
#: src/SUMMARY.md:39 src/exercises/day-1/implicit-conversions.md:1
msgid "Implicit Conversions"
msgstr "Implicitte konverteringer"
#: src/SUMMARY.md:40
msgid "Arrays and for Loops"
msgstr "Arrays og for-løkker"
#: src/SUMMARY.md:42
msgid "Day 1: Afternoon"
msgstr "Dag 1: Eftermiddag"
#: src/SUMMARY.md:44 src/basic-syntax/variables.md:1
msgid "Variables"
msgstr "Variabler"
#: src/SUMMARY.md:45 src/basic-syntax/type-inference.md:1
msgid "Type Inference"
msgstr "Typeudledning"
#: src/SUMMARY.md:46
msgid "static & const"
msgstr "static & const"
#: src/SUMMARY.md:47 src/basic-syntax/scopes-shadowing.md:1
msgid "Scopes and Shadowing"
msgstr "Virkefelt og overskyggede variabler"
#: src/SUMMARY.md:48 src/memory-management.md:1
msgid "Memory Management"
msgstr "Håndtering af hukommelse"
#: src/SUMMARY.md:49
msgid "Stack vs Heap"
msgstr "Stak og heap"
#: src/SUMMARY.md:50
msgid "Stack Memory"
msgstr "Stakhukommelse"
#: src/SUMMARY.md:51 src/memory-management/manual.md:1
msgid "Manual Memory Management"
msgstr "Manuel hukommelseshåndtering"
#: src/SUMMARY.md:52 src/memory-management/scope-based.md:1
msgid "Scope-Based Memory Management"
msgstr "Hukommelseshåndtering baseret på virkefelt"
#: src/SUMMARY.md:53
msgid "Garbage Collection"
msgstr "Automatisk hukommelseshåndtering"
#: src/SUMMARY.md:54
msgid "Rust Memory Management"
msgstr "Hukommelseshåndtering i Rust"
#: src/SUMMARY.md:55 src/memory-management/comparison.md:1
msgid "Comparison"
msgstr "Sammenligning"
#: src/SUMMARY.md:56 src/ownership.md:1
msgid "Ownership"
msgstr "Ejerskab"
#: src/SUMMARY.md:57 src/ownership/move-semantics.md:1
msgid "Move Semantics"
msgstr "Overførselssemantik"
#: src/SUMMARY.md:58 src/ownership/moved-strings-rust.md:1
msgid "Moved Strings in Rust"
msgstr "Overførte strenge i Rust"
#: src/SUMMARY.md:59
msgid "Double Frees in Modern C++"
msgstr "Dobbeltfrigivelser i moderne C++"
#: src/SUMMARY.md:60 src/ownership/moves-function-calls.md:1
msgid "Moves in Function Calls"
msgstr "Overførsel af ejerskab i funktionskald"
#: src/SUMMARY.md:61 src/ownership/copy-clone.md:1
msgid "Copying and Cloning"
msgstr "Kopiering og kloning"
#: src/SUMMARY.md:62 src/ownership/borrowing.md:1
msgid "Borrowing"
msgstr "Lån af variabler"
#: src/SUMMARY.md:63 src/ownership/shared-unique-borrows.md:1
msgid "Shared and Unique Borrows"
msgstr "Delte og unikke lån"
#: src/SUMMARY.md:64 src/ownership/lifetimes.md:1
msgid "Lifetimes"
msgstr "Livstider"
#: src/SUMMARY.md:65 src/ownership/lifetimes-function-calls.md:1
msgid "Lifetimes in Function Calls"
msgstr "Livstider i funktionskald"
#: src/SUMMARY.md:66 src/ownership/lifetimes-data-structures.md:1
msgid "Lifetimes in Data Structures"
msgstr "Livstider i datastrukturer"
#: src/SUMMARY.md:68 src/exercises/day-1/book-library.md:1
#, fuzzy
msgid "Storing Books"
msgstr "String og str"
#: src/SUMMARY.md:69 src/exercises/day-1/iterators-and-ownership.md:1
msgid "Iterators and Ownership"
msgstr "Iteratorer og ejerskab"
#: src/SUMMARY.md:72
msgid "Day 2: Morning"
msgstr "Dag 2: Formiddag"
#: src/SUMMARY.md:77 src/structs.md:1
msgid "Structs"
msgstr "Strukturer"
#: src/SUMMARY.md:78 src/structs/tuple-structs.md:1
msgid "Tuple Structs"
msgstr "Tuple-strukturer"
#: src/SUMMARY.md:79 src/structs/field-shorthand.md:1
msgid "Field Shorthand Syntax"
msgstr "Forenklet strukturinitialisering"
#: src/SUMMARY.md:80 src/enums.md:1
msgid "Enums"
msgstr "Enumerationer"
#: src/SUMMARY.md:81 src/enums/variant-payloads.md:1
msgid "Variant Payloads"
msgstr "Nyttelast i varianter"
#: src/SUMMARY.md:82 src/enums/sizes.md:1
msgid "Enum Sizes"
msgstr "Størrelse af enumerationer"
#: src/SUMMARY.md:84 src/methods/receiver.md:1
msgid "Method Receiver"
msgstr "Modtager af funktionskald"
#: src/SUMMARY.md:85 src/SUMMARY.md:161 src/SUMMARY.md:276
#: src/methods/example.md:1 src/concurrency/shared_state/example.md:1
msgid "Example"
msgstr "Eksempel"
#: src/SUMMARY.md:86 src/pattern-matching.md:1
msgid "Pattern Matching"
msgstr "Mønstergenkendelse"
#: src/SUMMARY.md:87 src/pattern-matching/destructuring-enums.md:1
msgid "Destructuring Enums"
msgstr "Dekonstruktion af enumerationer"
#: src/SUMMARY.md:88 src/pattern-matching/destructuring-structs.md:1
msgid "Destructuring Structs"
msgstr "Dekonstruktion af strukturer"
#: src/SUMMARY.md:89 src/pattern-matching/destructuring-arrays.md:1
msgid "Destructuring Arrays"
msgstr "Dekonstruktion af arrays"
#: src/SUMMARY.md:90 src/pattern-matching/match-guards.md:1
msgid "Match Guards"
msgstr ""
#: src/SUMMARY.md:92 src/exercises/day-2/health-statistics.md:1
msgid "Health Statistics"
msgstr ""
#: src/SUMMARY.md:93 src/exercises/day-2/solutions-morning.md:3
msgid "Points and Polygons"
msgstr "Punkter og polygoner"
#: src/SUMMARY.md:95
msgid "Day 2: Afternoon"
msgstr "Dag 2: Eftermiddag"
#: src/SUMMARY.md:97 src/SUMMARY.md:290 src/control-flow.md:1
msgid "Control Flow"
msgstr "Forgreninger"
#: src/SUMMARY.md:98 src/control-flow/blocks.md:1
msgid "Blocks"
msgstr "Blokke"
#: src/SUMMARY.md:99
msgid "if expressions"
msgstr "if udtryk"
#: src/SUMMARY.md:100
msgid "if let expressions"
msgstr "if let udtryk"
#: src/SUMMARY.md:101
msgid "while expressions"
msgstr "while udtryk"
#: src/SUMMARY.md:102
msgid "while let expressions"
msgstr "while let udtryk"
#: src/SUMMARY.md:103
msgid "for expressions"
msgstr "for udtryk"
#: src/SUMMARY.md:104
msgid "loop expressions"
msgstr "loop udtryk"
#: src/SUMMARY.md:105
msgid "match expressions"
msgstr "match udtryk"
#: src/SUMMARY.md:106
msgid "break & continue"
msgstr "break og continue"
#: src/SUMMARY.md:107 src/std.md:1
msgid "Standard Library"
msgstr ""
#: src/SUMMARY.md:108
msgid "Option and Result"
msgstr ""
#: src/SUMMARY.md:109 src/std/string.md:1
msgid "String"
msgstr ""
#: src/SUMMARY.md:110
msgid "Vec"
msgstr ""
#: src/SUMMARY.md:111
msgid "HashMap"
msgstr ""
#: src/SUMMARY.md:112
msgid "Box"
msgstr ""
#: src/SUMMARY.md:113
msgid "Recursive Data Types"
msgstr ""
#: src/SUMMARY.md:114 src/std/box-niche.md:1
msgid "Niche Optimization"
msgstr ""
#: src/SUMMARY.md:115
msgid "Rc"
msgstr ""
#: src/SUMMARY.md:116
msgid "Cell/RefCell"
msgstr ""
#: src/SUMMARY.md:117 src/modules.md:1
msgid "Modules"
msgstr ""
#: src/SUMMARY.md:118 src/modules/visibility.md:1
msgid "Visibility"
msgstr ""
#: src/SUMMARY.md:119 src/modules/paths.md:1
msgid "Paths"
msgstr ""
#: src/SUMMARY.md:120 src/modules/filesystem.md:1
msgid "Filesystem Hierarchy"
msgstr ""
#: src/SUMMARY.md:122 src/exercises/day-2/luhn.md:1
#: src/exercises/day-2/solutions-afternoon.md:3
msgid "Luhn Algorithm"
msgstr "Luhn-algorithmen"
#: src/SUMMARY.md:123 src/exercises/day-2/strings-iterators.md:1
#: src/exercises/day-2/solutions-afternoon.md:97
msgid "Strings and Iterators"
msgstr "Strenge og iteratorer"
#: src/SUMMARY.md:126
msgid "Day 3: Morning"
msgstr ""
#: src/SUMMARY.md:131 src/generics.md:1
msgid "Generics"
msgstr ""
#: src/SUMMARY.md:132 src/generics/data-types.md:1
msgid "Generic Data Types"
msgstr ""
#: src/SUMMARY.md:133 src/generics/methods.md:1
msgid "Generic Methods"
msgstr ""
#: src/SUMMARY.md:134 src/generics/monomorphization.md:1
msgid "Monomorphization"
msgstr ""
#: src/SUMMARY.md:135 src/traits.md:1
msgid "Traits"
msgstr ""
#: src/SUMMARY.md:136 src/traits/trait-objects.md:1
msgid "Trait Objects"
msgstr ""
#: src/SUMMARY.md:137 src/traits/deriving-traits.md:1
msgid "Deriving Traits"
msgstr ""
#: src/SUMMARY.md:138 src/traits/default-methods.md:1
msgid "Default Methods"
msgstr ""
#: src/SUMMARY.md:139 src/traits/trait-bounds.md:1
msgid "Trait Bounds"
msgstr ""
#: src/SUMMARY.md:140
msgid "impl Trait"
msgstr ""
#: src/SUMMARY.md:141 src/traits/important-traits.md:1
msgid "Important Traits"
msgstr ""
#: src/SUMMARY.md:142
msgid "Iterator"
msgstr ""
#: src/SUMMARY.md:143 src/traits/from-iterator.md:1
msgid "FromIterator"
msgstr ""
#: src/SUMMARY.md:144
msgid "From and Into"
msgstr ""
#: src/SUMMARY.md:145
msgid "Read and Write"
msgstr ""
#: src/SUMMARY.md:146
msgid "Drop"
msgstr ""
#: src/SUMMARY.md:147
msgid "Default"
msgstr ""
#: src/SUMMARY.md:148
msgid "Operators: Add, Mul, ..."
msgstr ""
#: src/SUMMARY.md:149
msgid "Closures: Fn, FnMut, FnOnce"
msgstr ""
#: src/SUMMARY.md:151 src/exercises/day-3/simple-gui.md:1
#: src/exercises/day-3/solutions-morning.md:3
msgid "A Simple GUI Library"
msgstr ""
#: src/SUMMARY.md:153
msgid "Day 3: Afternoon"
msgstr ""
#: src/SUMMARY.md:155 src/error-handling.md:1
msgid "Error Handling"
msgstr ""
#: src/SUMMARY.md:156 src/error-handling/panics.md:1
msgid "Panics"
msgstr ""
#: src/SUMMARY.md:157
msgid "Catching Stack Unwinding"
msgstr ""
#: src/SUMMARY.md:158
msgid "Structured Error Handling"
msgstr ""
#: src/SUMMARY.md:159
msgid "Propagating Errors with ?"
msgstr ""
#: src/SUMMARY.md:160 src/error-handling/converting-error-types.md:1
#: src/error-handling/converting-error-types-example.md:1
msgid "Converting Error Types"
msgstr ""
#: src/SUMMARY.md:162 src/error-handling/deriving-error-enums.md:1
msgid "Deriving Error Enums"
msgstr ""
#: src/SUMMARY.md:163 src/error-handling/dynamic-errors.md:1
msgid "Dynamic Error Types"
msgstr ""
#: src/SUMMARY.md:164 src/error-handling/error-contexts.md:1
msgid "Adding Context to Errors"
msgstr ""
#: src/SUMMARY.md:165 src/testing.md:1
msgid "Testing"
msgstr ""
#: src/SUMMARY.md:166 src/testing/unit-tests.md:1
msgid "Unit Tests"
msgstr ""
#: src/SUMMARY.md:167 src/testing/test-modules.md:1
msgid "Test Modules"
msgstr ""
#: src/SUMMARY.md:168 src/testing/doc-tests.md:1
msgid "Documentation Tests"
msgstr ""
#: src/SUMMARY.md:169 src/testing/integration-tests.md:1
msgid "Integration Tests"
msgstr ""
#: src/SUMMARY.md:170 src/bare-metal/useful-crates.md:1
msgid "Useful crates"
msgstr ""
#: src/SUMMARY.md:171 src/unsafe.md:1
msgid "Unsafe Rust"
msgstr ""
#: src/SUMMARY.md:172 src/unsafe/raw-pointers.md:1
msgid "Dereferencing Raw Pointers"
msgstr ""
#: src/SUMMARY.md:173 src/unsafe/mutable-static-variables.md:1
msgid "Mutable Static Variables"
msgstr ""
#: src/SUMMARY.md:174 src/unsafe/unions.md:1
msgid "Unions"
msgstr ""
#: src/SUMMARY.md:175 src/unsafe/calling-unsafe-functions.md:1
msgid "Calling Unsafe Functions"
msgstr ""
#: src/SUMMARY.md:176 src/unsafe/writing-unsafe-functions.md:1
msgid "Writing Unsafe Functions"
msgstr ""
#: src/SUMMARY.md:177
msgid "Extern Functions"
msgstr ""
#: src/SUMMARY.md:178 src/unsafe/unsafe-traits.md:1
msgid "Implementing Unsafe Traits"
msgstr ""
#: src/SUMMARY.md:180 src/exercises/day-3/safe-ffi-wrapper.md:1
#: src/exercises/day-3/solutions-afternoon.md:3
msgid "Safe FFI Wrapper"
msgstr ""
#: src/SUMMARY.md:183 src/SUMMARY.md:253
#: src/running-the-course/course-structure.md:16 src/bare-metal/android.md:1
msgid "Android"
msgstr "Android"
#: src/SUMMARY.md:188 src/android/setup.md:1
msgid "Setup"
msgstr ""
#: src/SUMMARY.md:189 src/android/build-rules.md:1
msgid "Build Rules"
msgstr ""
#: src/SUMMARY.md:190
msgid "Binary"
msgstr ""
#: src/SUMMARY.md:191
msgid "Library"
msgstr ""
#: src/SUMMARY.md:192 src/android/aidl.md:1
msgid "AIDL"
msgstr ""
#: src/SUMMARY.md:193
msgid "Interface"
msgstr ""
#: src/SUMMARY.md:194
msgid "Implementation"
msgstr ""
#: src/SUMMARY.md:195
msgid "Server"
msgstr ""
#: src/SUMMARY.md:196 src/android/aidl/deploy.md:1
msgid "Deploy"
msgstr ""
#: src/SUMMARY.md:197
msgid "Client"
msgstr ""
#: src/SUMMARY.md:198 src/android/aidl/changing.md:1
msgid "Changing API"
msgstr ""
#: src/SUMMARY.md:199 src/SUMMARY.md:243 src/android/logging.md:1
#: src/bare-metal/aps/logging.md:1
msgid "Logging"
msgstr ""
#: src/SUMMARY.md:200 src/android/interoperability.md:1
msgid "Interoperability"
msgstr ""
#: src/SUMMARY.md:201
msgid "With C"
msgstr ""
#: src/SUMMARY.md:202
msgid "Calling C with Bindgen"
msgstr ""
#: src/SUMMARY.md:203
msgid "Calling Rust from C"
msgstr ""
#: src/SUMMARY.md:204 src/android/interoperability/cpp.md:1
msgid "With C++"
msgstr ""
#: src/SUMMARY.md:205
msgid "With Java"
msgstr ""
#: src/SUMMARY.md:209
msgid "Bare Metal: Morning"
msgstr "Rå jern: Formiddag"
#: src/SUMMARY.md:214
msgid "no_std"
msgstr "no_std"
#: src/SUMMARY.md:215
msgid "A Minimal Example"
msgstr "Et minimalt eksempel"
#: src/SUMMARY.md:216
msgid "alloc"
msgstr "alloc"
#: src/SUMMARY.md:217 src/bare-metal/microcontrollers.md:1
msgid "Microcontrollers"
msgstr ""
#: src/SUMMARY.md:218 src/bare-metal/microcontrollers/mmio.md:1
msgid "Raw MMIO"
msgstr "Rå MMIO"
#: src/SUMMARY.md:219
msgid "PACs"
msgstr "PAC'er"
#: src/SUMMARY.md:220
msgid "HAL Crates"
msgstr ""
#: src/SUMMARY.md:221
msgid "Board Support Crates"
msgstr ""
#: src/SUMMARY.md:222
msgid "The Type State Pattern"
msgstr ""
#: src/SUMMARY.md:223
msgid "embedded-hal"
msgstr "embedded-hal"
#: src/SUMMARY.md:224
msgid "probe-rs, cargo-embed"
msgstr "probe-rs, cargo-embed"
#: src/SUMMARY.md:225 src/bare-metal/microcontrollers/debugging.md:1
msgid "Debugging"
msgstr "Fejlfinding"
#: src/SUMMARY.md:226 src/SUMMARY.md:246
msgid "Other Projects"
msgstr "Andre projekter"
#: src/SUMMARY.md:228 src/exercises/bare-metal/compass.md:1
#: src/exercises/bare-metal/solutions-morning.md:3
msgid "Compass"
msgstr "Kompas"
#: src/SUMMARY.md:230
msgid "Bare Metal: Afternoon"
msgstr "Rå jern: Eftermiddag"
#: src/SUMMARY.md:232
msgid "Application Processors"
msgstr ""
#: src/SUMMARY.md:233 src/bare-metal/aps/entry-point.md:1
msgid "Getting Ready to Rust"
msgstr ""
#: src/SUMMARY.md:234
msgid "Inline Assembly"
msgstr ""
#: src/SUMMARY.md:235
msgid "MMIO"
msgstr "MMIO"
#: src/SUMMARY.md:236
msgid "Let's Write a UART Driver"
msgstr ""
#: src/SUMMARY.md:237
msgid "More Traits"
msgstr ""
#: src/SUMMARY.md:238
msgid "A Better UART Driver"
msgstr ""
#: src/SUMMARY.md:239 src/bare-metal/aps/better-uart/bitflags.md:1
msgid "Bitflags"
msgstr "Bitflag"
#: src/SUMMARY.md:240
msgid "Multiple Registers"
msgstr ""
#: src/SUMMARY.md:241 src/bare-metal/aps/better-uart/driver.md:1
msgid "Driver"
msgstr "Driver"
#: src/SUMMARY.md:242 src/SUMMARY.md:244
msgid "Using It"
msgstr "Anvendelse"
#: src/SUMMARY.md:245 src/bare-metal/aps/exceptions.md:1
#, fuzzy
msgid "Exceptions"
msgstr "Funktioner"
#: src/SUMMARY.md:247
msgid "Useful Crates"
msgstr ""
#: src/SUMMARY.md:248
msgid "zerocopy"
msgstr "zerocopy"
#: src/SUMMARY.md:249
msgid "aarch64-paging"
msgstr "aarch64-paging"
#: src/SUMMARY.md:250
msgid "buddy_system_allocator"
msgstr "buddy_system_allocator"
#: src/SUMMARY.md:251
msgid "tinyvec"
msgstr "tinyvec"
#: src/SUMMARY.md:252
msgid "spin"
msgstr "spin"
#: src/SUMMARY.md:254 src/bare-metal/android/vmbase.md:1
msgid "vmbase"
msgstr "vmbase"
#: src/SUMMARY.md:256
msgid "RTC Driver"
msgstr ""
#: src/SUMMARY.md:259
msgid "Concurrency: Morning"
msgstr ""
#: src/SUMMARY.md:264 src/concurrency/threads.md:1
msgid "Threads"
msgstr "Tråde"
#: src/SUMMARY.md:265 src/concurrency/scoped-threads.md:1
msgid "Scoped Threads"
msgstr "Tråde med virkefelt"
#: src/SUMMARY.md:266 src/concurrency/channels.md:1
msgid "Channels"
msgstr "Kanaler"
#: src/SUMMARY.md:267 src/concurrency/channels/unbounded.md:1
msgid "Unbounded Channels"
msgstr "Ubegrænsede kanaler"
#: src/SUMMARY.md:268 src/concurrency/channels/bounded.md:1
msgid "Bounded Channels"
msgstr "Begrænsede kanaler"
#: src/SUMMARY.md:269
msgid "Send and Sync"
msgstr "Send og Sync"
#: src/SUMMARY.md:269
msgid "Send"
msgstr "Send"
#: src/SUMMARY.md:269
msgid "Sync"
msgstr "Sync"
#: src/SUMMARY.md:272 src/concurrency/send-sync/examples.md:1
msgid "Examples"
msgstr "Eksempler"
#: src/SUMMARY.md:273 src/concurrency/shared_state.md:1
msgid "Shared State"
msgstr "Delt tilstand"
#: src/SUMMARY.md:274
msgid "Arc"
msgstr "Arc"
#: src/SUMMARY.md:275
msgid "Mutex"
msgstr "Mutex"
#: src/SUMMARY.md:278 src/SUMMARY.md:299
#: src/exercises/concurrency/dining-philosophers.md:1
#: src/exercises/concurrency/solutions-morning.md:3
msgid "Dining Philosophers"
msgstr "Filosoffer omkring spisebordet"
#: src/SUMMARY.md:279 src/exercises/concurrency/link-checker.md:1
msgid "Multi-threaded Link Checker"
msgstr "Flertrådet linktjekker"
#: src/SUMMARY.md:281
#, fuzzy
msgid "Concurrency: Afternoon"
msgstr "Dag 1: Eftermiddag"
#: src/SUMMARY.md:283
msgid "Async Basics"
msgstr "Grundlæggende Async"
#: src/SUMMARY.md:284
msgid "async/await"
msgstr "async/await"
#: src/SUMMARY.md:285 src/async/futures.md:1
msgid "Futures"
msgstr "Fremtidige resultater (eng. Futures)"
#: src/SUMMARY.md:286 src/async/runtimes.md:1
#, fuzzy
msgid "Runtimes"
msgstr "Garantier under programudføring"
#: src/SUMMARY.md:287 src/async/runtimes/tokio.md:1
msgid "Tokio"
msgstr "Tokio"
#: src/SUMMARY.md:288 src/exercises/concurrency/link-checker.md:126
#: src/async/tasks.md:1 src/exercises/concurrency/chat-app.md:140
msgid "Tasks"
msgstr "Opgaver (eng. Tasks)"
#: src/SUMMARY.md:289 src/async/channels.md:1
msgid "Async Channels"
msgstr "Asynkrone kanaler"
#: src/SUMMARY.md:291 src/async/control-flow/join.md:1
msgid "Join"
msgstr "Join"
#: src/SUMMARY.md:292 src/async/control-flow/select.md:1
msgid "Select"
msgstr "Select"
#: src/SUMMARY.md:293
msgid "Pitfalls"
msgstr "Faldgruber"
#: src/SUMMARY.md:294
msgid "Blocking the Executor"
msgstr ""
#: src/SUMMARY.md:295 src/async/pitfalls/pin.md:1
msgid "Pin"
msgstr "Pin"
#: src/SUMMARY.md:296 src/async/pitfalls/async-traits.md:1
msgid "Async Traits"
msgstr "Asynkrone egenskaber (eng. Traits)"
#: src/SUMMARY.md:297 src/async/pitfalls/cancellation.md:1
#, fuzzy
msgid "Cancellation"
msgstr "Installation"
#: src/SUMMARY.md:300 src/exercises/concurrency/chat-app.md:1
#: src/exercises/concurrency/solutions-afternoon.md:119
msgid "Broadcast Chat Application"
msgstr "Broadcast chat-applikation"
#: src/SUMMARY.md:303
msgid "Final Words"
msgstr "Afsluttende bemærkninger"
#: src/SUMMARY.md:307 src/thanks.md:1
msgid "Thanks!"
msgstr "Tak!"
#: src/SUMMARY.md:308
msgid "Other Resources"
msgstr "Andre resourcer"
#: src/SUMMARY.md:309 src/credits.md:1
msgid "Credits"
msgstr "Anerkendelser"
#: src/SUMMARY.md:312 src/exercises/solutions.md:1
msgid "Solutions"
msgstr "Løsninger"
#: src/SUMMARY.md:317
msgid "Day 1 Morning"
msgstr "Dag 1 Formiddag"
#: src/SUMMARY.md:318
msgid "Day 1 Afternoon"
msgstr "Dag 1 Eftermiddag"
#: src/SUMMARY.md:319
msgid "Day 2 Morning"
msgstr "Dag 2 Formiddag"
#: src/SUMMARY.md:320
msgid "Day 2 Afternoon"
msgstr "Dag 2 Eftermiddag"
#: src/SUMMARY.md:321
msgid "Day 3 Morning"
msgstr "Dag 3 Formiddag"
#: src/SUMMARY.md:322
msgid "Day 3 Afternoon"
msgstr "Dag 3 Eftermiddag"
#: src/SUMMARY.md:323
msgid "Bare Metal Rust Morning"
msgstr "Rå jern Rust formiddag"
#: src/SUMMARY.md:324 src/exercises/bare-metal/solutions-afternoon.md:1
msgid "Bare Metal Rust Afternoon"
msgstr "Rå jern Rust eftermiddag"
#: src/SUMMARY.md:325
msgid "Concurrency Morning"
msgstr "Parallelprogrammering formiddag"
#: src/SUMMARY.md:326
msgid "Concurrency Afternoon"
msgstr "Parallelprogrammering eftermiddag"
#: src/index.md:3
msgid ""
"[![Build workflow](https://img.shields.io/github/actions/workflow/status/"
"google/comprehensive-rust/build.yml?style=flat-square)](https://github.com/"
"google/comprehensive-rust/actions/workflows/build.yml?query=branch%3Amain) [!"
"[GitHub contributors](https://img.shields.io/github/contributors/google/"
"comprehensive-rust?style=flat-square)](https://github.com/google/"
"comprehensive-rust/graphs/contributors) [![GitHub stars](https://img.shields."
"io/github/stars/google/comprehensive-rust?style=flat-square)](https://github."
"com/google/comprehensive-rust/stargazers)"
msgstr ""
#: src/index.md:7
#, fuzzy
msgid ""
"This is a free Rust course developed by the Android team at Google. The "
"course covers the full spectrum of Rust, from basic syntax to advanced "
"topics like generics and error handling."
msgstr ""
"Dette er et tre dages Rust-kursus udviklet af Android-teamet. Kurset dækker "
"hele spektret af Rust, fra grundlæggende syntaks til avancerede emner som "
"generiske og fejlhåndtering. Det inkluderer også Android-specifikt indhold "
"på den sidste dag."
#: src/index.md:11
msgid ""
"The goal of the course is to teach you Rust. We assume you don't know "
"anything about Rust and hope to:"
msgstr ""
"Målet med kurset er at lære dig Rust. Vi antager, at du ikke ved noget om "
"Rust og håber at:"
#: src/index.md:14
msgid "Give you a comprehensive understanding of the Rust syntax and language."
msgstr "Giver dig en omfattende forståelse af Rust-syntaksen og sproget."
#: src/index.md:15
msgid "Enable you to modify existing programs and write new programs in Rust."
msgstr ""
"Gøre det muligt for dig at ændre eksisterende programmer og skrive nye "
"programmer i Rust."
#: src/index.md:16
msgid "Show you common Rust idioms."
msgstr "Vis dig almindelige Rust idiomer."
#: src/index.md:18
msgid "We call the first three course days Rust Fundamentals."
msgstr ""
#: src/index.md:20
msgid ""
"Building on this, you're invited to dive into one or more specialized topics:"
msgstr ""
#: src/index.md:22
msgid ""
"[Android](android.md): a half-day course on using Rust for Android platform "
"development (AOSP). This includes interoperability with C, C++, and Java."
msgstr ""
#: src/index.md:24
msgid ""
"[Bare-metal](bare-metal.md): a whole-day class on using Rust for bare-metal "
"(embedded) development. Both microcontrollers and application processors are "
"covered."
msgstr ""
#: src/index.md:27
msgid ""
"[Concurrency](concurrency.md): a whole-day class on concurrency in Rust. We "
"cover both classical concurrency (preemptively scheduling using threads and "
"mutexes) and async/await concurrency (cooperative multitasking using "
"futures)."
msgstr ""
#: src/index.md:33
msgid "Non-Goals"
msgstr "Ting som ikke dækkes"
#: src/index.md:35
msgid ""
"Rust is a large language and we won't be able to cover all of it in a few "
"days. Some non-goals of this course are:"
msgstr ""
"Rust er et stort sprog og vi vil ikke være i stand til at dække det hele på "
"et par dage. Nogle af ting som vi ikke dækker er:"
#: src/index.md:38
msgid ""
"Learning how to develop macros: please see [Chapter 19.5 in the Rust Book]"
"(https://doc.rust-lang.org/book/ch19-06-macros.html) and [Rust by Example]"
"(https://doc.rust-lang.org/rust-by-example/macros.html) instead."
msgstr ""
#: src/index.md:42
msgid "Assumptions"
msgstr "Antagelser"
#: src/index.md:44
msgid ""
"The course assumes that you already know how to program. Rust is a "
"statically-typed language and we will sometimes make comparisons with C and "
"C++ to better explain or contrast the Rust approach."
msgstr ""
#: src/index.md:48
msgid ""
"If you know how to program in a dynamically-typed language such as Python or "
"JavaScript, then you will be able to follow along just fine too."
msgstr ""
#: src/index.md:53
msgid ""
"This is an example of a _speaker note_. We will use these to add additional "
"information to the slides. This could be key points which the instructor "
"should cover as well as answers to typical questions which come up in class."
msgstr ""
#: src/running-the-course.md:3 src/running-the-course/course-structure.md:3
msgid "This page is for the course instructor."
msgstr "Denne side er for kursuslederen."
#: src/running-the-course.md:5
msgid ""
"Here is a bit of background information about how we've been running the "
"course internally at Google."
msgstr ""
#: src/running-the-course.md:8
msgid "Before you run the course, you will want to:"
msgstr ""
#: src/running-the-course.md:10
msgid ""
"Make yourself familiar with the course material. We've included speaker "
"notes to help highlight the key points (please help us by contributing more "
"speaker notes!). When presenting, you should make sure to open the speaker "
"notes in a popup (click the link with a little arrow next to \"Speaker "
"Notes\"). This way you have a clean screen to present to the class."
msgstr ""
#: src/running-the-course.md:16
msgid ""
"Decide on the dates. Since the course takes at least three full days, we "
"recommend that you schedule the days over two weeks. Course participants "
"have said that they find it helpful to have a gap in the course since it "
"helps them process all the information we give them."
msgstr ""
#: src/running-the-course.md:21
msgid ""
"Find a room large enough for your in-person participants. We recommend a "
"class size of 15-25 people. That's small enough that people are comfortable "
"asking questions --- it's also small enough that one instructor will have "
"time to answer the questions. Make sure the room has _desks_ for yourself "
"and for the students: you will all need to be able to sit and work with your "
"laptops. In particular, you will be doing a lot of live-coding as an "
"instructor, so a lectern won't be very helpful for you."
msgstr ""
#: src/running-the-course.md:29
msgid ""
"On the day of your course, show up to the room a little early to set things "
"up. We recommend presenting directly using `mdbook serve` running on your "
"laptop (see the [installation instructions](https://github.com/google/"
"comprehensive-rust#building)). This ensures optimal performance with no lag "
"as you change pages. Using your laptop will also allow you to fix typos as "
"you or the course participants spot them."
msgstr ""
#: src/running-the-course.md:35
msgid ""
"Let people solve the exercises by themselves or in small groups. We "
"typically spend 30-45 minutes on exercises in the morning and in the "
"afternoon (including time to review the solutions). Make sure to ask people "
"if they're stuck or if there is anything you can help with. When you see "
"that several people have the same problem, call it out to the class and "
"offer a solution, e.g., by showing people where to find the relevant "
"information in the standard library."
msgstr ""
#: src/running-the-course.md:43
msgid ""
"That is all, good luck running the course! We hope it will be as much fun "
"for you as it has been for us!"
msgstr ""
#: src/running-the-course.md:46
msgid ""
"Please [provide feedback](https://github.com/google/comprehensive-rust/"
"discussions/86) afterwards so that we can keep improving the course. We "
"would love to hear what worked well for you and what can be made better. "
"Your students are also very welcome to [send us feedback](https://github.com/"
"google/comprehensive-rust/discussions/100)!"
msgstr ""
#: src/running-the-course/course-structure.md:5
msgid "The course is fast paced and covers a lot of ground:"
msgstr ""
#: src/running-the-course/course-structure.md:7
msgid "Day 1: Basic Rust, ownership and the borrow checker."
msgstr ""
#: src/running-the-course/course-structure.md:8
msgid "Day 2: Compound data types, pattern matching, the standard library."
msgstr ""
#: src/running-the-course/course-structure.md:9
msgid "Day 3: Traits and generics, error handling, testing, unsafe Rust."
msgstr ""
#: src/running-the-course/course-structure.md:11
msgid "Deep Dives"
msgstr ""
#: src/running-the-course/course-structure.md:13
msgid ""
"In addition to the 3-day class on Rust Fundamentals, we cover some more "
"specialized topics:"
msgstr ""
#: src/running-the-course/course-structure.md:18
msgid ""
"The [Android Deep Dive](../android.md) is a half-day course on using Rust "
"for Android platform development. This includes interoperability with C, C+"
"+, and Java."
msgstr ""
#: src/running-the-course/course-structure.md:22
msgid ""
"You will need an [AOSP checkout](https://source.android.com/docs/setup/"
"download/downloading). Make a checkout of the [course repository](https://"
"github.com/google/comprehensive-rust) on the same machine and move the `src/"
"android/` directory into the root of your AOSP checkout. This will ensure "
"that the Android build system sees the `Android.bp` files in `src/android/`."
msgstr ""
#: src/running-the-course/course-structure.md:27
msgid ""
"Ensure that `adb sync` works with your emulator or real device and pre-build "
"all Android examples using `src/android/build_all.sh`. Read the script to "
"see the commands it runs and make sure they work when you run them by hand."
msgstr ""
#: src/running-the-course/course-structure.md:34
msgid "Bare-Metal"
msgstr ""
#: src/running-the-course/course-structure.md:36
msgid ""
"The [Bare-Metal Deep Dive](../bare-metal.md): a full day class on using Rust "
"for bare-metal (embedded) development. Both microcontrollers and application "
"processors are covered."
msgstr ""
#: src/running-the-course/course-structure.md:40
msgid ""
"For the microcontroller part, you will need to buy the [BBC micro:bit]"
"(https://microbit.org/) v2 development board ahead of time. Everybody will "
"need to install a number of packages as described on the [welcome page](../"
"bare-metal.md)."
msgstr ""
#: src/running-the-course/course-structure.md:45
msgid "Concurrency"
msgstr ""
#: src/running-the-course/course-structure.md:47
msgid ""
"The [Concurrency Deep Dive](../concurrency.md) is a full day class on "
"classical as well as `async`/`await` concurrency."
msgstr ""
#: src/running-the-course/course-structure.md:50
msgid ""
"You will need a fresh crate set up and the dependencies downloaded and ready "
"to go. You can then copy/paste the examples into `src/main.rs` to experiment "
"with them:"
msgstr ""
#: src/running-the-course/course-structure.md:54
msgid ""
"```shell\n"
"cargo init concurrency\n"
"cd concurrency\n"
"cargo add tokio --features full\n"
"cargo run\n"
"```"
msgstr ""
#: src/running-the-course/course-structure.md:61
msgid "Format"
msgstr ""
#: src/running-the-course/course-structure.md:63
msgid ""
"The course is meant to be very interactive and we recommend letting the "
"questions drive the exploration of Rust!"
msgstr ""
#: src/running-the-course/keyboard-shortcuts.md:3
msgid "There are several useful keyboard shortcuts in mdBook:"
msgstr ""
#: src/running-the-course/keyboard-shortcuts.md:5
msgid "Arrow-Left"
msgstr ""
#: src/running-the-course/keyboard-shortcuts.md:5
msgid ": Navigate to the previous page."
msgstr ""
#: src/running-the-course/keyboard-shortcuts.md:6
msgid "Arrow-Right"
msgstr ""
#: src/running-the-course/keyboard-shortcuts.md:6
msgid ": Navigate to the next page."
msgstr ""
#: src/running-the-course/keyboard-shortcuts.md:7 src/cargo/code-samples.md:19
msgid "Ctrl + Enter"
msgstr "Ctrl + Enter"
#: src/running-the-course/keyboard-shortcuts.md:7
msgid ": Execute the code sample that has focus."
msgstr ""
#: src/running-the-course/keyboard-shortcuts.md:8
msgid "s"
msgstr ""
#: src/running-the-course/keyboard-shortcuts.md:8
msgid ": Activate the search bar."
msgstr ""
#: src/running-the-course/translations.md:3
msgid ""
"The course has been translated into other languages by a set of wonderful "
"volunteers:"
msgstr ""
#: src/running-the-course/translations.md:6
msgid ""
"[Brazilian Portuguese](https://google.github.io/comprehensive-rust/pt-BR/) "
"by [@rastringer](https://github.com/rastringer), [@hugojacob](https://github."
"com/hugojacob), [@joaovicmendes](https://github.com/joaovicmendes) and "
"[@henrif75](https://github.com/henrif75)."
msgstr ""
#: src/running-the-course/translations.md:7
msgid ""
"[Korean](https://google.github.io/comprehensive-rust/ko/) by [@keispace]"
"(https://github.com/keispace), [@jiyongp](https://github.com/jiyongp) and "
"[@jooyunghan](https://github.com/jooyunghan)."
msgstr ""
#: src/running-the-course/translations.md:9
msgid ""
"Use the language picker in the top-right corner to switch between languages."
msgstr ""
#: src/running-the-course/translations.md:11
#, fuzzy
msgid "Incomplete Translations"
msgstr "Oversættelser"
#: src/running-the-course/translations.md:13
msgid ""
"There is a large number of in-progress translations. We link to the most "
"recently updated translations:"
msgstr ""
#: src/running-the-course/translations.md:16
msgid ""
"[Bengali](https://google.github.io/comprehensive-rust/bn/) by [@raselmandol]"
"(https://github.com/raselmandol)."
msgstr ""
#: src/running-the-course/translations.md:17
msgid ""
"[French](https://google.github.io/comprehensive-rust/fr/) by [@KookaS]"
"(https://github.com/KookaS) and [@vcaen](https://github.com/vcaen)."
msgstr ""
#: src/running-the-course/translations.md:18
msgid ""
"[German](https://google.github.io/comprehensive-rust/de/) by [@Throvn]"
"(https://github.com/Throvn) and [@ronaldfw](https://github.com/ronaldfw)."
msgstr ""
#: src/running-the-course/translations.md:19
msgid ""
"[Japanese](https://google.github.io/comprehensive-rust/ja/) by [@CoinEZ-JPN]"
"(https://github.com/CoinEZ) and [@momotaro1105](https://github.com/"
"momotaro1105)."
msgstr ""
#: src/running-the-course/translations.md:21
msgid ""
"If you want to help with this effort, please see [our instructions](https://"
"github.com/google/comprehensive-rust/blob/main/TRANSLATIONS.md) for how to "
"get going. Translations are coordinated on the [issue tracker](https://"
"github.com/google/comprehensive-rust/issues/282)."
msgstr ""
#: src/cargo.md:3
msgid ""
"When you start reading about Rust, you will soon meet [Cargo](https://doc."
"rust-lang.org/cargo/), the standard tool used in the Rust ecosystem to build "
"and run Rust applications. Here we want to give a brief overview of what "
"Cargo is and how it fits into the wider ecosystem and how it fits into this "
"training."
msgstr ""
#: src/cargo.md:8
msgid "Installation"
msgstr "Installation"
#: src/cargo.md:10
msgid "**Please follow the instructions on .**"
msgstr ""
#: src/cargo.md:12
msgid ""
"This will give you the Cargo build tool (`cargo`) and the Rust compiler "
"(`rustc`). You will also get `rustup`, a command line utility that you can "
"use to install/switch toolchains, setup cross compilation, etc."
msgstr ""
#: src/cargo.md:16
msgid ""
"On Debian/Ubuntu, you can also install Cargo, the Rust source and the [Rust "
"formatter](https://github.com/rust-lang/rustfmt) via `apt`. However, this "
"gets you an outdated rust version and may lead to unexpected behavior. The "
"command would be:"
msgstr ""
#: src/cargo.md:18
#, fuzzy
msgid ""
"```shell\n"
" sudo apt install cargo rust-src rustfmt\n"
"```"
msgstr ""
"```shell\n"
"$ sudo apt install cargo rust-src rustfmt\n"
"```"
#: src/cargo.md:22
msgid ""
"We suggest using [VS Code](https://code.visualstudio.com/) to edit the code "
"(but any LSP compatible editor works with rust-analyzer[3](https://rust-"
"analyzer.github.io/))."
msgstr ""
#: src/cargo.md:24
msgid ""
"Some folks also like to use the [JetBrains](https://www.jetbrains.com/"
"clion/) family of IDEs, which do their own analysis but have their own "
"tradeoffs. If you prefer them, you can install the [Rust Plugin](https://www."
"jetbrains.com/rust/). Please take note that as of January 2023 debugging "
"only works on the CLion version of the JetBrains IDEA suite."
msgstr ""
#: src/cargo/rust-ecosystem.md:1
msgid "The Rust Ecosystem"
msgstr ""
#: src/cargo/rust-ecosystem.md:3
msgid ""
"The Rust ecosystem consists of a number of tools, of which the main ones are:"
msgstr ""
#: src/cargo/rust-ecosystem.md:5
msgid ""
"`rustc`: the Rust compiler which turns `.rs` files into binaries and other "
"intermediate formats."
msgstr ""
#: src/cargo/rust-ecosystem.md:8
msgid ""
"`cargo`: the Rust dependency manager and build tool. Cargo knows how to "
"download dependencies, usually hosted on , and it will "
"pass them to `rustc` when building your project. Cargo also comes with a "
"built-in test runner which is used to execute unit tests."
msgstr ""
#: src/cargo/rust-ecosystem.md:13
msgid ""
"`rustup`: the Rust toolchain installer and updater. This tool is used to "
"install and update `rustc` and `cargo` when new versions of Rust is "
"released. In addition, `rustup` can also download documentation for the "
"standard library. You can have multiple versions of Rust installed at once "
"and `rustup` will let you switch between them as needed."
msgstr ""
#: src/cargo/rust-ecosystem.md:21 src/hello-world.md:25
#: src/hello-world/small-example.md:27 src/why-rust/runtime.md:10
#: src/why-rust/modern.md:21 src/basic-syntax/compound-types.md:30
#: src/basic-syntax/references.md:23
#: src/pattern-matching/destructuring-enums.md:35
#: src/error-handling/try-operator.md:48
#: src/error-handling/converting-error-types-example.md:50
#: src/concurrency/threads.md:30 src/async/async-await.md:25
msgid "Key points:"
msgstr "Nøglepunkter:"
#: src/cargo/rust-ecosystem.md:23
msgid ""
"Rust has a rapid release schedule with a new release coming out every six "
"weeks. New releases maintain backwards compatibility with old releases --- "
"plus they enable new functionality."
msgstr ""
#: src/cargo/rust-ecosystem.md:27
msgid ""
"There are three release channels: \"stable\", \"beta\", and \"nightly\"."
msgstr ""
#: src/cargo/rust-ecosystem.md:29
msgid ""
"New features are being tested on \"nightly\", \"beta\" is what becomes "
"\"stable\" every six weeks."
msgstr ""
#: src/cargo/rust-ecosystem.md:32
msgid ""
"Dependencies can also be resolved from alternative [registries](https://doc."
"rust-lang.org/cargo/reference/registries.html), git, folders, and more."
msgstr ""
#: src/cargo/rust-ecosystem.md:34
msgid ""
"Rust also has [editions](https://doc.rust-lang.org/edition-guide/): the "
"current edition is Rust 2021. Previous editions were Rust 2015 and Rust 2018."
msgstr ""
#: src/cargo/rust-ecosystem.md:37
msgid ""
"The editions are allowed to make backwards incompatible changes to the "
"language."
msgstr ""
#: src/cargo/rust-ecosystem.md:40
msgid ""
"To prevent breaking code, editions are opt-in: you select the edition for "
"your crate via the `Cargo.toml` file."
msgstr ""
#: src/cargo/rust-ecosystem.md:43
msgid ""
"To avoid splitting the ecosystem, Rust compilers can mix code written for "
"different editions."
msgstr ""
#: src/cargo/rust-ecosystem.md:46
msgid ""
"Mention that it is quite rare to ever use the compiler directly not through "
"`cargo` (most users never do)."
msgstr ""
#: src/cargo/rust-ecosystem.md:48
msgid ""
"It might be worth alluding that Cargo itself is an extremely powerful and "
"comprehensive tool. It is capable of many advanced features including but "
"not limited to: "
msgstr ""
#: src/cargo/rust-ecosystem.md:49
msgid "Project/package structure"
msgstr ""
#: src/cargo/rust-ecosystem.md:50
msgid "[workspaces](https://doc.rust-lang.org/cargo/reference/workspaces.html)"
msgstr ""
#: src/cargo/rust-ecosystem.md:51
msgid "Dev Dependencies and Runtime Dependency management/caching"
msgstr ""
#: src/cargo/rust-ecosystem.md:52
msgid ""
"[build scripting](https://doc.rust-lang.org/cargo/reference/build-scripts."
"html)"
msgstr ""
#: src/cargo/rust-ecosystem.md:53
msgid ""
"[global installation](https://doc.rust-lang.org/cargo/commands/cargo-install."
"html)"
msgstr ""
#: src/cargo/rust-ecosystem.md:54
msgid ""
"It is also extensible with sub command plugins as well (such as [cargo "
"clippy](https://github.com/rust-lang/rust-clippy))."
msgstr ""
#: src/cargo/rust-ecosystem.md:55
msgid ""
"Read more from the [official Cargo Book](https://doc.rust-lang.org/cargo/)"
msgstr ""
#: src/cargo/code-samples.md:1
msgid "Code Samples in This Training"
msgstr ""
#: src/cargo/code-samples.md:3
msgid ""
"For this training, we will mostly explore the Rust language through examples "
"which can be executed through your browser. This makes the setup much easier "
"and ensures a consistent experience for everyone."
msgstr ""
#: src/cargo/code-samples.md:7
msgid ""
"Installing Cargo is still encouraged: it will make it easier for you to do "
"the exercises. On the last day, we will do a larger exercise which shows you "
"how to work with dependencies and for that you need Cargo."
msgstr ""
#: src/cargo/code-samples.md:11
msgid "The code blocks in this course are fully interactive:"
msgstr ""
#: src/cargo/code-samples.md:13
msgid ""
"```rust,editable\n"
"fn main() {\n"
" println!(\"Edit me!\");\n"
"}\n"
"```"
msgstr ""
"```rust,editable\n"
"fn main() {\n"
" println!(\"Rediger mig!\");\n"
"}\n"
"```"
#: src/cargo/code-samples.md:19
msgid "You can use "
msgstr "Du kan bruge "
#: src/cargo/code-samples.md:19
msgid " to execute the code when focus is in the text box."
msgstr " for at afvikle koden når fokus er i tekstboksen."
#: src/cargo/code-samples.md:24
msgid ""
"Most code samples are editable like shown above. A few code samples are not "
"editable for various reasons:"
msgstr ""
#: src/cargo/code-samples.md:27
msgid ""
"The embedded playgrounds cannot execute unit tests. Copy-paste the code and "
"open it in the real Playground to demonstrate unit tests."
msgstr ""
#: src/cargo/code-samples.md:30
msgid ""
"The embedded playgrounds lose their state the moment you navigate away from "
"the page! This is the reason that the students should solve the exercises "
"using a local Rust installation or via the Playground."
msgstr ""
#: src/cargo/running-locally.md:1
msgid "Running Code Locally with Cargo"
msgstr ""
#: src/cargo/running-locally.md:3
msgid ""
"If you want to experiment with the code on your own system, then you will "
"need to first install Rust. Do this by following the [instructions in the "
"Rust Book](https://doc.rust-lang.org/book/ch01-01-installation.html). This "
"should give you a working `rustc` and `cargo`. At the time of writing, the "
"latest stable Rust release has these version numbers:"
msgstr ""
#: src/cargo/running-locally.md:8
msgid ""
"```shell\n"
"% rustc --version\n"
"rustc 1.69.0 (84c898d65 2023-04-16)\n"
"% cargo --version\n"
"cargo 1.69.0 (6e9a83356 2023-04-12)\n"
"```"
msgstr ""
"```shell\n"
"% rustc --version\n"
"rustc 1.69.0 (84c898d65 2023-04-16)\n"
"% cargo --version\n"
"cargo 1.69.0 (6e9a83356 2023-04-12)\n"
"```"
#: src/cargo/running-locally.md:15
msgid ""
"You can use any later version too since Rust maintains backwards "
"compatibility."
msgstr ""
#: src/cargo/running-locally.md:17
msgid ""
"With this in place, follow these steps to build a Rust binary from one of "
"the examples in this training:"
msgstr ""
#: src/cargo/running-locally.md:20
msgid "Click the \"Copy to clipboard\" button on the example you want to copy."
msgstr ""
#: src/cargo/running-locally.md:22
msgid ""
"Use `cargo new exercise` to create a new `exercise/` directory for your code:"
msgstr ""
#: src/cargo/running-locally.md:24
msgid ""
"```shell\n"
"$ cargo new exercise\n"
" Created binary (application) `exercise` package\n"
"```"
msgstr ""
#: src/cargo/running-locally.md:29
msgid ""
"Navigate into `exercise/` and use `cargo run` to build and run your binary:"
msgstr ""
#: src/cargo/running-locally.md:31
msgid ""
"```shell\n"
"$ cd exercise\n"
"$ cargo run\n"
" Compiling exercise v0.1.0 (/home/mgeisler/tmp/exercise)\n"
" Finished dev [unoptimized + debuginfo] target(s) in 0.75s\n"
" Running `target/debug/exercise`\n"
"Hello, world!\n"
"```"
msgstr ""
#: src/cargo/running-locally.md:40
msgid ""
"Replace the boiler-plate code in `src/main.rs` with your own code. For "
"example, using the example on the previous page, make `src/main.rs` look like"
msgstr ""
#: src/cargo/running-locally.md:43
msgid ""
"```rust\n"
"fn main() {\n"
" println!(\"Edit me!\");\n"
"}\n"
"```"
msgstr ""
#: src/cargo/running-locally.md:49
msgid "Use `cargo run` to build and run your updated binary:"
msgstr ""
#: src/cargo/running-locally.md:51
msgid ""
"```shell\n"
"$ cargo run\n"
" Compiling exercise v0.1.0 (/home/mgeisler/tmp/exercise)\n"
" Finished dev [unoptimized + debuginfo] target(s) in 0.24s\n"
" Running `target/debug/exercise`\n"
"Edit me!\n"
"```"
msgstr ""
#: src/cargo/running-locally.md:59
msgid ""
"Use `cargo check` to quickly check your project for errors, use `cargo "
"build` to compile it without running it. You will find the output in `target/"
"debug/` for a normal debug build. Use `cargo build --release` to produce an "
"optimized release build in `target/release/`."
msgstr ""
#: src/cargo/running-locally.md:64
msgid ""
"You can add dependencies for your project by editing `Cargo.toml`. When you "
"run `cargo` commands, it will automatically download and compile missing "
"dependencies for you."
msgstr ""
#: src/cargo/running-locally.md:72
msgid ""
"Try to encourage the class participants to install Cargo and use a local "
"editor. It will make their life easier since they will have a normal "
"development environment."
msgstr ""
#: src/welcome-day-1.md:1
msgid "Welcome to Day 1"
msgstr "Velkommen til Dag 1"
#: src/welcome-day-1.md:3
#, fuzzy
msgid ""
"This is the first day of Rust Fundamentals. We will cover a lot of ground "
"today:"
msgstr ""
"Dette er den første dag af Comprehensive Rust. Vi kommer til at dække en "
"masse terræn i dag:"
#: src/welcome-day-1.md:6
msgid ""
"Basic Rust syntax: variables, scalar and compound types, enums, structs, "
"references, functions, and methods."
msgstr ""
#: src/welcome-day-1.md:9
msgid ""
"Memory management: stack vs heap, manual memory management, scope-based "
"memory management, and garbage collection."
msgstr ""
#: src/welcome-day-1.md:12
msgid ""
"Ownership: move semantics, copying and cloning, borrowing, and lifetimes."
msgstr ""
#: src/welcome-day-1.md:16
msgid "Please remind the students that:"
msgstr ""
#: src/welcome-day-1.md:18
msgid ""
"They should ask questions when they get them, don't save them to the end."
msgstr ""
#: src/welcome-day-1.md:19
msgid ""
"The class is meant to be interactive and discussions are very much "
"encouraged!"
msgstr ""
#: src/welcome-day-1.md:20
msgid ""
"As an instructor, you should try to keep the discussions relevant, i.e., "
"keep the discussions related to how Rust does things vs some other "
"language. It can be hard to find the right balance, but err on the side of "
"allowing discussions since they engage people much more than one-way "
"communication."
msgstr ""
#: src/welcome-day-1.md:24
msgid ""
"The questions will likely mean that we talk about things ahead of the slides."
msgstr ""
#: src/welcome-day-1.md:25
msgid ""
"This is perfectly okay! Repetition is an important part of learning. "
"Remember that the slides are just a support and you are free to skip them as "
"you like."
msgstr ""
#: src/welcome-day-1.md:29
msgid ""
"The idea for the first day is to show _just enough_ of Rust to be able to "
"speak about the famous borrow checker. The way Rust handles memory is a "
"major feature and we should show students this right away."
msgstr ""
#: src/welcome-day-1.md:33
msgid ""
"If you're teaching this in a classroom, this is a good place to go over the "
"schedule. We suggest splitting the day into two parts (following the slides):"
msgstr ""
#: src/welcome-day-1.md:36
msgid "Morning: 9:00 to 12:00,"
msgstr ""
#: src/welcome-day-1.md:37
msgid "Afternoon: 13:00 to 16:00."
msgstr ""
#: src/welcome-day-1.md:39
msgid ""
"You can of course adjust this as necessary. Please make sure to include "
"breaks, we recommend a break every hour!"
msgstr ""
#: src/welcome-day-1/what-is-rust.md:3
msgid ""
"Rust is a new programming language which had its [1.0 release in 2015]"
"(https://blog.rust-lang.org/2015/05/15/Rust-1.0.html):"
msgstr ""
#: src/welcome-day-1/what-is-rust.md:5
msgid "Rust is a statically compiled language in a similar role as C++"
msgstr ""
#: src/welcome-day-1/what-is-rust.md:6
msgid "`rustc` uses LLVM as its backend."
msgstr ""
#: src/welcome-day-1/what-is-rust.md:7
msgid ""
"Rust supports many [platforms and architectures](https://doc.rust-lang.org/"
"nightly/rustc/platform-support.html):"
msgstr ""
#: src/welcome-day-1/what-is-rust.md:9
msgid "x86, ARM, WebAssembly, ..."
msgstr ""
#: src/welcome-day-1/what-is-rust.md:10
msgid "Linux, Mac, Windows, ..."
msgstr ""
#: src/welcome-day-1/what-is-rust.md:11
msgid "Rust is used for a wide range of devices:"
msgstr ""
#: src/welcome-day-1/what-is-rust.md:12
msgid "firmware and boot loaders,"
msgstr ""
#: src/welcome-day-1/what-is-rust.md:13
msgid "smart displays,"
msgstr ""
#: src/welcome-day-1/what-is-rust.md:14
msgid "mobile phones,"
msgstr ""
#: src/welcome-day-1/what-is-rust.md:15
msgid "desktops,"
msgstr ""
#: src/welcome-day-1/what-is-rust.md:16
msgid "servers."
msgstr ""
#: src/welcome-day-1/what-is-rust.md:21
msgid "Rust fits in the same area as C++:"
msgstr "Rust har det samme anvendelsesområde som C++:"
#: src/welcome-day-1/what-is-rust.md:23
msgid "High flexibility."
msgstr ""
#: src/welcome-day-1/what-is-rust.md:24
msgid "High level of control."
msgstr ""
#: src/welcome-day-1/what-is-rust.md:25
msgid ""
"Can be scaled down to very constrained devices such as microcontrollers."
msgstr ""
#: src/welcome-day-1/what-is-rust.md:26
msgid "Has no runtime or garbage collection."
msgstr ""
#: src/welcome-day-1/what-is-rust.md:27
msgid "Focuses on reliability and safety without sacrificing performance."
msgstr ""
#: src/hello-world.md:3
msgid ""
"Let us jump into the simplest possible Rust program, a classic Hello World "
"program:"
msgstr ""
#: src/hello-world.md:6
msgid ""
"```rust,editable\n"
"fn main() {\n"
" println!(\"Hello 🌍!\");\n"
"}\n"
"```"
msgstr ""
"```rust,editable\n"
"fn main() {\n"
" println!(\"Hallo 🌍!\");\n"
"}\n"
"```"
#: src/hello-world.md:12
msgid "What you see:"
msgstr "Hvad du ser:"
#: src/hello-world.md:14
msgid "Functions are introduced with `fn`."
msgstr ""
#: src/hello-world.md:15
msgid "Blocks are delimited by curly braces like in C and C++."
msgstr ""
#: src/hello-world.md:16
msgid "The `main` function is the entry point of the program."
msgstr ""
#: src/hello-world.md:17
msgid "Rust has hygienic macros, `println!` is an example of this."
msgstr ""
#: src/hello-world.md:18
msgid "Rust strings are UTF-8 encoded and can contain any Unicode character."
msgstr ""
#: src/hello-world.md:22
msgid ""
"This slide tries to make the students comfortable with Rust code. They will "
"see a ton of it over the next three days so we start small with something "
"familiar."
msgstr ""
#: src/hello-world.md:27
msgid ""
"Rust is very much like other languages in the C/C++/Java tradition. It is "
"imperative and it doesn't try to reinvent things unless absolutely necessary."
msgstr ""
#: src/hello-world.md:31
msgid "Rust is modern with full support for things like Unicode."
msgstr ""
#: src/hello-world.md:33
msgid ""
"Rust uses macros for situations where you want to have a variable number of "
"arguments (no function [overloading](basic-syntax/functions-interlude.md))."
msgstr ""
#: src/hello-world.md:36
msgid ""
"Macros being 'hygienic' means they don't accidentally capture identifiers "
"from the scope they are used in. Rust macros are actually only [partially "
"hygienic](https://veykril.github.io/tlborm/decl-macros/minutiae/hygiene."
"html)."
msgstr ""
#: src/hello-world.md:40
msgid ""
"Rust is multi-paradigm. For example, it has powerful [object-oriented "
"programming features](https://doc.rust-lang.org/book/ch17-00-oop.html), and, "
"while it is not a functional language, it includes a range of [functional "
"concepts](https://doc.rust-lang.org/book/ch13-00-functional-features.html)."
msgstr ""
#: src/hello-world/small-example.md:3
msgid "Here is a small example program in Rust:"
msgstr "Her er et lille eksempel på et program i Rust:"
#: src/hello-world/small-example.md:5
msgid ""
"```rust,editable\n"
"fn main() { // Program entry point\n"
" let mut x: i32 = 6; // Mutable variable binding\n"
" print!(\"{x}\"); // Macro for printing, like printf\n"
" while x != 1 { // No parenthesis around expression\n"
" if x % 2 == 0 { // Math like in other languages\n"
" x = x / 2;\n"
" } else {\n"
" x = 3 * x + 1;\n"
" }\n"
" print!(\" -> {x}\");\n"
" }\n"
" println!();\n"
"}\n"
"```"
msgstr ""
#: src/hello-world/small-example.md:23
msgid ""
"The code implements the Collatz conjecture: it is believed that the loop "
"will always end, but this is not yet proved. Edit the code and play with "
"different inputs."
msgstr ""
#: src/hello-world/small-example.md:29
msgid ""
"Explain that all variables are statically typed. Try removing `i32` to "
"trigger type inference. Try with `i8` instead and trigger a runtime integer "
"overflow."
msgstr ""
#: src/hello-world/small-example.md:32
msgid "Change `let mut x` to `let x`, discuss the compiler error."
msgstr ""
#: src/hello-world/small-example.md:34
msgid ""
"Show how `print!` gives a compilation error if the arguments don't match the "
"format string."
msgstr ""
#: src/hello-world/small-example.md:37
msgid ""
"Show how you need to use `{}` as a placeholder if you want to print an "
"expression which is more complex than just a single variable."
msgstr ""
#: src/hello-world/small-example.md:40
msgid ""
"Show the students the standard library, show them how to search for `std::"
"fmt` which has the rules of the formatting mini-language. It's important "
"that the students become familiar with searching in the standard library."
msgstr ""
#: src/hello-world/small-example.md:44
msgid ""
"In a shell `rustup doc std::fmt` will open a browser on the local std::fmt "
"documentation"
msgstr ""
#: src/why-rust.md:3
msgid "Some unique selling points of Rust:"
msgstr ""
#: src/why-rust.md:5
msgid "Compile time memory safety."
msgstr ""
#: src/why-rust.md:6
msgid "Lack of undefined runtime behavior."
msgstr ""
#: src/why-rust.md:7
msgid "Modern language features."
msgstr ""
#: src/why-rust.md:11
msgid ""
"Make sure to ask the class which languages they have experience with. "
"Depending on the answer you can highlight different features of Rust:"
msgstr ""
#: src/why-rust.md:14
msgid ""
"Experience with C or C++: Rust eliminates a whole class of _runtime errors_ "
"via the borrow checker. You get performance like in C and C++, but you don't "
"have the memory unsafety issues. In addition, you get a modern language with "
"constructs like pattern matching and built-in dependency management."
msgstr ""
#: src/why-rust.md:19
msgid ""
"Experience with Java, Go, Python, JavaScript...: You get the same memory "
"safety as in those languages, plus a similar high-level language feeling. In "
"addition you get fast and predictable performance like C and C++ (no garbage "
"collector) as well as access to low-level hardware (should you need it)"
msgstr ""
#: src/why-rust/compile-time.md:3
msgid "Static memory management at compile time:"
msgstr ""
#: src/why-rust/compile-time.md:5
msgid "No uninitialized variables."
msgstr ""
#: src/why-rust/compile-time.md:6
msgid "No memory leaks (_mostly_, see notes)."
msgstr ""
#: src/why-rust/compile-time.md:7
msgid "No double-frees."
msgstr ""
#: src/why-rust/compile-time.md:8
msgid "No use-after-free."
msgstr ""
#: src/why-rust/compile-time.md:9
msgid "No `NULL` pointers."
msgstr ""
#: src/why-rust/compile-time.md:10
msgid "No forgotten locked mutexes."
msgstr ""
#: src/why-rust/compile-time.md:11
msgid "No data races between threads."
msgstr ""
#: src/why-rust/compile-time.md:12
msgid "No iterator invalidation."
msgstr ""
#: src/why-rust/compile-time.md:16
msgid ""
"It is possible to produce memory leaks in (safe) Rust. Some examples are:"
msgstr ""
#: src/why-rust/compile-time.md:19
msgid ""
"You can use [`Box::leak`](https://doc.rust-lang.org/std/boxed/struct.Box."
"html#method.leak) to leak a pointer. A use of this could be to get runtime-"
"initialized and runtime-sized static variables"
msgstr ""
#: src/why-rust/compile-time.md:21
msgid ""
"You can use [`std::mem::forget`](https://doc.rust-lang.org/std/mem/fn.forget."
"html) to make the compiler \"forget\" about a value (meaning the destructor "
"is never run)."
msgstr ""
#: src/why-rust/compile-time.md:23
msgid ""
"You can also accidentally create a [reference cycle](https://doc.rust-lang."
"org/book/ch15-06-reference-cycles.html) with `Rc` or `Arc`."
msgstr ""
#: src/why-rust/compile-time.md:25
msgid ""
"In fact, some will consider infinitely populating a collection a memory leak "
"and Rust does not protect from those."
msgstr ""
#: src/why-rust/compile-time.md:28
msgid ""
"For the purpose of this course, \"No memory leaks\" should be understood as "
"\"Pretty much no _accidental_ memory leaks\"."
msgstr ""
#: src/why-rust/runtime.md:3
msgid "No undefined behavior at runtime:"
msgstr ""
#: src/why-rust/runtime.md:5
msgid "Array access is bounds checked."
msgstr ""
#: src/why-rust/runtime.md:6
msgid "Integer overflow is defined (panic or wrap-around)."
msgstr ""
#: src/why-rust/runtime.md:12
msgid ""
"Integer overflow is defined via the [`overflow-checks`](https://doc.rust-"
"lang.org/rustc/codegen-options/index.html#overflow-checks) compile-time "
"flag. If enabled, the program will panic (a controlled crash of the "
"program), otherwise you get wrap-around semantics. By default, you get "
"panics in debug mode (`cargo build`) and wrap-around in release mode (`cargo "
"build --release`)."
msgstr ""
#: src/why-rust/runtime.md:18
msgid ""
"Bounds checking cannot be disabled with a compiler flag. It can also not be "
"disabled directly with the `unsafe` keyword. However, `unsafe` allows you to "
"call functions such as `slice::get_unchecked` which does not do bounds "
"checking."
msgstr ""
#: src/why-rust/modern.md:3
msgid "Rust is built with all the experience gained in the last decades."
msgstr ""
#: src/why-rust/modern.md:5
msgid "Language Features"
msgstr ""
#: src/why-rust/modern.md:7
msgid "Enums and pattern matching."
msgstr ""
#: src/why-rust/modern.md:8
msgid "Generics."
msgstr ""
#: src/why-rust/modern.md:9
msgid "No overhead FFI."
msgstr ""
#: src/why-rust/modern.md:10
msgid "Zero-cost abstractions."
msgstr ""
#: src/why-rust/modern.md:12
msgid "Tooling"
msgstr ""
#: src/why-rust/modern.md:14
msgid "Great compiler errors."
msgstr ""
#: src/why-rust/modern.md:15
msgid "Built-in dependency manager."
msgstr ""
#: src/why-rust/modern.md:16
msgid "Built-in support for testing."
msgstr ""
#: src/why-rust/modern.md:17
msgid "Excellent Language Server Protocol support."
msgstr ""
#: src/why-rust/modern.md:23
msgid ""
"Zero-cost abstractions, similar to C++, means that you don't have to 'pay' "
"for higher-level programming constructs with memory or CPU. For example, "
"writing a loop using `for` should result in roughly the same low level "
"instructions as using the `.iter().fold()` construct."
msgstr ""
#: src/why-rust/modern.md:28
msgid ""
"It may be worth mentioning that Rust enums are 'Algebraic Data Types', also "
"known as 'sum types', which allow the type system to express things like "
"`Option` and `Result`."
msgstr ""
#: src/why-rust/modern.md:32
msgid ""
"Remind people to read the errors --- many developers have gotten used to "
"ignore lengthy compiler output. The Rust compiler is significantly more "
"talkative than other compilers. It will often provide you with _actionable_ "
"feedback, ready to copy-paste into your code."
msgstr ""
#: src/why-rust/modern.md:37
msgid ""
"The Rust standard library is small compared to languages like Java, Python, "
"and Go. Rust does not come with several things you might consider standard "
"and essential:"
msgstr ""
#: src/why-rust/modern.md:41
msgid "a random number generator, but see [rand](https://docs.rs/rand/)."
msgstr ""
#: src/why-rust/modern.md:42
msgid "support for SSL or TLS, but see [rusttls](https://docs.rs/rustls/)."
msgstr ""
#: src/why-rust/modern.md:43
msgid "support for JSON, but see [serde_json](https://docs.rs/serde_json/)."
msgstr ""
#: src/why-rust/modern.md:45
msgid ""
"The reasoning behind this is that functionality in the standard library "
"cannot go away, so it has to be very stable. For the examples above, the "
"Rust community is still working on finding the best solution --- and perhaps "
"there isn't a single \"best solution\" for some of these things."
msgstr ""
#: src/why-rust/modern.md:50
msgid ""
"Rust comes with a built-in package manager in the form of Cargo and this "
"makes it trivial to download and compile third-party crates. A consequence "
"of this is that the standard library can be smaller."
msgstr ""
#: src/why-rust/modern.md:54
msgid ""
"Discovering good third-party crates can be a problem. Sites like help with this by letting you compare health metrics for crates to "
"find a good and trusted one."
msgstr ""
#: src/why-rust/modern.md:58
msgid ""
"[rust-analyzer](https://rust-analyzer.github.io/) is a well supported LSP "
"implementation used in major IDEs and text editors."
msgstr ""
#: src/basic-syntax.md:3
msgid "Much of the Rust syntax will be familiar to you from C, C++ or Java:"
msgstr ""
#: src/basic-syntax.md:5
msgid "Blocks and scopes are delimited by curly braces."
msgstr ""
#: src/basic-syntax.md:6
msgid ""
"Line comments are started with `//`, block comments are delimited by `/* ... "
"*/`."
msgstr ""
#: src/basic-syntax.md:8
msgid "Keywords like `if` and `while` work the same."
msgstr ""
#: src/basic-syntax.md:9
msgid "Variable assignment is done with `=`, comparison is done with `==`."
msgstr ""
#: src/basic-syntax/scalar-types.md:3 src/basic-syntax/compound-types.md:3
#: src/exercises/day-3/safe-ffi-wrapper.md:16
msgid "Types"
msgstr ""
#: src/basic-syntax/scalar-types.md:3 src/basic-syntax/compound-types.md:3
msgid "Literals"
msgstr ""
#: src/basic-syntax/scalar-types.md:5
msgid "Signed integers"
msgstr ""
#: src/basic-syntax/scalar-types.md:5
msgid "`i8`, `i16`, `i32`, `i64`, `i128`, `isize`"
msgstr ""
#: src/basic-syntax/scalar-types.md:5
msgid "`-10`, `0`, `1_000`, `123_i64`"
msgstr ""
#: src/basic-syntax/scalar-types.md:6
msgid "Unsigned integers"
msgstr ""
#: src/basic-syntax/scalar-types.md:6
msgid "`u8`, `u16`, `u32`, `u64`, `u128`, `usize`"
msgstr ""
#: src/basic-syntax/scalar-types.md:6
msgid "`0`, `123`, `10_u16`"
msgstr ""
#: src/basic-syntax/scalar-types.md:7
msgid "Floating point numbers"
msgstr ""
#: src/basic-syntax/scalar-types.md:7
msgid "`f32`, `f64`"
msgstr ""
#: src/basic-syntax/scalar-types.md:7
msgid "`3.14`, `-10.0e20`, `2_f32`"
msgstr ""
#: src/basic-syntax/scalar-types.md:8
msgid "Strings"
msgstr ""
#: src/basic-syntax/scalar-types.md:8
msgid "`&str`"
msgstr ""
#: src/basic-syntax/scalar-types.md:8
msgid "`\"foo\"`, `\"two\\nlines\"`"
msgstr ""
#: src/basic-syntax/scalar-types.md:9
msgid "Unicode scalar values"
msgstr ""
#: src/basic-syntax/scalar-types.md:9
msgid "`char`"
msgstr ""
#: src/basic-syntax/scalar-types.md:9
msgid "`'a'`, `'α'`, `'∞'`"
msgstr ""
#: src/basic-syntax/scalar-types.md:10
msgid "Booleans"
msgstr ""
#: src/basic-syntax/scalar-types.md:10
msgid "`bool`"
msgstr ""
#: src/basic-syntax/scalar-types.md:10
msgid "`true`, `false`"
msgstr ""
#: src/basic-syntax/scalar-types.md:12
msgid "The types have widths as follows:"
msgstr ""
#: src/basic-syntax/scalar-types.md:14
msgid "`iN`, `uN`, and `fN` are _N_ bits wide,"
msgstr ""
#: src/basic-syntax/scalar-types.md:15
msgid "`isize` and `usize` are the width of a pointer,"
msgstr ""
#: src/basic-syntax/scalar-types.md:16
msgid "`char` is 32 bits wide,"
msgstr ""
#: src/basic-syntax/scalar-types.md:17
msgid "`bool` is 8 bits wide."
msgstr ""
#: src/basic-syntax/scalar-types.md:21
msgid "There are a few syntaxes which are not shown above:"
msgstr ""
#: src/basic-syntax/scalar-types.md:23
msgid ""
"Raw strings allow you to create a `&str` value with escapes disabled: "
"`r\"\\n\" == \"\\\\n\"`. You can embed double-quotes by using an equal "
"amount of `#` on either side of the quotes:"
msgstr ""
#: src/basic-syntax/scalar-types.md:27
msgid ""
"```rust,editable\n"
"fn main() {\n"
" println!(r#\"link\"#);\n"
" println!(\"link\");\n"
"}\n"
"```"
msgstr ""
#: src/basic-syntax/scalar-types.md:34
msgid "Byte strings allow you to create a `&[u8]` value directly:"
msgstr ""
#: src/basic-syntax/scalar-types.md:36
msgid ""
"```rust,editable\n"
"fn main() {\n"
" println!(\"{:?}\", b\"abc\");\n"
" println!(\"{:?}\", &[97, 98, 99]);\n"
"}\n"
"```"
msgstr ""
#: src/basic-syntax/scalar-types.md:43
msgid ""
"All underscores in numbers can be left out, they are for legibility only. So "
"`1_000` can be written as `1000` (or `10_00`), and `123_i64` can be written "
"as `123i64`."
msgstr ""
#: src/basic-syntax/compound-types.md:5
msgid "Arrays"
msgstr ""
#: src/basic-syntax/compound-types.md:5
msgid "`[T; N]`"
msgstr ""
#: src/basic-syntax/compound-types.md:5
msgid "`[20, 30, 40]`, `[0; 3]`"
msgstr ""
#: src/basic-syntax/compound-types.md:6
msgid "Tuples"
msgstr ""
#: src/basic-syntax/compound-types.md:6
msgid "`()`, `(T,)`, `(T1, T2)`, ..."
msgstr ""
#: src/basic-syntax/compound-types.md:6
msgid "`()`, `('x',)`, `('x', 1.2)`, ..."
msgstr ""
#: src/basic-syntax/compound-types.md:8
msgid "Array assignment and access:"
msgstr ""
#: src/basic-syntax/compound-types.md:10
msgid ""
"```rust,editable\n"
"fn main() {\n"
" let mut a: [i8; 10] = [42; 10];\n"
" a[5] = 0;\n"
" println!(\"a: {:?}\", a);\n"
"}\n"
"```"
msgstr ""
#: src/basic-syntax/compound-types.md:18
msgid "Tuple assignment and access:"
msgstr ""
#: src/basic-syntax/compound-types.md:20
msgid ""
"```rust,editable\n"
"fn main() {\n"
" let t: (i8, bool) = (7, true);\n"
" println!(\"1st index: {}\", t.0);\n"
" println!(\"2nd index: {}\", t.1);\n"
"}\n"
"```"
msgstr ""
#: src/basic-syntax/compound-types.md:32
msgid "Arrays:"
msgstr ""
#: src/basic-syntax/compound-types.md:34
msgid ""
"A value of the array type `[T; N]` holds `N` (a compile-time constant) "
"elements of the same type `T`. Note that the length of the array is _part of "
"its type_, which means that `[u8; 3]` and `[u8; 4]` are considered two "
"different types."
msgstr ""
#: src/basic-syntax/compound-types.md:38
msgid "We can use literals to assign values to arrays."
msgstr ""
#: src/basic-syntax/compound-types.md:40
msgid ""
"In the main function, the print statement asks for the debug implementation "
"with the `?` format parameter: `{}` gives the default output, `{:?}` gives "
"the debug output. We could also have used `{a}` and `{a:?}` without "
"specifying the value after the format string."
msgstr ""
#: src/basic-syntax/compound-types.md:45
msgid ""
"Adding `#`, eg `{a:#?}`, invokes a \"pretty printing\" format, which can be "
"easier to read."
msgstr ""
#: src/basic-syntax/compound-types.md:47
msgid "Tuples:"
msgstr ""
#: src/basic-syntax/compound-types.md:49
msgid "Like arrays, tuples have a fixed length."
msgstr ""
#: src/basic-syntax/compound-types.md:51
msgid "Tuples group together values of different types into a compound type."
msgstr ""
#: src/basic-syntax/compound-types.md:53
msgid ""
"Fields of a tuple can be accessed by the period and the index of the value, "
"e.g. `t.0`, `t.1`."
msgstr ""
#: src/basic-syntax/compound-types.md:55
msgid ""
"The empty tuple `()` is also known as the \"unit type\". It is both a type, "
"and the only valid value of that type - that is to say both the type and its "
"value are expressed as `()`. It is used to indicate, for example, that a "
"function or expression has no return value, as we'll see in a future slide. "
msgstr ""
#: src/basic-syntax/compound-types.md:59
msgid ""
"You can think of it as `void` that can be familiar to you from other "
"programming languages."
msgstr ""
#: src/basic-syntax/references.md:3
msgid "Like C++, Rust has references:"
msgstr ""
#: src/basic-syntax/references.md:5
msgid ""
"```rust,editable\n"
"fn main() {\n"
" let mut x: i32 = 10;\n"
" let ref_x: &mut i32 = &mut x;\n"
" *ref_x = 20;\n"
" println!(\"x: {x}\");\n"
"}\n"
"```"
msgstr ""
#: src/basic-syntax/references.md:14
msgid "Some notes:"
msgstr ""
#: src/basic-syntax/references.md:16
msgid ""
"We must dereference `ref_x` when assigning to it, similar to C and C++ "
"pointers."
msgstr ""
#: src/basic-syntax/references.md:17
msgid ""
"Rust will auto-dereference in some cases, in particular when invoking "
"methods (try `ref_x.count_ones()`)."
msgstr ""
#: src/basic-syntax/references.md:19
msgid ""
"References that are declared as `mut` can be bound to different values over "
"their lifetime."
msgstr ""
#: src/basic-syntax/references.md:25
msgid ""
"Be sure to note the difference between `let mut ref_x: &i32` and `let ref_x: "
"&mut i32`. The first one represents a mutable reference which can be bound "
"to different values, while the second represents a reference to a mutable "
"value."
msgstr ""
#: src/basic-syntax/references-dangling.md:3
msgid "Rust will statically forbid dangling references:"
msgstr ""
#: src/basic-syntax/references-dangling.md:5
msgid ""
"```rust,editable,compile_fail\n"
"fn main() {\n"
" let ref_x: &i32;\n"
" {\n"
" let x: i32 = 10;\n"
" ref_x = &x;\n"
" }\n"
" println!(\"ref_x: {ref_x}\");\n"
"}\n"
"```"
msgstr ""
#: src/basic-syntax/references-dangling.md:16
msgid "A reference is said to \"borrow\" the value it refers to."
msgstr ""
#: src/basic-syntax/references-dangling.md:17
msgid ""
"Rust is tracking the lifetimes of all references to ensure they live long "
"enough."
msgstr ""
#: src/basic-syntax/references-dangling.md:19
msgid "We will talk more about borrowing when we get to ownership."
msgstr ""
#: src/basic-syntax/slices.md:3
msgid "A slice gives you a view into a larger collection:"
msgstr ""
#: src/basic-syntax/slices.md:5
msgid ""
"```rust,editable\n"
"fn main() {\n"
" let mut a: [i32; 6] = [10, 20, 30, 40, 50, 60];\n"
" println!(\"a: {a:?}\");\n"
"\n"
" let s: &[i32] = &a[2..4];\n"
"\n"
" println!(\"s: {s:?}\");\n"
"}\n"
"```"
msgstr ""
#: src/basic-syntax/slices.md:16
msgid "Slices borrow data from the sliced type."
msgstr ""
#: src/basic-syntax/slices.md:17
msgid "Question: What happens if you modify `a[3]` right before printing `s`?"
msgstr ""
#: src/basic-syntax/slices.md:21
msgid ""
"We create a slice by borrowing `a` and specifying the starting and ending "
"indexes in brackets."
msgstr ""
#: src/basic-syntax/slices.md:23
msgid ""
"If the slice starts at index 0, Rust’s range syntax allows us to drop the "
"starting index, meaning that `&a[0..a.len()]` and `&a[..a.len()]` are "
"identical."
msgstr ""
#: src/basic-syntax/slices.md:25
msgid ""
"The same is true for the last index, so `&a[2..a.len()]` and `&a[2..]` are "
"identical."
msgstr ""
#: src/basic-syntax/slices.md:27
msgid ""
"To easily create a slice of the full array, we can therefore use `&a[..]`."
msgstr ""
#: src/basic-syntax/slices.md:29
msgid ""
"`s` is a reference to a slice of `i32`s. Notice that the type of `s` "
"(`&[i32]`) no longer mentions the array length. This allows us to perform "
"computation on slices of different sizes."
msgstr ""
#: src/basic-syntax/slices.md:31
msgid ""
"Slices always borrow from another object. In this example, `a` has to remain "
"'alive' (in scope) for at least as long as our slice. "
msgstr ""
#: src/basic-syntax/slices.md:33
msgid ""
"The question about modifying `a[3]` can spark an interesting discussion, but "
"the answer is that for memory safety reasons you cannot do it through `a` at "
"this point in the execution, but you can read the data from both `a` and `s` "
"safely. It works before you created the slice, and again after the "
"`println`, when the slice is no longer used. More details will be explained "
"in the borrow checker section."
msgstr ""
#: src/basic-syntax/string-slices.md:1
msgid "`String` vs `str`"
msgstr ""
#: src/basic-syntax/string-slices.md:3
msgid "We can now understand the two string types in Rust:"
msgstr ""
#: src/basic-syntax/string-slices.md:5
msgid ""
"```rust,editable\n"
"fn main() {\n"
" let s1: &str = \"World\";\n"
" println!(\"s1: {s1}\");\n"
"\n"
" let mut s2: String = String::from(\"Hello \");\n"
" println!(\"s2: {s2}\");\n"
" s2.push_str(s1);\n"
" println!(\"s2: {s2}\");\n"
" \n"
" let s3: &str = &s2[6..];\n"
" println!(\"s3: {s3}\");\n"
"}\n"
"```"
msgstr ""
#: src/basic-syntax/string-slices.md:20
msgid "Rust terminology:"
msgstr ""
#: src/basic-syntax/string-slices.md:22
msgid "`&str` an immutable reference to a string slice."
msgstr ""
#: src/basic-syntax/string-slices.md:23
msgid "`String` a mutable string buffer."
msgstr ""
#: src/basic-syntax/string-slices.md:27
msgid ""
"`&str` introduces a string slice, which is an immutable reference to UTF-8 "
"encoded string data stored in a block of memory. String literals "
"(`”Hello”`), are stored in the program’s binary."
msgstr ""
#: src/basic-syntax/string-slices.md:30
msgid ""
"Rust’s `String` type is a wrapper around a vector of bytes. As with a "
"`Vec`, it is owned."
msgstr ""
#: src/basic-syntax/string-slices.md:32
msgid ""
"As with many other types `String::from()` creates a string from a string "
"literal; `String::new()` creates a new empty string, to which string data "
"can be added using the `push()` and `push_str()` methods."
msgstr ""
#: src/basic-syntax/string-slices.md:35
msgid ""
"The `format!()` macro is a convenient way to generate an owned string from "
"dynamic values. It accepts the same format specification as `println!()`."
msgstr ""
#: src/basic-syntax/string-slices.md:38
msgid ""
"You can borrow `&str` slices from `String` via `&` and optionally range "
"selection."
msgstr ""
#: src/basic-syntax/string-slices.md:40
msgid ""
"For C++ programmers: think of `&str` as `const char*` from C++, but the one "
"that always points to a valid string in memory. Rust `String` is a rough "
"equivalent of `std::string` from C++ (main difference: it can only contain "
"UTF-8 encoded bytes and will never use a small-string optimization)."
msgstr ""
#: src/basic-syntax/functions.md:3
msgid ""
"A Rust version of the famous [FizzBuzz](https://en.wikipedia.org/wiki/"
"Fizz_buzz) interview question:"
msgstr ""
#: src/basic-syntax/functions.md:5
msgid ""
"```rust,editable\n"
"fn main() {\n"
" print_fizzbuzz_to(20);\n"
"}\n"
"\n"
"fn is_divisible(n: u32, divisor: u32) -> bool {\n"
" if divisor == 0 {\n"
" return false;\n"
" }\n"
" n % divisor == 0\n"
"}\n"
"\n"
"fn fizzbuzz(n: u32) -> String {\n"
" let fizz = if is_divisible(n, 3) { \"fizz\" } else { \"\" };\n"
" let buzz = if is_divisible(n, 5) { \"buzz\" } else { \"\" };\n"
" if fizz.is_empty() && buzz.is_empty() {\n"
" return format!(\"{n}\");\n"
" }\n"
" format!(\"{fizz}{buzz}\")\n"
"}\n"
"\n"
"fn print_fizzbuzz_to(n: u32) {\n"
" for i in 1..=n {\n"
" println!(\"{}\", fizzbuzz(i));\n"
" }\n"
"}\n"
"```"
msgstr ""
#: src/basic-syntax/functions.md:35
msgid ""
"We refer in `main` to a function written below. Neither forward declarations "
"nor headers are necessary. "
msgstr ""
#: src/basic-syntax/functions.md:36
msgid ""
"Declaration parameters are followed by a type (the reverse of some "
"programming languages), then a return type."
msgstr ""
#: src/basic-syntax/functions.md:37
msgid ""
"The last expression in a function body (or any block) becomes the return "
"value. Simply omit the `;` at the end of the expression."
msgstr ""
#: src/basic-syntax/functions.md:38
msgid ""
"Some functions have no return value, and return the 'unit type', `()`. The "
"compiler will infer this if the `-> ()` return type is omitted."
msgstr ""
#: src/basic-syntax/functions.md:39
msgid ""
"The range expression in the `for` loop in `print_fizzbuzz_to()` contains "
"`=n`, which causes it to include the upper bound."
msgstr ""
#: src/basic-syntax/rustdoc.md:3
msgid ""
"All language items in Rust can be documented using special `///` syntax."
msgstr ""
#: src/basic-syntax/rustdoc.md:5
msgid ""
"```rust,editable\n"
"/// Determine whether the first argument is divisible by the second "
"argument.\n"
"///\n"
"/// If the second argument is zero, the result is false.\n"
"fn is_divisible_by(lhs: u32, rhs: u32) -> bool {\n"
" if rhs == 0 {\n"
" return false; // Corner case, early return\n"
" }\n"
" lhs % rhs == 0 // The last expression in a block is the return "
"value\n"
"}\n"
"```"
msgstr ""
#: src/basic-syntax/rustdoc.md:17
msgid ""
"The contents are treated as Markdown. All published Rust library crates are "
"automatically documented at [`docs.rs`](https://docs.rs) using the [rustdoc]"
"(https://doc.rust-lang.org/rustdoc/what-is-rustdoc.html) tool. It is "
"idiomatic to document all public items in an API using this pattern."
msgstr ""
#: src/basic-syntax/rustdoc.md:24
msgid ""
"Show students the generated docs for the `rand` crate at [`docs.rs/rand`]"
"(https://docs.rs/rand)."
msgstr ""
#: src/basic-syntax/rustdoc.md:27
msgid ""
"This course does not include rustdoc on slides, just to save space, but in "
"real code they should be present."
msgstr ""
#: src/basic-syntax/rustdoc.md:30
msgid ""
"Inner doc comments are discussed later (in the page on modules) and need not "
"be addressed here."
msgstr ""
#: src/basic-syntax/rustdoc.md:33
msgid ""
"Rustdoc comments can contain code snippets that we can run and test using "
"`cargo test`. We will discuss these tests in the [Testing section](../"
"testing/doc-tests.html)."
msgstr ""
#: src/basic-syntax/methods.md:3
msgid ""
"Methods are functions associated with a type. The `self` argument of a "
"method is an instance of the type it is associated with:"
msgstr ""
#: src/basic-syntax/methods.md:6
msgid ""
"```rust,editable\n"
"struct Rectangle {\n"
" width: u32,\n"
" height: u32,\n"
"}\n"
"\n"
"impl Rectangle {\n"
" fn area(&self) -> u32 {\n"
" self.width * self.height\n"
" }\n"
"\n"
" fn inc_width(&mut self, delta: u32) {\n"
" self.width += delta;\n"
" }\n"
"}\n"
"\n"
"fn main() {\n"
" let mut rect = Rectangle { width: 10, height: 5 };\n"
" println!(\"old area: {}\", rect.area());\n"
" rect.inc_width(5);\n"
" println!(\"new area: {}\", rect.area());\n"
"}\n"
"```"
msgstr ""
#: src/basic-syntax/methods.md:30
msgid ""
"We will look much more at methods in today's exercise and in tomorrow's "
"class."
msgstr ""
#: src/basic-syntax/methods.md:34
msgid "Add a static method called `Rectangle::new` and call this from `main`:"
msgstr ""
#: src/basic-syntax/methods.md:36
msgid ""
"```rust,editable,compile_fail\n"
"fn new(width: u32, height: u32) -> Rectangle {\n"
" Rectangle { width, height }\n"
"}\n"
"```"
msgstr ""
#: src/basic-syntax/methods.md:42
msgid ""
"While _technically_, Rust does not have custom constructors, static methods "
"are commonly used to initialize structs (but don't have to). The actual "
"constructor, `Rectangle { width, height }`, could be called directly. See "
"the [Rustnomicon](https://doc.rust-lang.org/nomicon/constructors.html)."
msgstr ""
#: src/basic-syntax/methods.md:45
msgid ""
"Add a `Rectangle::square(width: u32)` constructor to illustrate that such "
"static methods can take arbitrary parameters."
msgstr ""
#: src/basic-syntax/functions-interlude.md:1
msgid "Function Overloading"
msgstr ""
#: src/basic-syntax/functions-interlude.md:3
msgid "Overloading is not supported:"
msgstr ""
#: src/basic-syntax/functions-interlude.md:5
msgid "Each function has a single implementation:"
msgstr ""
#: src/basic-syntax/functions-interlude.md:6
msgid "Always takes a fixed number of parameters."
msgstr ""
#: src/basic-syntax/functions-interlude.md:7
msgid "Always takes a single set of parameter types."
msgstr ""
#: src/basic-syntax/functions-interlude.md:8
msgid "Default values are not supported:"
msgstr ""
#: src/basic-syntax/functions-interlude.md:9
msgid "All call sites have the same number of arguments."
msgstr ""
#: src/basic-syntax/functions-interlude.md:10
msgid "Macros are sometimes used as an alternative."
msgstr ""
#: src/basic-syntax/functions-interlude.md:12
msgid "However, function parameters can be generic:"
msgstr ""
#: src/basic-syntax/functions-interlude.md:14
msgid ""
"```rust,editable\n"
"fn pick_one(a: T, b: T) -> T {\n"
" if std::process::id() % 2 == 0 { a } else { b }\n"
"}\n"
"\n"
"fn main() {\n"
" println!(\"coin toss: {}\", pick_one(\"heads\", \"tails\"));\n"
" println!(\"cash prize: {}\", pick_one(500, 1000));\n"
"}\n"
"```"
msgstr ""
#: src/basic-syntax/functions-interlude.md:27
msgid ""
"When using generics, the standard library's `Into` can provide a kind of "
"limited polymorphism on argument types. We will see more details in a later "
"section."
msgstr ""
#: src/exercises/day-1/morning.md:1
msgid "Day 1: Morning Exercises"
msgstr "Dag 1: formiddagsøvelser"
#: src/exercises/day-1/morning.md:3
msgid "In these exercises, we will explore two parts of Rust:"
msgstr ""
#: src/exercises/day-1/morning.md:5
msgid "Implicit conversions between types."
msgstr ""
#: src/exercises/day-1/morning.md:7
msgid "Arrays and `for` loops."
msgstr ""
#: src/exercises/day-1/morning.md:11
msgid "A few things to consider while solving the exercises:"
msgstr ""
#: src/exercises/day-1/morning.md:13
msgid ""
"Use a local Rust installation, if possible. This way you can get auto-"
"completion in your editor. See the page about [Using Cargo](../../cargo.md) "
"for details on installing Rust."
msgstr ""
#: src/exercises/day-1/morning.md:17
msgid "Alternatively, use the Rust Playground."
msgstr ""
#: src/exercises/day-1/morning.md:19
msgid ""
"The code snippets are not editable on purpose: the inline code snippets lose "
"their state if you navigate away from the page."
msgstr ""
#: src/exercises/day-1/morning.md:22 src/exercises/day-2/morning.md:11
#: src/exercises/day-3/morning.md:7 src/exercises/bare-metal/morning.md:7
#: src/exercises/concurrency/morning.md:12
msgid ""
"After looking at the exercises, you can look at the [solutions](solutions-"
"morning.md) provided."
msgstr ""
#: src/exercises/day-1/implicit-conversions.md:3
msgid ""
"Rust will not automatically apply _implicit conversions_ between types "
"([unlike C++](https://en.cppreference.com/w/cpp/language/"
"implicit_conversion)). You can see this in a program like this:"
msgstr ""
#: src/exercises/day-1/implicit-conversions.md:6
msgid ""
"```rust,editable,compile_fail\n"
"fn multiply(x: i16, y: i16) -> i16 {\n"
" x * y\n"
"}\n"
"\n"
"fn main() {\n"
" let x: i8 = 15;\n"
" let y: i16 = 1000;\n"
"\n"
" println!(\"{x} * {y} = {}\", multiply(x, y));\n"
"}\n"
"```"
msgstr ""
#: src/exercises/day-1/implicit-conversions.md:19
msgid ""
"The Rust integer types all implement the [`From`](https://doc.rust-lang."
"org/std/convert/trait.From.html) and [`Into`](https://doc.rust-lang.org/"
"std/convert/trait.Into.html) traits to let us convert between them. The "
"`From` trait has a single `from()` method and similarly, the `Into` "
"trait has a single `into()` method. Implementing these traits is how a type "
"expresses that it can be converted into another type."
msgstr ""
#: src/exercises/day-1/implicit-conversions.md:25
msgid ""
"The standard library has an implementation of `From for i16`, which "
"means that we can convert a variable `x` of type `i8` to an `i16` by "
"calling `i16::from(x)`. Or, simpler, with `x.into()`, because `From for "
"i16` implementation automatically create an implementation of `Into for "
"i8`."
msgstr ""
#: src/exercises/day-1/implicit-conversions.md:30
msgid ""
"The same applies for your own `From` implementations for your own types, so "
"it is sufficient to only implement `From` to get a respective `Into` "
"implementation automatically."
msgstr ""
#: src/exercises/day-1/implicit-conversions.md:33
msgid "Execute the above program and look at the compiler error."
msgstr ""
#: src/exercises/day-1/implicit-conversions.md:35
msgid "Update the code above to use `into()` to do the conversion."
msgstr ""
#: src/exercises/day-1/implicit-conversions.md:37
msgid ""
"Change the types of `x` and `y` to other things (such as `f32`, `bool`, "
"`i128`) to see which types you can convert to which other types. Try "
"converting small types to big types and the other way around. Check the "
"[standard library documentation](https://doc.rust-lang.org/std/convert/trait."
"From.html) to see if `From` is implemented for the pairs you check."
msgstr ""
#: src/exercises/day-1/for-loops.md:1
#: src/exercises/day-1/solutions-morning.md:3
msgid "Arrays and `for` Loops"
msgstr ""
#: src/exercises/day-1/for-loops.md:3
msgid "We saw that an array can be declared like this:"
msgstr ""
#: src/exercises/day-1/for-loops.md:5
msgid ""
"```rust\n"
"let array = [10, 20, 30];\n"
"```"
msgstr ""
#: src/exercises/day-1/for-loops.md:9
msgid ""
"You can print such an array by asking for its debug representation with `{:?}"
"`:"
msgstr ""
#: src/exercises/day-1/for-loops.md:11
msgid ""
"```rust,editable\n"
"fn main() {\n"
" let array = [10, 20, 30];\n"
" println!(\"array: {array:?}\");\n"
"}\n"
"```"
msgstr ""
#: src/exercises/day-1/for-loops.md:18
msgid ""
"Rust lets you iterate over things like arrays and ranges using the `for` "
"keyword:"
msgstr ""
#: src/exercises/day-1/for-loops.md:21
msgid ""
"```rust,editable\n"
"fn main() {\n"
" let array = [10, 20, 30];\n"
" print!(\"Iterating over array:\");\n"
" for n in &array {\n"
" print!(\" {n}\");\n"
" }\n"
" println!();\n"
"\n"
" print!(\"Iterating over range:\");\n"
" for i in 0..3 {\n"
" print!(\" {}\", array[i]);\n"
" }\n"
" println!();\n"
"}\n"
"```"
msgstr ""
#: src/exercises/day-1/for-loops.md:38
msgid ""
"Use the above to write a function `pretty_print` which pretty-print a matrix "
"and a function `transpose` which will transpose a matrix (turn rows into "
"columns):"
msgstr ""
#: src/exercises/day-1/for-loops.md:41
msgid ""
"```bob\n"
" ⎛⎡1 2 3⎤⎞ ⎡1 4 7⎤\n"
"\"transpose\"⎜⎢4 5 6⎥⎟ \"==\"⎢2 5 8⎥\n"
" ⎝⎣7 8 9⎦⎠ ⎣3 6 9⎦\n"
"```"
msgstr ""
"```bob\n"
" ⎛⎡1 2 3⎤⎞ ⎡1 4 7⎤\n"
"\"transpose\"⎜⎢4 5 6⎥⎟ \"==\"⎢2 5 8⎥\n"
" ⎝⎣7 8 9⎦⎠ ⎣3 6 9⎦\n"
"```"
#: src/exercises/day-1/for-loops.md:47
msgid "Hard-code both functions to operate on 3 × 3 matrices."
msgstr ""
#: src/exercises/day-1/for-loops.md:49
msgid ""
"Copy the code below to and implement the "
"functions:"
msgstr ""
#: src/exercises/day-1/for-loops.md:52
msgid ""
"```rust,should_panic\n"
"// TODO: remove this when you're done with your implementation.\n"
"#![allow(unused_variables, dead_code)]\n"
"\n"
"fn transpose(matrix: [[i32; 3]; 3]) -> [[i32; 3]; 3] {\n"
" unimplemented!()\n"
"}\n"
"\n"
"fn pretty_print(matrix: &[[i32; 3]; 3]) {\n"
" unimplemented!()\n"
"}\n"
"\n"
"fn main() {\n"
" let matrix = [\n"
" [101, 102, 103], // <-- the comment makes rustfmt add a newline\n"
" [201, 202, 203],\n"
" [301, 302, 303],\n"
" ];\n"
"\n"
" println!(\"matrix:\");\n"
" pretty_print(&matrix);\n"
"\n"
" let transposed = transpose(matrix);\n"
" println!(\"transposed:\");\n"
" pretty_print(&transposed);\n"
"}\n"
"```"
msgstr ""
#: src/exercises/day-1/for-loops.md:80
msgid "Bonus Question"
msgstr ""
#: src/exercises/day-1/for-loops.md:82
msgid ""
"Could you use `&[i32]` slices instead of hard-coded 3 × 3 matrices for your "
"argument and return types? Something like `&[&[i32]]` for a two-dimensional "
"slice-of-slices. Why or why not?"
msgstr ""
#: src/exercises/day-1/for-loops.md:87
msgid ""
"See the [`ndarray` crate](https://docs.rs/ndarray/) for a production quality "
"implementation."
msgstr ""
#: src/exercises/day-1/for-loops.md:92
msgid ""
"The solution and the answer to the bonus section are available in the "
"[Solution](solutions-morning.md#arrays-and-for-loops) section."
msgstr ""
#: src/exercises/day-1/for-loops.md:95
msgid ""
"The use of the reference `&array` within `for n in &array` is a subtle "
"preview of issues of ownership that will come later in the afternoon."
msgstr ""
#: src/exercises/day-1/for-loops.md:98
msgid "Without the `&`..."
msgstr ""
#: src/exercises/day-1/for-loops.md:99
msgid ""
"The loop would have been one that consumes the array. This is a change "
"[introduced in the 2021 Edition](https://doc.rust-lang.org/edition-guide/"
"rust-2021/IntoIterator-for-arrays.html)."
msgstr ""
#: src/exercises/day-1/for-loops.md:102
msgid ""
"An implicit array copy would have occured. Since `i32` is a copy type, then "
"`[i32; 3]` is also a copy type."
msgstr ""
#: src/basic-syntax/variables.md:3
msgid ""
"Rust provides type safety via static typing. Variable bindings are immutable "
"by default:"
msgstr ""
#: src/basic-syntax/variables.md:6
msgid ""
"```rust,editable\n"
"fn main() {\n"
" let x: i32 = 10;\n"
" println!(\"x: {x}\");\n"
" // x = 20;\n"
" // println!(\"x: {x}\");\n"
"}\n"
"```"
msgstr ""
#: src/basic-syntax/variables.md:17
msgid ""
"Due to type inference the `i32` is optional. We will gradually show the "
"types less and less as the course progresses."
msgstr ""
#: src/basic-syntax/type-inference.md:3
msgid "Rust will look at how the variable is _used_ to determine the type:"
msgstr ""
#: src/basic-syntax/type-inference.md:5
msgid ""
"```rust,editable\n"
"fn takes_u32(x: u32) {\n"
" println!(\"u32: {x}\");\n"
"}\n"
"\n"
"fn takes_i8(y: i8) {\n"
" println!(\"i8: {y}\");\n"
"}\n"
"\n"
"fn main() {\n"
" let x = 10;\n"
" let y = 20;\n"
"\n"
" takes_u32(x);\n"
" takes_i8(y);\n"
" // takes_u32(y);\n"
"}\n"
"```"
msgstr ""
#: src/basic-syntax/type-inference.md:26
msgid ""
"This slide demonstrates how the Rust compiler infers types based on "
"constraints given by variable declarations and usages."
msgstr ""
#: src/basic-syntax/type-inference.md:28
msgid ""
"It is very important to emphasize that variables declared like this are not "
"of some sort of dynamic \"any type\" that can hold any data. The machine "
"code generated by such declaration is identical to the explicit declaration "
"of a type. The compiler does the job for us and helps us write more concise "
"code."
msgstr ""
#: src/basic-syntax/type-inference.md:32
msgid ""
"The following code tells the compiler to copy into a certain generic "
"container without the code ever explicitly specifying the contained type, "
"using `_` as a placeholder:"
msgstr ""
#: src/basic-syntax/type-inference.md:34
msgid ""
"```rust,editable\n"
"fn main() {\n"
" let mut v = Vec::new();\n"
" v.push((10, false));\n"
" v.push((20, true));\n"
" println!(\"v: {v:?}\");\n"
"\n"
" let vv = v.iter().collect::>();\n"
" println!(\"vv: {vv:?}\");\n"
"}\n"
"```"
msgstr ""
#: src/basic-syntax/type-inference.md:46
msgid ""
"[`collect`](https://doc.rust-lang.org/stable/std/iter/trait.Iterator."
"html#method.collect) relies on [`FromIterator`](https://doc.rust-lang.org/"
"std/iter/trait.FromIterator.html), which [`HashSet`](https://doc.rust-lang."
"org/std/collections/struct.HashSet.html#impl-FromIterator%3CT%3E-for-"
"HashSet%3CT,+S%3E) implements."
msgstr ""
#: src/basic-syntax/static-and-const.md:1
msgid "Static and Constant Variables"
msgstr ""
#: src/basic-syntax/static-and-const.md:3
msgid ""
"Static and constant variables are two different ways to create globally-"
"scoped values that cannot be moved or reallocated during the execution of "
"the program. "
msgstr ""
#: src/basic-syntax/static-and-const.md:6
msgid "`const`"
msgstr ""
#: src/basic-syntax/static-and-const.md:8
msgid ""
"Constant variables are evaluated at compile time and their values are "
"inlined wherever they are used:"
msgstr ""
#: src/basic-syntax/static-and-const.md:11
msgid ""
"```rust,editable\n"
"const DIGEST_SIZE: usize = 3;\n"
"const ZERO: Option = Some(42);\n"
"\n"
"fn compute_digest(text: &str) -> [u8; DIGEST_SIZE] {\n"
" let mut digest = [ZERO.unwrap_or(0); DIGEST_SIZE];\n"
" for (idx, &b) in text.as_bytes().iter().enumerate() {\n"
" digest[idx % DIGEST_SIZE] = digest[idx % DIGEST_SIZE]."
"wrapping_add(b);\n"
" }\n"
" digest\n"
"}\n"
"\n"
"fn main() {\n"
" let digest = compute_digest(\"Hello\");\n"
" println!(\"Digest: {digest:?}\");\n"
"}\n"
"```"
msgstr ""
#: src/basic-syntax/static-and-const.md:29
msgid ""
"According to the [Rust RFC Book](https://rust-lang.github.io/rfcs/0246-const-"
"vs-static.html) these are inlined upon use."
msgstr ""
#: src/basic-syntax/static-and-const.md:31
msgid ""
"Only functions marked `const` can be called at compile time to generate "
"`const` values. `const` functions can however be called at runtime."
msgstr ""
#: src/basic-syntax/static-and-const.md:33
msgid "`static`"
msgstr ""
#: src/basic-syntax/static-and-const.md:35
msgid ""
"Static variables will live during the whole execution of the program, and "
"therefore will not move:"
msgstr ""
#: src/basic-syntax/static-and-const.md:37
msgid ""
"```rust,editable\n"
"static BANNER: &str = \"Welcome to RustOS 3.14\";\n"
"\n"
"fn main() {\n"
" println!(\"{BANNER}\");\n"
"}\n"
"```"
msgstr ""
#: src/basic-syntax/static-and-const.md:45
msgid ""
"As noted in the [Rust RFC Book](https://rust-lang.github.io/rfcs/0246-const-"
"vs-static.html), these are not inlined upon use and have an actual "
"associated memory location. This is useful for unsafe and embedded code, "
"and the variable lives through the entirety of the program execution. When a "
"globally-scoped value does not have a reason to need object identity, "
"`const` is generally preferred."
msgstr ""
#: src/basic-syntax/static-and-const.md:49
msgid ""
"Because `static` variables are accessible from any thread, they must be "
"`Sync`. Interior mutability is possible through a [`Mutex`](https://doc.rust-"
"lang.org/std/sync/struct.Mutex.html), atomic or similar. It is also possible "
"to have mutable statics, but they require manual synchronisation so any "
"access to them requires `unsafe` code. We will look at [mutable statics](../"
"unsafe/mutable-static-variables.md) in the chapter on Unsafe Rust."
msgstr ""
#: src/basic-syntax/static-and-const.md:57
msgid "Mention that `const` behaves semantically similar to C++'s `constexpr`."
msgstr ""
#: src/basic-syntax/static-and-const.md:58
msgid ""
"`static`, on the other hand, is much more similar to a `const` or mutable "
"global variable in C++."
msgstr ""
#: src/basic-syntax/static-and-const.md:59
msgid ""
"`static` provides object identity: an address in memory and state as "
"required by types with interior mutability such as `Mutex`."
msgstr ""
#: src/basic-syntax/static-and-const.md:60
msgid ""
"It isn't super common that one would need a runtime evaluated constant, but "
"it is helpful and safer than using a static."
msgstr ""
#: src/basic-syntax/static-and-const.md:61
msgid "`thread_local` data can be created with the macro `std::thread_local`."
msgstr ""
#: src/basic-syntax/static-and-const.md:63
msgid "Properties table:"
msgstr ""
#: src/basic-syntax/static-and-const.md:65
msgid "Property"
msgstr ""
#: src/basic-syntax/static-and-const.md:65
msgid "Static"
msgstr ""
#: src/basic-syntax/static-and-const.md:65
msgid "Constant"
msgstr ""
#: src/basic-syntax/static-and-const.md:67
msgid "Has an address in memory"
msgstr ""
#: src/basic-syntax/static-and-const.md:67
#: src/basic-syntax/static-and-const.md:68
#: src/basic-syntax/static-and-const.md:70
#: src/basic-syntax/static-and-const.md:71
msgid "Yes"
msgstr ""
#: src/basic-syntax/static-and-const.md:67
msgid "No (inlined)"
msgstr ""
#: src/basic-syntax/static-and-const.md:68
msgid "Lives for the entire duration of the program"
msgstr ""
#: src/basic-syntax/static-and-const.md:68
#: src/basic-syntax/static-and-const.md:69
#: src/basic-syntax/static-and-const.md:71
msgid "No"
msgstr ""
#: src/basic-syntax/static-and-const.md:69
msgid "Can be mutable"
msgstr ""
#: src/basic-syntax/static-and-const.md:69
msgid "Yes (unsafe)"
msgstr ""
#: src/basic-syntax/static-and-const.md:70
msgid "Evaluated at compile time"
msgstr ""
#: src/basic-syntax/static-and-const.md:70
msgid "Yes (initialised at compile time)"
msgstr ""
#: src/basic-syntax/static-and-const.md:71
msgid "Inlined wherever it is used"
msgstr ""
#: src/basic-syntax/scopes-shadowing.md:3
msgid ""
"You can shadow variables, both those from outer scopes and variables from "
"the same scope:"
msgstr ""
#: src/basic-syntax/scopes-shadowing.md:6
msgid ""
"```rust,editable\n"
"fn main() {\n"
" let a = 10;\n"
" println!(\"before: {a}\");\n"
"\n"
" {\n"
" let a = \"hello\";\n"
" println!(\"inner scope: {a}\");\n"
"\n"
" let a = true;\n"
" println!(\"shadowed in inner scope: {a}\");\n"
" }\n"
"\n"
" println!(\"after: {a}\");\n"
"}\n"
"```"
msgstr ""
#: src/basic-syntax/scopes-shadowing.md:25
msgid ""
"Definition: Shadowing is different from mutation, because after shadowing "
"both variable's memory locations exist at the same time. Both are available "
"under the same name, depending where you use it in the code. "
msgstr ""
#: src/basic-syntax/scopes-shadowing.md:26
msgid "A shadowing variable can have a different type. "
msgstr ""
#: src/basic-syntax/scopes-shadowing.md:27
msgid ""
"Shadowing looks obscure at first, but is convenient for holding on to values "
"after `.unwrap()`."
msgstr ""
#: src/basic-syntax/scopes-shadowing.md:28
msgid ""
"The following code demonstrates why the compiler can't simply reuse memory "
"locations when shadowing an immutable variable in a scope, even if the type "
"does not change."
msgstr ""
#: src/basic-syntax/scopes-shadowing.md:30
msgid ""
"```rust,editable\n"
"fn main() {\n"
" let a = 1;\n"
" let b = &a;\n"
" let a = a + 1;\n"
" println!(\"{a} {b}\");\n"
"}\n"
"```"
msgstr ""
#: src/memory-management.md:3
msgid "Traditionally, languages have fallen into two broad categories:"
msgstr ""
#: src/memory-management.md:5
msgid "Full control via manual memory management: C, C++, Pascal, ..."
msgstr ""
#: src/memory-management.md:6
msgid ""
"Full safety via automatic memory management at runtime: Java, Python, Go, "
"Haskell, ..."
msgstr ""
#: src/memory-management.md:8
msgid "Rust offers a new mix:"
msgstr ""
#: src/memory-management.md:10
msgid ""
"Full control _and_ safety via compile time enforcement of correct memory "
"management."
msgstr ""
#: src/memory-management.md:13
msgid "It does this with an explicit ownership concept."
msgstr ""
#: src/memory-management.md:15
msgid "First, let's refresh how memory management works."
msgstr ""
#: src/memory-management/stack-vs-heap.md:1
msgid "The Stack vs The Heap"
msgstr ""
#: src/memory-management/stack-vs-heap.md:3
msgid "Stack: Continuous area of memory for local variables."
msgstr ""
#: src/memory-management/stack-vs-heap.md:4
msgid "Values have fixed sizes known at compile time."
msgstr ""
#: src/memory-management/stack-vs-heap.md:5
msgid "Extremely fast: just move a stack pointer."
msgstr ""
#: src/memory-management/stack-vs-heap.md:6
msgid "Easy to manage: follows function calls."
msgstr ""
#: src/memory-management/stack-vs-heap.md:7
msgid "Great memory locality."
msgstr ""
#: src/memory-management/stack-vs-heap.md:9
msgid "Heap: Storage of values outside of function calls."
msgstr ""
#: src/memory-management/stack-vs-heap.md:10
msgid "Values have dynamic sizes determined at runtime."
msgstr ""
#: src/memory-management/stack-vs-heap.md:11
msgid "Slightly slower than the stack: some book-keeping needed."
msgstr ""
#: src/memory-management/stack-vs-heap.md:12
msgid "No guarantee of memory locality."
msgstr ""
#: src/memory-management/stack.md:1
#, fuzzy
msgid "Stack and Heap Example"
msgstr "Stak og heap"
#: src/memory-management/stack.md:3
msgid ""
"Creating a `String` puts fixed-sized metadata on the stack and dynamically "
"sized data, the actual string, on the heap:"
msgstr ""
#: src/memory-management/stack.md:6
msgid ""
"```rust,editable\n"
"fn main() {\n"
" let s1 = String::from(\"Hello\");\n"
"}\n"
"```"
msgstr ""
#: src/memory-management/stack.md:12
msgid ""
"```bob\n"
" Stack Heap\n"
".- - - - - - - - - - - - - -. .- - - - - - - - - - - - - - - -.\n"
": : : :\n"
": s1 : : :\n"
": +-----------+-------+ : : +----+----+----+----+----+ :\n"
": | ptr | o---+---+-----+-->| H | e | l | l | o | :\n"
": | len | 5 | : : +----+----+----+----+----+ :\n"
": | capacity | 5 | : : :\n"
": +-----------+-------+ : : :\n"
": : `- - - - - - - - - - - - - - - -'\n"
"`- - - - - - - - - - - - - -'\n"
"```"
msgstr ""
"```bob\n"
" Stak Heap\n"
".- - - - - - - - - - - - - -. .- - - - - - - - - - - - - - - -.\n"
": : : :\n"
": s1 : : :\n"
": +-----------+-------+ : : +----+----+----+----+----+ :\n"
": | ptr | o---+---+-----+-->| H | a | l | l | o | :\n"
": | len | 5 | : : +----+----+----+----+----+ :\n"
": | capacity | 5 | : : :\n"
": +-----------+-------+ : : :\n"
": : `- - - - - - - - - - - - - - - -'\n"
"`- - - - - - - - - - - - - -'\n"
"```"
#: src/memory-management/stack.md:28
msgid ""
"Mention that a `String` is backed by a `Vec`, so it has a capacity and "
"length and can grow if mutable via reallocation on the heap."
msgstr ""
#: src/memory-management/stack.md:30
msgid ""
"If students ask about it, you can mention that the underlying memory is heap "
"allocated using the [System Allocator](https://doc.rust-lang.org/std/alloc/"
"struct.System.html) and custom allocators can be implemented using the "
"[Allocator API](https://doc.rust-lang.org/std/alloc/index.html)"
msgstr ""
#: src/memory-management/stack.md:32
msgid ""
"We can inspect the memory layout with `unsafe` code. However, you should "
"point out that this is rightfully unsafe!"
msgstr ""
#: src/memory-management/stack.md:34
msgid ""
"```rust,editable\n"
"fn main() {\n"
" let mut s1 = String::from(\"Hello\");\n"
" s1.push(' ');\n"
" s1.push_str(\"world\");\n"
" // DON'T DO THIS AT HOME! For educational purposes only.\n"
" // String provides no guarantees about its layout, so this could lead "
"to\n"
" // undefined behavior.\n"
" unsafe {\n"
" let (ptr, capacity, len): (usize, usize, usize) = std::mem::"
"transmute(s1);\n"
" println!(\"ptr = {ptr:#x}, len = {len}, capacity = {capacity}\");\n"
" }\n"
"}\n"
"```"
msgstr ""
#: src/memory-management/manual.md:3
msgid "You allocate and deallocate heap memory yourself."
msgstr "Du allokerer og deallokerer din heap-memory."
#: src/memory-management/manual.md:5
msgid ""
"If not done with care, this can lead to crashes, bugs, security "
"vulnerabilities, and memory leaks."
msgstr ""
#: src/memory-management/manual.md:7
msgid "C Example"
msgstr "C-eksempel"
#: src/memory-management/manual.md:9
msgid "You must call `free` on every pointer you allocate with `malloc`:"
msgstr ""
#: src/memory-management/manual.md:11
msgid ""
"```c\n"
"void foo(size_t n) {\n"
" int* int_array = malloc(n * sizeof(int));\n"
" //\n"
" // ... lots of code\n"
" //\n"
" free(int_array);\n"
"}\n"
"```"
msgstr ""
#: src/memory-management/manual.md:21
msgid ""
"Memory is leaked if the function returns early between `malloc` and `free`: "
"the pointer is lost and we cannot deallocate the memory. Worse, freeing the "
"pointer twice, or accessing a freed pointer can lead to exploitable security "
"vulnerabilities."
msgstr ""
#: src/memory-management/scope-based.md:3
msgid ""
"Constructors and destructors let you hook into the lifetime of an object."
msgstr ""
#: src/memory-management/scope-based.md:5
msgid ""
"By wrapping a pointer in an object, you can free memory when the object is "
"destroyed. The compiler guarantees that this happens, even if an exception "
"is raised."
msgstr ""
#: src/memory-management/scope-based.md:9
msgid ""
"This is often called _resource acquisition is initialization_ (RAII) and "
"gives you smart pointers."
msgstr ""
#: src/memory-management/scope-based.md:12
msgid "C++ Example"
msgstr ""
#: src/memory-management/scope-based.md:14
msgid ""
"```c++\n"
"void say_hello(std::unique_ptr person) {\n"
" std::cout << \"Hello \" << person->name << std::endl;\n"
"}\n"
"```"
msgstr ""
#: src/memory-management/scope-based.md:20
msgid ""
"The `std::unique_ptr` object is allocated on the stack, and points to memory "
"allocated on the heap."
msgstr ""
#: src/memory-management/scope-based.md:22
msgid "At the end of `say_hello`, the `std::unique_ptr` destructor will run."
msgstr ""
#: src/memory-management/scope-based.md:23
msgid "The destructor frees the `Person` object it points to."
msgstr ""
#: src/memory-management/scope-based.md:25
msgid ""
"Special move constructors are used when passing ownership to a function:"
msgstr ""
#: src/memory-management/scope-based.md:27
msgid ""
"```c++\n"
"std::unique_ptr person = find_person(\"Carla\");\n"
"say_hello(std::move(person));\n"
"```"
msgstr ""
#: src/memory-management/garbage-collection.md:1
msgid "Automatic Memory Management"
msgstr ""
#: src/memory-management/garbage-collection.md:3
msgid ""
"An alternative to manual and scope-based memory management is automatic "
"memory management:"
msgstr ""
#: src/memory-management/garbage-collection.md:6
msgid "The programmer never allocates or deallocates memory explicitly."
msgstr ""
#: src/memory-management/garbage-collection.md:7
msgid ""
"A garbage collector finds unused memory and deallocates it for the "
"programmer."
msgstr ""
#: src/memory-management/garbage-collection.md:9
msgid "Java Example"
msgstr ""
#: src/memory-management/garbage-collection.md:11
msgid "The `person` object is not deallocated after `sayHello` returns:"
msgstr ""
#: src/memory-management/garbage-collection.md:13
msgid ""
"```java\n"
"void sayHello(Person person) {\n"
" System.out.println(\"Hello \" + person.getName());\n"
"}\n"
"```"
msgstr ""
#: src/memory-management/rust.md:1
msgid "Memory Management in Rust"
msgstr ""
#: src/memory-management/rust.md:3
msgid "Memory management in Rust is a mix:"
msgstr ""
#: src/memory-management/rust.md:5
msgid "Safe and correct like Java, but without a garbage collector."
msgstr ""
#: src/memory-management/rust.md:6
msgid ""
"Depending on which abstraction (or combination of abstractions) you choose, "
"can be a single unique pointer, reference counted, or atomically reference "
"counted."
msgstr ""
#: src/memory-management/rust.md:7
msgid "Scope-based like C++, but the compiler enforces full adherence."
msgstr ""
#: src/memory-management/rust.md:8
msgid ""
"A Rust user can choose the right abstraction for the situation, some even "
"have no cost at runtime like C."
msgstr ""
#: src/memory-management/rust.md:10
msgid "Rust achieves this by modeling _ownership_ explicitly."
msgstr ""
#: src/memory-management/rust.md:14
msgid ""
"If asked how at this point, you can mention that in Rust this is usually "
"handled by RAII wrapper types such as [Box](https://doc.rust-lang.org/std/"
"boxed/struct.Box.html), [Vec](https://doc.rust-lang.org/std/vec/struct.Vec."
"html), [Rc](https://doc.rust-lang.org/std/rc/struct.Rc.html), or [Arc]"
"(https://doc.rust-lang.org/std/sync/struct.Arc.html). These encapsulate "
"ownership and memory allocation via various means, and prevent the potential "
"errors in C."
msgstr ""
#: src/memory-management/rust.md:16
msgid ""
"You may be asked about destructors here, the [Drop](https://doc.rust-lang."
"org/std/ops/trait.Drop.html) trait is the Rust equivalent."
msgstr ""
#: src/memory-management/comparison.md:3
msgid "Here is a rough comparison of the memory management techniques."
msgstr ""
#: src/memory-management/comparison.md:5
msgid "Pros of Different Memory Management Techniques"
msgstr ""
#: src/memory-management/comparison.md:7 src/memory-management/comparison.md:22
msgid "Manual like C:"
msgstr ""
#: src/memory-management/comparison.md:8 src/memory-management/comparison.md:14
#: src/memory-management/comparison.md:17
msgid "No runtime overhead."
msgstr ""
#: src/memory-management/comparison.md:9 src/memory-management/comparison.md:26
msgid "Automatic like Java:"
msgstr ""
#: src/memory-management/comparison.md:10
msgid "Fully automatic."
msgstr ""
#: src/memory-management/comparison.md:11
#: src/memory-management/comparison.md:18
msgid "Safe and correct."
msgstr ""
#: src/memory-management/comparison.md:12
#: src/memory-management/comparison.md:29
msgid "Scope-based like C++:"
msgstr ""
#: src/memory-management/comparison.md:13
msgid "Partially automatic."
msgstr ""
#: src/memory-management/comparison.md:15
msgid "Compiler-enforced scope-based like Rust:"
msgstr ""
#: src/memory-management/comparison.md:16
msgid "Enforced by compiler."
msgstr ""
#: src/memory-management/comparison.md:20
msgid "Cons of Different Memory Management Techniques"
msgstr ""
#: src/memory-management/comparison.md:23
msgid "Use-after-free."
msgstr ""
#: src/memory-management/comparison.md:24
msgid "Double-frees."
msgstr ""
#: src/memory-management/comparison.md:25
msgid "Memory leaks."
msgstr ""
#: src/memory-management/comparison.md:27
msgid "Garbage collection pauses."
msgstr ""
#: src/memory-management/comparison.md:28
msgid "Destructor delays."
msgstr ""
#: src/memory-management/comparison.md:30
msgid "Complex, opt-in by programmer (on C++)."
msgstr ""
#: src/memory-management/comparison.md:31
msgid "Circular references can lead to memory leaks"
msgstr ""
#: src/memory-management/comparison.md:32
msgid "Potential runtime overhead"
msgstr ""
#: src/memory-management/comparison.md:33
msgid "Compiler-enforced and scope-based like Rust:"
msgstr ""
#: src/memory-management/comparison.md:34
msgid "Some upfront complexity."
msgstr ""
#: src/memory-management/comparison.md:35
msgid "Can reject valid programs."
msgstr ""
#: src/ownership.md:3
msgid ""
"All variable bindings have a _scope_ where they are valid and it is an error "
"to use a variable outside its scope:"
msgstr ""
#: src/ownership.md:6
msgid ""
"```rust,editable,compile_fail\n"
"struct Point(i32, i32);\n"
"\n"
"fn main() {\n"
" {\n"
" let p = Point(3, 4);\n"
" println!(\"x: {}\", p.0);\n"
" }\n"
" println!(\"y: {}\", p.1);\n"
"}\n"
"```"
msgstr ""
#: src/ownership.md:18
msgid ""
"At the end of the scope, the variable is _dropped_ and the data is freed."
msgstr ""
#: src/ownership.md:19
msgid "A destructor can run here to free up resources."
msgstr ""
#: src/ownership.md:20
msgid "We say that the variable _owns_ the value."
msgstr ""
#: src/ownership/move-semantics.md:3
msgid "An assignment will transfer _ownership_ between variables:"
msgstr ""
#: src/ownership/move-semantics.md:5
msgid ""
"```rust,editable\n"
"fn main() {\n"
" let s1: String = String::from(\"Hello!\");\n"
" let s2: String = s1;\n"
" println!(\"s2: {s2}\");\n"
" // println!(\"s1: {s1}\");\n"
"}\n"
"```"
msgstr ""
#: src/ownership/move-semantics.md:14
msgid "The assignment of `s1` to `s2` transfers ownership."
msgstr ""
#: src/ownership/move-semantics.md:15
msgid "When `s1` goes out of scope, nothing happens: it does not own anything."
msgstr ""
#: src/ownership/move-semantics.md:16
msgid "When `s2` goes out of scope, the string data is freed."
msgstr ""
#: src/ownership/move-semantics.md:17
msgid "There is always _exactly_ one variable binding which owns a value."
msgstr ""
#: src/ownership/move-semantics.md:21
msgid ""
"Mention that this is the opposite of the defaults in C++, which copies by "
"value unless you use `std::move` (and the move constructor is defined!)."
msgstr ""
#: src/ownership/move-semantics.md:23
msgid ""
"It is only the ownership that moves. Whether any machine code is generated "
"to manipulate the data itself is a matter of optimization, and such copies "
"are aggressively optimized away."
msgstr ""
#: src/ownership/move-semantics.md:25
msgid ""
"Simple values (such as integers) can be marked `Copy` (see later slides)."
msgstr ""
#: src/ownership/move-semantics.md:27
msgid "In Rust, clones are explicit (by using `clone`)."
msgstr ""
#: src/ownership/moved-strings-rust.md:3
msgid ""
"```rust,editable\n"
"fn main() {\n"
" let s1: String = String::from(\"Rust\");\n"
" let s2: String = s1;\n"
"}\n"
"```"
msgstr ""
#: src/ownership/moved-strings-rust.md:10
msgid "The heap data from `s1` is reused for `s2`."
msgstr ""
#: src/ownership/moved-strings-rust.md:11
msgid "When `s1` goes out of scope, nothing happens (it has been moved from)."
msgstr ""
#: src/ownership/moved-strings-rust.md:13
msgid "Before move to `s2`:"
msgstr ""
#: src/ownership/moved-strings-rust.md:15
msgid ""
"```bob\n"
" Stack Heap\n"
".- - - - - - - - - - - - - -. .- - - - - - - - - - - - - -.\n"
": : : :\n"
": s1 : : :\n"
": +-----------+-------+ : : +----+----+----+----+ :\n"
": | ptr | o---+---+-----+-->| R | u | s | t | :\n"
": | len | 4 | : : +----+----+----+----+ :\n"
": | capacity | 4 | : : :\n"
": +-----------+-------+ : : :\n"
": : `- - - - - - - - - - - - - -'\n"
": :\n"
"`- - - - - - - - - - - - - -'\n"
"```"
msgstr ""
#: src/ownership/moved-strings-rust.md:30
msgid "After move to `s2`:"
msgstr ""
#: src/ownership/moved-strings-rust.md:32
msgid ""
"```bob\n"
" Stack Heap\n"
".- - - - - - - - - - - - - -. .- - - - - - - - - - - - - -.\n"
": : : :\n"
": s1 \"(inaccessible)\" : : :\n"
": +-----------+-------+ : : +----+----+----+----+ :\n"
": | ptr | o---+---+--+--+-->| R | u | s | t | :\n"
": | len | 4 | : | : +----+----+----+----+ :\n"
": | capacity | 4 | : | : :\n"
": +-----------+-------+ : | : :\n"
": : | `- - - - - - - - - - - - - -'\n"
": s2 : |\n"
": +-----------+-------+ : |\n"
": | ptr | o---+---+--'\n"
": | len | 4 | :\n"
": | capacity | 4 | :\n"
": +-----------+-------+ :\n"
": :\n"
"`- - - - - - - - - - - - - -'\n"
"```"
msgstr ""
"```bob\n"
" Stak Heap\n"
".- - - - - - - - - - - - - -. .- - - - - - - - - - - - - -.\n"
": : : :\n"
": s1 \"(utilgængelig)\" : : :\n"
": +-----------+-------+ : : +----+----+----+----+ :\n"
": | ptr | o---+---+--+--+-->| R | u | s | t | :\n"
": | len | 4 | : | : +----+----+----+----+ :\n"
": | capacity | 4 | : | : :\n"
": +-----------+-------+ : | : :\n"
": : | `- - - - - - - - - - - - - -'\n"
": s2 : |\n"
": +-----------+-------+ : |\n"
": | ptr | o---+---+--'\n"
": | len | 4 | :\n"
": | capacity | 4 | :\n"
": +-----------+-------+ :\n"
": :\n"
"`- - - - - - - - - - - - - -'\n"
"```"
#: src/ownership/double-free-modern-cpp.md:1
#, fuzzy
msgid "Extra Work in Modern C++"
msgstr "Dobbeltfrigivelser i moderne C++"
#: src/ownership/double-free-modern-cpp.md:3
msgid "Modern C++ solves this differently:"
msgstr ""
#: src/ownership/double-free-modern-cpp.md:5
msgid ""
"```c++\n"
"std::string s1 = \"Cpp\";\n"
"std::string s2 = s1; // Duplicate the data in s1.\n"
"```"
msgstr ""
#: src/ownership/double-free-modern-cpp.md:10
msgid ""
"The heap data from `s1` is duplicated and `s2` gets its own independent copy."
msgstr ""
#: src/ownership/double-free-modern-cpp.md:11
msgid "When `s1` and `s2` go out of scope, they each free their own memory."
msgstr ""
#: src/ownership/double-free-modern-cpp.md:13
msgid "Before copy-assignment:"
msgstr ""
#: src/ownership/double-free-modern-cpp.md:16
msgid ""
"```bob\n"
" Stack Heap\n"
".- - - - - - - - - - - - - -. .- - - - - - - - - - - -.\n"
": : : :\n"
": s1 : : :\n"
": +-----------+-------+ : : +----+----+----+ :\n"
": | ptr | o---+---+--+--+-->| C | p | p | :\n"
": | len | 3 | : : +----+----+----+ :\n"
": | capacity | 3 | : : :\n"
": +-----------+-------+ : : :\n"
": : `- - - - - - - - - - - -'\n"
"`- - - - - - - - - - - - - -'\n"
"```"
msgstr ""
#: src/ownership/double-free-modern-cpp.md:30
msgid "After copy-assignment:"
msgstr ""
#: src/ownership/double-free-modern-cpp.md:32
msgid ""
"```bob\n"
" Stack Heap\n"
".- - - - - - - - - - - - - -. .- - - - - - - - - - - -.\n"
": : : :\n"
": s1 : : :\n"
": +-----------+-------+ : : +----+----+----+ :\n"
": | ptr | o---+---+--+--+-->| C | p | p | :\n"
": | len | 3 | : : +----+----+----+ :\n"
": | capacity | 3 | : : :\n"
": +-----------+-------+ : : :\n"
": : : :\n"
": s2 : : :\n"
": +-----------+-------+ : : +----+----+----+ :\n"
": | ptr | o---+---+-----+-->| C | p | p | :\n"
": | len | 3 | : : +----+----+----+ :\n"
": | capacity | 3 | : : :\n"
": +-----------+-------+ : : :\n"
": : `- - - - - - - - - - - -'\n"
"`- - - - - - - - - - - - - -'\n"
"```"
msgstr ""
"```bob\n"
" Stak Heap\n"
".- - - - - - - - - - - - - -. .- - - - - - - - - - - -.\n"
": : : :\n"
": s1 : : :\n"
": +-----------+-------+ : : +----+----+----+ :\n"
": | ptr | o---+---+--+--+-->| C | p | p | :\n"
": | len | 3 | : : +----+----+----+ :\n"
": | capacity | 3 | : : :\n"
": +-----------+-------+ : : :\n"
": : : :\n"
": s2 : : :\n"
": +-----------+-------+ : : +----+----+----+ :\n"
": | ptr | o---+---+-----+-->| C | p | p | :\n"
": | len | 3 | : : +----+----+----+ :\n"
": | capacity | 3 | : : :\n"
": +-----------+-------+ : : :\n"
": : `- - - - - - - - - - - -'\n"
"`- - - - - - - - - - - - - -'\n"
"```"
#: src/ownership/moves-function-calls.md:3
msgid ""
"When you pass a value to a function, the value is assigned to the function "
"parameter. This transfers ownership:"
msgstr ""
#: src/ownership/moves-function-calls.md:6
msgid ""
"```rust,editable\n"
"fn say_hello(name: String) {\n"
" println!(\"Hello {name}\")\n"
"}\n"
"\n"
"fn main() {\n"
" let name = String::from(\"Alice\");\n"
" say_hello(name);\n"
" // say_hello(name);\n"
"}\n"
"```"
msgstr ""
#: src/ownership/moves-function-calls.md:20
msgid ""
"With the first call to `say_hello`, `main` gives up ownership of `name`. "
"Afterwards, `name` cannot be used anymore within `main`."
msgstr ""
#: src/ownership/moves-function-calls.md:21
msgid ""
"The heap memory allocated for `name` will be freed at the end of the "
"`say_hello` function."
msgstr ""
#: src/ownership/moves-function-calls.md:22
msgid ""
"`main` can retain ownership if it passes `name` as a reference (`&name`) and "
"if `say_hello` accepts a reference as a parameter."
msgstr ""
#: src/ownership/moves-function-calls.md:23
msgid ""
"Alternatively, `main` can pass a clone of `name` in the first call (`name."
"clone()`)."
msgstr ""
#: src/ownership/moves-function-calls.md:24
msgid ""
"Rust makes it harder than C++ to inadvertently create copies by making move "
"semantics the default, and by forcing programmers to make clones explicit."
msgstr ""
#: src/ownership/copy-clone.md:3
msgid ""
"While move semantics are the default, certain types are copied by default:"
msgstr ""
#: src/ownership/copy-clone.md:5
msgid ""
"```rust,editable\n"
"fn main() {\n"
" let x = 42;\n"
" let y = x;\n"
" println!(\"x: {x}\");\n"
" println!(\"y: {y}\");\n"
"}\n"
"```"
msgstr ""
#: src/ownership/copy-clone.md:14
msgid "These types implement the `Copy` trait."
msgstr ""
#: src/ownership/copy-clone.md:16
msgid "You can opt-in your own types to use copy semantics:"
msgstr ""
#: src/ownership/copy-clone.md:18
msgid ""
"```rust,editable\n"
"#[derive(Copy, Clone, Debug)]\n"
"struct Point(i32, i32);\n"
"\n"
"fn main() {\n"
" let p1 = Point(3, 4);\n"
" let p2 = p1;\n"
" println!(\"p1: {p1:?}\");\n"
" println!(\"p2: {p2:?}\");\n"
"}\n"
"```"
msgstr ""
#: src/ownership/copy-clone.md:30
msgid "After the assignment, both `p1` and `p2` own their own data."
msgstr ""
#: src/ownership/copy-clone.md:31
msgid "We can also use `p1.clone()` to explicitly copy the data."
msgstr ""
#: src/ownership/copy-clone.md:35
msgid "Copying and cloning are not the same thing:"
msgstr ""
#: src/ownership/copy-clone.md:37
msgid ""
"Copying refers to bitwise copies of memory regions and does not work on "
"arbitrary objects."
msgstr ""
#: src/ownership/copy-clone.md:38
msgid ""
"Copying does not allow for custom logic (unlike copy constructors in C++)."
msgstr ""
#: src/ownership/copy-clone.md:39
msgid ""
"Cloning is a more general operation and also allows for custom behavior by "
"implementing the `Clone` trait."
msgstr ""
#: src/ownership/copy-clone.md:40
msgid "Copying does not work on types that implement the `Drop` trait."
msgstr ""
#: src/ownership/copy-clone.md:42 src/ownership/lifetimes-function-calls.md:29
msgid "In the above example, try the following:"
msgstr ""
#: src/ownership/copy-clone.md:44
msgid ""
"Add a `String` field to `struct Point`. It will not compile because `String` "
"is not a `Copy` type."
msgstr ""
#: src/ownership/copy-clone.md:45
msgid ""
"Remove `Copy` from the `derive` attribute. The compiler error is now in the "
"`println!` for `p1`."
msgstr ""
#: src/ownership/copy-clone.md:46
msgid "Show that it works if you clone `p1` instead."
msgstr ""
#: src/ownership/copy-clone.md:48
msgid ""
"If students ask about `derive`, it is sufficient to say that this is a way "
"to generate code in Rust at compile time. In this case the default "
"implementations of `Copy` and `Clone` traits are generated."
msgstr ""
#: src/ownership/borrowing.md:3
msgid ""
"Instead of transferring ownership when calling a function, you can let a "
"function _borrow_ the value:"
msgstr ""
#: src/ownership/borrowing.md:6
msgid ""
"```rust,editable\n"
"#[derive(Debug)]\n"
"struct Point(i32, i32);\n"
"\n"
"fn add(p1: &Point, p2: &Point) -> Point {\n"
" Point(p1.0 + p2.0, p1.1 + p2.1)\n"
"}\n"
"\n"
"fn main() {\n"
" let p1 = Point(3, 4);\n"
" let p2 = Point(10, 20);\n"
" let p3 = add(&p1, &p2);\n"
" println!(\"{p1:?} + {p2:?} = {p3:?}\");\n"
"}\n"
"```"
msgstr ""
#: src/ownership/borrowing.md:22
msgid "The `add` function _borrows_ two points and returns a new point."
msgstr ""
#: src/ownership/borrowing.md:23
msgid "The caller retains ownership of the inputs."
msgstr ""
#: src/ownership/borrowing.md:27
msgid "Notes on stack returns:"
msgstr ""
#: src/ownership/borrowing.md:28
msgid ""
"Demonstrate that the return from `add` is cheap because the compiler can "
"eliminate the copy operation. Change the above code to print stack addresses "
"and run it on the [Playground](https://play.rust-lang.org/) or look at the "
"assembly in [Godbolt](https://rust.godbolt.org/). In the \"DEBUG\" "
"optimization level, the addresses should change, while they stay the same "
"when changing to the \"RELEASE\" setting:"
msgstr ""
#: src/ownership/borrowing.md:30
msgid ""
"```rust,editable\n"
"#[derive(Debug)]\n"
"struct Point(i32, i32);\n"
"\n"
"fn add(p1: &Point, p2: &Point) -> Point {\n"
" let p = Point(p1.0 + p2.0, p1.1 + p2.1);\n"
" println!(\"&p.0: {:p}\", &p.0);\n"
" p\n"
"}\n"
"\n"
"pub fn main() {\n"
" let p1 = Point(3, 4);\n"
" let p2 = Point(10, 20);\n"
" let p3 = add(&p1, &p2);\n"
" println!(\"&p3.0: {:p}\", &p3.0);\n"
" println!(\"{p1:?} + {p2:?} = {p3:?}\");\n"
"}\n"
"```"
msgstr ""
#: src/ownership/borrowing.md:48
msgid "The Rust compiler can do return value optimization (RVO)."
msgstr ""
#: src/ownership/borrowing.md:49
msgid ""
"In C++, copy elision has to be defined in the language specification because "
"constructors can have side effects. In Rust, this is not an issue at all. If "
"RVO did not happen, Rust will always perform a simple and efficient `memcpy` "
"copy."
msgstr ""
#: src/ownership/shared-unique-borrows.md:3
msgid "Rust puts constraints on the ways you can borrow values:"
msgstr ""
#: src/ownership/shared-unique-borrows.md:5
msgid "You can have one or more `&T` values at any given time, _or_"
msgstr ""
#: src/ownership/shared-unique-borrows.md:6
msgid "You can have exactly one `&mut T` value."
msgstr ""
#: src/ownership/shared-unique-borrows.md:8
msgid ""
"```rust,editable,compile_fail\n"
"fn main() {\n"
" let mut a: i32 = 10;\n"
" let b: &i32 = &a;\n"
"\n"
" {\n"
" let c: &mut i32 = &mut a;\n"
" *c = 20;\n"
" }\n"
"\n"
" println!(\"a: {a}\");\n"
" println!(\"b: {b}\");\n"
"}\n"
"```"
msgstr ""
#: src/ownership/shared-unique-borrows.md:25
msgid ""
"The above code does not compile because `a` is borrowed as mutable (through "
"`c`) and as immutable (through `b`) at the same time."
msgstr ""
#: src/ownership/shared-unique-borrows.md:26
msgid ""
"Move the `println!` statement for `b` before the scope that introduces `c` "
"to make the code compile."
msgstr ""
#: src/ownership/shared-unique-borrows.md:27
msgid ""
"After that change, the compiler realizes that `b` is only ever used before "
"the new mutable borrow of `a` through `c`. This is a feature of the borrow "
"checker called \"non-lexical lifetimes\"."
msgstr ""
#: src/ownership/lifetimes.md:3
msgid "A borrowed value has a _lifetime_:"
msgstr ""
#: src/ownership/lifetimes.md:5
msgid "The lifetime can be implicit: `add(p1: &Point, p2: &Point) -> Point`."
msgstr ""
#: src/ownership/lifetimes.md:6
msgid "Lifetimes can also be explicit: `&'a Point`, `&'document str`."
msgstr ""
#: src/ownership/lifetimes.md:7 src/ownership/lifetimes-function-calls.md:23
msgid ""
"Read `&'a Point` as \"a borrowed `Point` which is valid for at least the "
"lifetime `a`\"."
msgstr ""
#: src/ownership/lifetimes.md:9
msgid ""
"Lifetimes are always inferred by the compiler: you cannot assign a lifetime "
"yourself."
msgstr ""
#: src/ownership/lifetimes.md:11
msgid ""
"Lifetime annotations create constraints; the compiler verifies that there is "
"a valid solution."
msgstr ""
#: src/ownership/lifetimes.md:13
msgid ""
"Lifetimes for function arguments and return values must be fully specified, "
"but Rust allows lifetimes to be elided in most cases with [a few simple "
"rules](https://doc.rust-lang.org/nomicon/lifetime-elision.html)."
msgstr ""
#: src/ownership/lifetimes-function-calls.md:3
msgid ""
"In addition to borrowing its arguments, a function can return a borrowed "
"value:"
msgstr ""
#: src/ownership/lifetimes-function-calls.md:5
msgid ""
"```rust,editable\n"
"#[derive(Debug)]\n"
"struct Point(i32, i32);\n"
"\n"
"fn left_most<'a>(p1: &'a Point, p2: &'a Point) -> &'a Point {\n"
" if p1.0 < p2.0 { p1 } else { p2 }\n"
"}\n"
"\n"
"fn main() {\n"
" let p1: Point = Point(10, 10);\n"
" let p2: Point = Point(20, 20);\n"
" let p3: &Point = left_most(&p1, &p2);\n"
" println!(\"left-most point: {:?}\", p3);\n"
"}\n"
"```"
msgstr ""
#: src/ownership/lifetimes-function-calls.md:21
msgid "`'a` is a generic parameter, it is inferred by the compiler."
msgstr ""
#: src/ownership/lifetimes-function-calls.md:22
msgid "Lifetimes start with `'` and `'a` is a typical default name."
msgstr ""
#: src/ownership/lifetimes-function-calls.md:25
msgid ""
"The _at least_ part is important when parameters are in different scopes."
msgstr ""
#: src/ownership/lifetimes-function-calls.md:31
msgid ""
"Move the declaration of `p2` and `p3` into a new scope (`{ ... }`), "
"resulting in the following code:"
msgstr ""
#: src/ownership/lifetimes-function-calls.md:32
msgid ""
"```rust,ignore\n"
"#[derive(Debug)]\n"
"struct Point(i32, i32);\n"
"\n"
"fn left_most<'a>(p1: &'a Point, p2: &'a Point) -> &'a Point {\n"
" if p1.0 < p2.0 { p1 } else { p2 }\n"
"}\n"
"\n"
"fn main() {\n"
" let p1: Point = Point(10, 10);\n"
" let p3: &Point;\n"
" {\n"
" let p2: Point = Point(20, 20);\n"
" p3 = left_most(&p1, &p2);\n"
" }\n"
" println!(\"left-most point: {:?}\", p3);\n"
"}\n"
"```"
msgstr ""
#: src/ownership/lifetimes-function-calls.md:50
msgid "Note how this does not compile since `p3` outlives `p2`."
msgstr ""
#: src/ownership/lifetimes-function-calls.md:52
msgid ""
"Reset the workspace and change the function signature to `fn left_most<'a, "
"'b>(p1: &'a Point, p2: &'a Point) -> &'b Point`. This will not compile "
"because the relationship between the lifetimes `'a` and `'b` is unclear."
msgstr ""
#: src/ownership/lifetimes-function-calls.md:53
msgid "Another way to explain it:"
msgstr ""
#: src/ownership/lifetimes-function-calls.md:54
msgid ""
"Two references to two values are borrowed by a function and the function "
"returns another reference."
msgstr ""
#: src/ownership/lifetimes-function-calls.md:56
msgid ""
"It must have come from one of those two inputs (or from a global variable)."
msgstr ""
#: src/ownership/lifetimes-function-calls.md:57
msgid ""
"Which one is it? The compiler needs to know, so at the call site the "
"returned reference is not used for longer than a variable from where the "
"reference came from."
msgstr ""
#: src/ownership/lifetimes-data-structures.md:3
msgid ""
"If a data type stores borrowed data, it must be annotated with a lifetime:"
msgstr ""
#: src/ownership/lifetimes-data-structures.md:5
msgid ""
"```rust,editable\n"
"#[derive(Debug)]\n"
"struct Highlight<'doc>(&'doc str);\n"
"\n"
"fn erase(text: String) {\n"
" println!(\"Bye {text}!\");\n"
"}\n"
"\n"
"fn main() {\n"
" let text = String::from(\"The quick brown fox jumps over the lazy dog."
"\");\n"
" let fox = Highlight(&text[4..19]);\n"
" let dog = Highlight(&text[35..43]);\n"
" // erase(text);\n"
" println!(\"{fox:?}\");\n"
" println!(\"{dog:?}\");\n"
"}\n"
"```"
msgstr ""
#: src/ownership/lifetimes-data-structures.md:25
msgid ""
"In the above example, the annotation on `Highlight` enforces that the data "
"underlying the contained `&str` lives at least as long as any instance of "
"`Highlight` that uses that data."
msgstr ""
#: src/ownership/lifetimes-data-structures.md:26
msgid ""
"If `text` is consumed before the end of the lifetime of `fox` (or `dog`), "
"the borrow checker throws an error."
msgstr ""
#: src/ownership/lifetimes-data-structures.md:27
msgid ""
"Types with borrowed data force users to hold on to the original data. This "
"can be useful for creating lightweight views, but it generally makes them "
"somewhat harder to use."
msgstr ""
#: src/ownership/lifetimes-data-structures.md:28
msgid "When possible, make data structures own their data directly."
msgstr ""
#: src/ownership/lifetimes-data-structures.md:29
msgid ""
"Some structs with multiple references inside can have more than one lifetime "
"annotation. This can be necessary if there is a need to describe lifetime "
"relationships between the references themselves, in addition to the lifetime "
"of the struct itself. Those are very advanced use cases."
msgstr ""
#: src/exercises/day-1/afternoon.md:1
msgid "Day 1: Afternoon Exercises"
msgstr ""
#: src/exercises/day-1/afternoon.md:3
msgid "We will look at two things:"
msgstr ""
#: src/exercises/day-1/afternoon.md:5
msgid "A small book library,"
msgstr ""
#: src/exercises/day-1/afternoon.md:7
msgid "Iterators and ownership (hard)."
msgstr ""
#: src/exercises/day-1/afternoon.md:11 src/exercises/day-2/afternoon.md:7
#: src/exercises/bare-metal/afternoon.md:7
#: src/exercises/concurrency/afternoon.md:13
msgid ""
"After looking at the exercises, you can look at the [solutions](solutions-"
"afternoon.md) provided."
msgstr ""
#: src/exercises/day-1/book-library.md:3
msgid ""
"We will learn much more about structs and the `Vec` type tomorrow. For "
"now, you just need to know part of its API:"
msgstr ""
#: src/exercises/day-1/book-library.md:6
msgid ""
"```rust,editable\n"
"fn main() {\n"
" let mut vec = vec![10, 20];\n"
" vec.push(30);\n"
" let midpoint = vec.len() / 2;\n"
" println!(\"middle value: {}\", vec[midpoint]);\n"
" for item in &vec {\n"
" println!(\"item: {item}\");\n"
" }\n"
"}\n"
"```"
msgstr ""
#: src/exercises/day-1/book-library.md:18
msgid ""
"Use this to model a library's book collection. Copy the code below to "
" and update the types to make it compile:"
msgstr ""
#: src/exercises/day-1/book-library.md:21
msgid ""
"```rust,should_panic\n"
"struct Library {\n"
" books: Vec,\n"
"}\n"
"\n"
"struct Book {\n"
" title: String,\n"
" year: u16,\n"
"}\n"
"\n"
"impl Book {\n"
" // This is a constructor, used below.\n"
" fn new(title: &str, year: u16) -> Book {\n"
" Book {\n"
" title: String::from(title),\n"
" year,\n"
" }\n"
" }\n"
"}\n"
"\n"
"// Implement the methods below. Update the `self` parameter to\n"
"// indicate the method's required level of ownership over the object:\n"
"//\n"
"// - `&self` for shared read-only access,\n"
"// - `&mut self` for unique and mutable access,\n"
"// - `self` for unique access by value.\n"
"impl Library {\n"
" fn new() -> Library {\n"
" todo!(\"Initialize and return a `Library` value\")\n"
" }\n"
"\n"
" //fn len(self) -> usize {\n"
" // todo!(\"Return the length of `self.books`\")\n"
" //}\n"
"\n"
" //fn is_empty(self) -> bool {\n"
" // todo!(\"Return `true` if `self.books` is empty\")\n"
" //}\n"
"\n"
" //fn add_book(self, book: Book) {\n"
" // todo!(\"Add a new book to `self.books`\")\n"
" //}\n"
"\n"
" //fn print_books(self) {\n"
" // todo!(\"Iterate over `self.books` and each book's title and "
"year\")\n"
" //}\n"
"\n"
" //fn oldest_book(self) -> Option<&Book> {\n"
" // todo!(\"Return a reference to the oldest book (if any)\")\n"
" //}\n"
"}\n"
"\n"
"// This shows the desired behavior. Uncomment the code below and\n"
"// implement the missing methods. You will need to update the\n"
"// method signatures, including the \"self\" parameter! You may\n"
"// also need to update the variable bindings within main.\n"
"fn main() {\n"
" let library = Library::new();\n"
"\n"
" //println!(\"The library is empty: library.is_empty() -> {}\", library."
"is_empty());\n"
" //\n"
" //library.add_book(Book::new(\"Lord of the Rings\", 1954));\n"
" //library.add_book(Book::new(\"Alice's Adventures in Wonderland\", "
"1865));\n"
" //\n"
" //println!(\"The library is no longer empty: library.is_empty() -> {}\", "
"library.is_empty());\n"
" //\n"
" //\n"
" //library.print_books();\n"
" //\n"
" //match library.oldest_book() {\n"
" // Some(book) => println!(\"The oldest book is {}\", book.title),\n"
" // None => println!(\"The library is empty!\"),\n"
" //}\n"
" //\n"
" //println!(\"The library has {} books\", library.len());\n"
" //library.print_books();\n"
"}\n"
"```"
msgstr ""
#: src/exercises/day-1/book-library.md:102
msgid "[Solution](solutions-afternoon.md#designing-a-library)"
msgstr ""
#: src/exercises/day-1/iterators-and-ownership.md:3
msgid ""
"The ownership model of Rust affects many APIs. An example of this is the "
"[`Iterator`](https://doc.rust-lang.org/std/iter/trait.Iterator.html) and "
"[`IntoIterator`](https://doc.rust-lang.org/std/iter/trait.IntoIterator.html) "
"traits."
msgstr ""
#: src/exercises/day-1/iterators-and-ownership.md:8 src/bare-metal/no_std.md:28
msgid "`Iterator`"
msgstr "`Iterator`"
#: src/exercises/day-1/iterators-and-ownership.md:10
msgid ""
"Traits are like interfaces: they describe behavior (methods) for a type. The "
"`Iterator` trait simply says that you can call `next` until you get `None` "
"back:"
msgstr ""
#: src/exercises/day-1/iterators-and-ownership.md:13
msgid ""
"```rust\n"
"pub trait Iterator {\n"
" type Item;\n"
" fn next(&mut self) -> Option;\n"
"}\n"
"```"
msgstr ""
#: src/exercises/day-1/iterators-and-ownership.md:20
msgid "You use this trait like this:"
msgstr ""
#: src/exercises/day-1/iterators-and-ownership.md:22
msgid ""
"```rust,editable\n"
"fn main() {\n"
" let v: Vec = vec![10, 20, 30];\n"
" let mut iter = v.iter();\n"
"\n"
" println!(\"v[0]: {:?}\", iter.next());\n"
" println!(\"v[1]: {:?}\", iter.next());\n"
" println!(\"v[2]: {:?}\", iter.next());\n"
" println!(\"No more items: {:?}\", iter.next());\n"
"}\n"
"```"
msgstr ""
#: src/exercises/day-1/iterators-and-ownership.md:34
msgid "What is the type returned by the iterator? Test your answer here:"
msgstr ""
#: src/exercises/day-1/iterators-and-ownership.md:36
msgid ""
"```rust,editable,compile_fail\n"
"fn main() {\n"
" let v: Vec = vec![10, 20, 30];\n"
" let mut iter = v.iter();\n"
"\n"
" let v0: Option<..> = iter.next();\n"
" println!(\"v0: {v0:?}\");\n"
"}\n"
"```"
msgstr ""
#: src/exercises/day-1/iterators-and-ownership.md:46
msgid "Why is this type used?"
msgstr ""
#: src/exercises/day-1/iterators-and-ownership.md:48
msgid "`IntoIterator`"
msgstr "`IntoIterator`"
#: src/exercises/day-1/iterators-and-ownership.md:50
msgid ""
"The `Iterator` trait tells you how to _iterate_ once you have created an "
"iterator. The related trait `IntoIterator` tells you how to create the "
"iterator:"
msgstr ""
#: src/exercises/day-1/iterators-and-ownership.md:53
msgid ""
"```rust\n"
"pub trait IntoIterator {\n"
" type Item;\n"
" type IntoIter: Iterator;\n"
"\n"
" fn into_iter(self) -> Self::IntoIter;\n"
"}\n"
"```"
msgstr ""
#: src/exercises/day-1/iterators-and-ownership.md:62
msgid ""
"The syntax here means that every implementation of `IntoIterator` must "
"declare two types:"
msgstr ""
#: src/exercises/day-1/iterators-and-ownership.md:65
msgid "`Item`: the type we iterate over, such as `i8`,"
msgstr ""
#: src/exercises/day-1/iterators-and-ownership.md:66
msgid "`IntoIter`: the `Iterator` type returned by the `into_iter` method."
msgstr ""
#: src/exercises/day-1/iterators-and-ownership.md:68
msgid ""
"Note that `IntoIter` and `Item` are linked: the iterator must have the same "
"`Item` type, which means that it returns `Option`"
msgstr ""
#: src/exercises/day-1/iterators-and-ownership.md:71
msgid "Like before, what is the type returned by the iterator?"
msgstr ""
#: src/exercises/day-1/iterators-and-ownership.md:73
msgid ""
"```rust,editable,compile_fail\n"
"fn main() {\n"
" let v: Vec = vec![String::from(\"foo\"), String::"
"from(\"bar\")];\n"
" let mut iter = v.into_iter();\n"
"\n"
" let v0: Option<..> = iter.next();\n"
" println!(\"v0: {v0:?}\");\n"
"}\n"
"```"
msgstr ""
#: src/exercises/day-1/iterators-and-ownership.md:83
msgid "`for` Loops"
msgstr "`for`\\-løkker"
#: src/exercises/day-1/iterators-and-ownership.md:85
msgid ""
"Now that we know both `Iterator` and `IntoIterator`, we can build `for` "
"loops. They call `into_iter()` on an expression and iterates over the "
"resulting iterator:"
msgstr ""
#: src/exercises/day-1/iterators-and-ownership.md:89
msgid ""
"```rust,editable\n"
"fn main() {\n"
" let v: Vec = vec![String::from(\"foo\"), String::"
"from(\"bar\")];\n"
"\n"
" for word in &v {\n"
" println!(\"word: {word}\");\n"
" }\n"
"\n"
" for word in v {\n"
" println!(\"word: {word}\");\n"
" }\n"
"}\n"
"```"
msgstr ""
#: src/exercises/day-1/iterators-and-ownership.md:103
msgid "What is the type of `word` in each loop?"
msgstr ""
#: src/exercises/day-1/iterators-and-ownership.md:105
msgid ""
"Experiment with the code above and then consult the documentation for [`impl "
"IntoIterator for &Vec`](https://doc.rust-lang.org/std/vec/struct.Vec."
"html#impl-IntoIterator-for-%26'a+Vec%3CT,+A%3E) and [`impl IntoIterator for "
"Vec`](https://doc.rust-lang.org/std/vec/struct.Vec.html#impl-IntoIterator-"
"for-Vec%3CT,+A%3E) to check your answers."
msgstr ""
#: src/welcome-day-2.md:1
msgid "Welcome to Day 2"
msgstr ""
#: src/welcome-day-2.md:3
msgid "Now that we have seen a fair amount of Rust, we will continue with:"
msgstr ""
#: src/welcome-day-2.md:5
msgid "Structs, enums, methods."
msgstr ""
#: src/welcome-day-2.md:7
msgid "Pattern matching: destructuring enums, structs, and arrays."
msgstr ""
#: src/welcome-day-2.md:9
msgid ""
"Control flow constructs: `if`, `if let`, `while`, `while let`, `break`, and "
"`continue`."
msgstr ""
#: src/welcome-day-2.md:12
msgid ""
"The Standard Library: `String`, `Option` and `Result`, `Vec`, `HashMap`, "
"`Rc` and `Arc`."
msgstr ""
#: src/welcome-day-2.md:15
msgid "Modules: visibility, paths, and filesystem hierarchy."
msgstr ""
#: src/structs.md:3
msgid "Like C and C++, Rust has support for custom structs:"
msgstr ""
#: src/structs.md:5
msgid ""
"```rust,editable\n"
"struct Person {\n"
" name: String,\n"
" age: u8,\n"
"}\n"
"\n"
"fn main() {\n"
" let mut peter = Person {\n"
" name: String::from(\"Peter\"),\n"
" age: 27,\n"
" };\n"
" println!(\"{} is {} years old\", peter.name, peter.age);\n"
" \n"
" peter.age = 28;\n"
" println!(\"{} is {} years old\", peter.name, peter.age);\n"
" \n"
" let jackie = Person {\n"
" name: String::from(\"Jackie\"),\n"
" ..peter\n"
" };\n"
" println!(\"{} is {} years old\", jackie.name, jackie.age);\n"
"}\n"
"```"
msgstr ""
#: src/structs.md:31 src/enums.md:34 src/enums/sizes.md:28 src/methods.md:30
#: src/methods/example.md:46 src/pattern-matching.md:25
#: src/pattern-matching/match-guards.md:22 src/control-flow/blocks.md:43
msgid "Key Points:"
msgstr ""
#: src/structs.md:33
msgid "Structs work like in C or C++."
msgstr ""
#: src/structs.md:34
msgid "Like in C++, and unlike in C, no typedef is needed to define a type."
msgstr ""
#: src/structs.md:35
msgid "Unlike in C++, there is no inheritance between structs."
msgstr ""
#: src/structs.md:36
msgid ""
"Methods are defined in an `impl` block, which we will see in following "
"slides."
msgstr ""
#: src/structs.md:37
msgid ""
"This may be a good time to let people know there are different types of "
"structs. "
msgstr ""
#: src/structs.md:38
msgid ""
"Zero-sized structs `e.g., struct Foo;` might be used when implementing a "
"trait on some type but don’t have any data that you want to store in the "
"value itself. "
msgstr ""
#: src/structs.md:39
msgid ""
"The next slide will introduce Tuple structs, used when the field names are "
"not important."
msgstr ""
#: src/structs.md:40
msgid ""
"The syntax `..peter` allows us to copy the majority of the fields from the "
"old struct without having to explicitly type it all out. It must always be "
"the last element."
msgstr ""
#: src/structs/tuple-structs.md:3
msgid "If the field names are unimportant, you can use a tuple struct:"
msgstr ""
#: src/structs/tuple-structs.md:5
msgid ""
"```rust,editable\n"
"struct Point(i32, i32);\n"
"\n"
"fn main() {\n"
" let p = Point(17, 23);\n"
" println!(\"({}, {})\", p.0, p.1);\n"
"}\n"
"```"
msgstr ""
#: src/structs/tuple-structs.md:14
msgid "This is often used for single-field wrappers (called newtypes):"
msgstr ""
#: src/structs/tuple-structs.md:16
msgid ""
"```rust,editable,compile_fail\n"
"struct PoundsOfForce(f64);\n"
"struct Newtons(f64);\n"
"\n"
"fn compute_thruster_force() -> PoundsOfForce {\n"
" todo!(\"Ask a rocket scientist at NASA\")\n"
"}\n"
"\n"
"fn set_thruster_force(force: Newtons) {\n"
" // ...\n"
"}\n"
"\n"
"fn main() {\n"
" let force = compute_thruster_force();\n"
" set_thruster_force(force);\n"
"}\n"
"\n"
"```"
msgstr ""
#: src/structs/tuple-structs.md:37
msgid ""
"Newtypes are a great way to encode additional information about the value in "
"a primitive type, for example:"
msgstr ""
#: src/structs/tuple-structs.md:38
msgid "The number is measured in some units: `Newtons` in the example above."
msgstr ""
#: src/structs/tuple-structs.md:39
msgid ""
"The value passed some validation when it was created, so you no longer have "
"to validate it again at every use: 'PhoneNumber(String)`or`OddNumber(u32)\\`."
msgstr ""
#: src/structs/tuple-structs.md:40
msgid ""
"Demonstrate how to add a `f64` value to a `Newtons` type by accessing the "
"single field in the newtype."
msgstr ""
#: src/structs/tuple-structs.md:41
msgid ""
"Rust generally doesn’t like inexplicit things, like automatic unwrapping or "
"for instance using booleans as integers."
msgstr ""
#: src/structs/tuple-structs.md:42
msgid "Operator overloading is discussed on Day 3 (generics)."
msgstr ""
#: src/structs/tuple-structs.md:43
msgid ""
"The example is a subtle reference to the [Mars Climate Orbiter](https://en."
"wikipedia.org/wiki/Mars_Climate_Orbiter) failure."
msgstr ""
#: src/structs/field-shorthand.md:3
msgid ""
"If you already have variables with the right names, then you can create the "
"struct using a shorthand:"
msgstr ""
#: src/structs/field-shorthand.md:6
msgid ""
"```rust,editable\n"
"#[derive(Debug)]\n"
"struct Person {\n"
" name: String,\n"
" age: u8,\n"
"}\n"
"\n"
"impl Person {\n"
" fn new(name: String, age: u8) -> Person {\n"
" Person { name, age }\n"
" }\n"
"}\n"
"\n"
"fn main() {\n"
" let peter = Person::new(String::from(\"Peter\"), 27);\n"
" println!(\"{peter:?}\");\n"
"}\n"
"```"
msgstr ""
#: src/structs/field-shorthand.md:27
msgid ""
"The `new` function could be written using `Self` as a type, as it is "
"interchangeable with the struct type name"
msgstr ""
#: src/structs/field-shorthand.md:29
msgid ""
"```rust,editable\n"
"#[derive(Debug)]\n"
"struct Person {\n"
" name: String,\n"
" age: u8,\n"
"}\n"
"impl Person {\n"
" fn new(name: String, age: u8) -> Self {\n"
" Self { name, age }\n"
" }\n"
"}\n"
"```"
msgstr ""
#: src/structs/field-shorthand.md:41
msgid ""
"Implement the `Default` trait for the struct. Define some fields and use the "
"default values for the other fields."
msgstr ""
#: src/structs/field-shorthand.md:43
msgid ""
"```rust,editable\n"
"#[derive(Debug)]\n"
"struct Person {\n"
" name: String,\n"
" age: u8,\n"
"}\n"
"impl Default for Person {\n"
" fn default() -> Person {\n"
" Person {\n"
" name: \"Bot\".to_string(),\n"
" age: 0,\n"
" }\n"
" }\n"
"}\n"
"fn create_default() {\n"
" let tmp = Person {\n"
" ..Person::default()\n"
" };\n"
" let tmp = Person {\n"
" name: \"Sam\".to_string(),\n"
" ..Person::default()\n"
" };\n"
"}\n"
"```"
msgstr ""
#: src/structs/field-shorthand.md:68
msgid "Methods are defined in the `impl` block."
msgstr ""
#: src/structs/field-shorthand.md:69
msgid ""
"Use struct update syntax to define a new structure using `peter`. Note that "
"the variable `peter` will no longer be accessible afterwards."
msgstr ""
#: src/structs/field-shorthand.md:70
msgid ""
"Use `{:#?}` when printing structs to request the `Debug` representation."
msgstr ""
#: src/enums.md:3
msgid ""
"The `enum` keyword allows the creation of a type which has a few different "
"variants:"
msgstr ""
#: src/enums.md:6
msgid ""
"```rust,editable\n"
"fn generate_random_number() -> i32 {\n"
" // Implementation based on https://xkcd.com/221/\n"
" 4 // Chosen by fair dice roll. Guaranteed to be random.\n"
"}\n"
"\n"
"#[derive(Debug)]\n"
"enum CoinFlip {\n"
" Heads,\n"
" Tails,\n"
"}\n"
"\n"
"fn flip_coin() -> CoinFlip {\n"
" let random_number = generate_random_number();\n"
" if random_number % 2 == 0 {\n"
" return CoinFlip::Heads;\n"
" } else {\n"
" return CoinFlip::Tails;\n"
" }\n"
"}\n"
"\n"
"fn main() {\n"
" println!(\"You got: {:?}\", flip_coin());\n"
"}\n"
"```"
msgstr ""
#: src/enums.md:36
msgid "Enumerations allow you to collect a set of values under one type"
msgstr ""
#: src/enums.md:37
msgid ""
"This page offers an enum type `CoinFlip` with two variants `Heads` and "
"`Tails`. You might note the namespace when using variants."
msgstr ""
#: src/enums.md:38
msgid "This might be a good time to compare Structs and Enums:"
msgstr ""
#: src/enums.md:39
msgid ""
"In both, you can have a simple version without fields (unit struct) or one "
"with different types of fields (variant payloads). "
msgstr ""
#: src/enums.md:40
msgid "In both, associated functions are defined within an `impl` block."
msgstr ""
#: src/enums.md:41
msgid ""
"You could even implement the different variants of an enum with separate "
"structs but then they wouldn’t be the same type as they would if they were "
"all defined in an enum. "
msgstr ""
#: src/enums/variant-payloads.md:3
msgid ""
"You can define richer enums where the variants carry data. You can then use "
"the `match` statement to extract the data from each variant:"
msgstr ""
#: src/enums/variant-payloads.md:6
msgid ""
"```rust,editable\n"
"enum WebEvent {\n"
" PageLoad, // Variant without payload\n"
" KeyPress(char), // Tuple struct variant\n"
" Click { x: i64, y: i64 }, // Full struct variant\n"
"}\n"
"\n"
"#[rustfmt::skip]\n"
"fn inspect(event: WebEvent) {\n"
" match event {\n"
" WebEvent::PageLoad => println!(\"page loaded\"),\n"
" WebEvent::KeyPress(c) => println!(\"pressed '{c}'\"),\n"
" WebEvent::Click { x, y } => println!(\"clicked at x={x}, y={y}\"),\n"
" }\n"
"}\n"
"\n"
"fn main() {\n"
" let load = WebEvent::PageLoad;\n"
" let press = WebEvent::KeyPress('x');\n"
" let click = WebEvent::Click { x: 20, y: 80 };\n"
"\n"
" inspect(load);\n"
" inspect(press);\n"
" inspect(click);\n"
"}\n"
"```"
msgstr ""
#: src/enums/variant-payloads.md:35
msgid ""
"The values in the enum variants can only be accessed after being pattern "
"matched. The pattern binds references to the fields in the \"match arm\" "
"after the `=>`."
msgstr ""
#: src/enums/variant-payloads.md:36
msgid ""
"The expression is matched against the patterns from top to bottom. There is "
"no fall-through like in C or C++."
msgstr ""
#: src/enums/variant-payloads.md:37
msgid ""
"The match expression has a value. The value is the last expression in the "
"match arm which was executed."
msgstr ""
#: src/enums/variant-payloads.md:38
msgid ""
"Starting from the top we look for what pattern matches the value then run "
"the code following the arrow. Once we find a match, we stop. "
msgstr ""
#: src/enums/variant-payloads.md:39
msgid ""
"Demonstrate what happens when the search is inexhaustive. Note the advantage "
"the Rust compiler provides by confirming when all cases are handled. "
msgstr ""
#: src/enums/variant-payloads.md:40
msgid "`match` inspects a hidden discriminant field in the `enum`."
msgstr ""
#: src/enums/variant-payloads.md:41
msgid ""
"It is possible to retrieve the discriminant by calling `std::mem::"
"discriminant()`"
msgstr ""
#: src/enums/variant-payloads.md:42
msgid ""
"This is useful, for example, if implementing `PartialEq` for structs where "
"comparing field values doesn't affect equality."
msgstr ""
#: src/enums/variant-payloads.md:43
msgid ""
"`WebEvent::Click { ... }` is not exactly the same as `WebEvent::"
"Click(Click)` with a top level `struct Click { ... }`. The inlined version "
"cannot implement traits, for example."
msgstr ""
#: src/enums/sizes.md:3
msgid ""
"Rust enums are packed tightly, taking constraints due to alignment into "
"account:"
msgstr ""
#: src/enums/sizes.md:5
msgid ""
"```rust,editable\n"
"use std::any::type_name;\n"
"use std::mem::{align_of, size_of};\n"
"\n"
"fn dbg_size() {\n"
" println!(\"{}: size {} bytes, align: {} bytes\",\n"
" type_name::(), size_of::(), align_of::());\n"
"}\n"
"\n"
"enum Foo {\n"
" A,\n"
" B,\n"
"}\n"
"\n"
"fn main() {\n"
" dbg_size::();\n"
"}\n"
"```"
msgstr ""
#: src/enums/sizes.md:24
msgid ""
"See the [Rust Reference](https://doc.rust-lang.org/reference/type-layout."
"html)."
msgstr ""
#: src/enums/sizes.md:30
msgid ""
"Internally Rust is using a field (discriminant) to keep track of the enum "
"variant."
msgstr ""
#: src/enums/sizes.md:32
msgid ""
"You can control the discriminant if needed (e.g., for compatibility with C):"
msgstr ""
#: src/enums/sizes.md:34
msgid ""
"```rust,editable\n"
"#[repr(u32)]\n"
"enum Bar {\n"
" A, // 0\n"
" B = 10000,\n"
" C, // 10001\n"
"}\n"
"\n"
"fn main() {\n"
" println!(\"A: {}\", Bar::A as u32);\n"
" println!(\"B: {}\", Bar::B as u32);\n"
" println!(\"C: {}\", Bar::C as u32);\n"
"}\n"
"```"
msgstr ""
#: src/enums/sizes.md:49
msgid ""
"Without `repr`, the discriminant type takes 2 bytes, because 10001 fits 2 "
"bytes."
msgstr ""
#: src/enums/sizes.md:53
msgid "Try out other types such as"
msgstr ""
#: src/enums/sizes.md:55
msgid "`dbg_size!(bool)`: size 1 bytes, align: 1 bytes,"
msgstr ""
#: src/enums/sizes.md:56
msgid ""
"`dbg_size!(Option)`: size 1 bytes, align: 1 bytes (niche optimization, "
"see below),"
msgstr ""
#: src/enums/sizes.md:57
msgid "`dbg_size!(&i32)`: size 8 bytes, align: 8 bytes (on a 64-bit machine),"
msgstr ""
#: src/enums/sizes.md:58
msgid ""
"`dbg_size!(Option<&i32>)`: size 8 bytes, align: 8 bytes (null pointer "
"optimization, see below)."
msgstr ""
#: src/enums/sizes.md:60
msgid ""
"Niche optimization: Rust will merge unused bit patterns for the enum "
"discriminant."
msgstr ""
#: src/enums/sizes.md:63
msgid ""
"Null pointer optimization: For [some types](https://doc.rust-lang.org/std/"
"option/#representation), Rust guarantees that `size_of::()` equals "
"`size_of::