From 73d1c63d113ed29e371ca55f4f6dd552f74b2341 Mon Sep 17 00:00:00 2001 From: 1dimir <1dimir@users.noreply.github.com> Date: Sun, 7 Apr 2024 10:48:51 +0300 Subject: [PATCH] ru: Update with `messages.pot` as of 2024-04-06 (#1959) * Build `messages.pot` (untracked) using `gettext` with granularity=0; * Update `ru.po` with `msgmerge --update`; * Make it easier to review consequent translation-centric pull requests; #326 --- po/ru.po | 5354 ++++++++++++++++++++++++++++-------------------------- 1 file changed, 2775 insertions(+), 2579 deletions(-) diff --git a/po/ru.po b/po/ru.po index f4409672..dfc3e845 100644 --- a/po/ru.po +++ b/po/ru.po @@ -1,7 +1,7 @@ msgid "" msgstr "" "Project-Id-Version: Comprehensive Rust 🦀\n" -"POT-Creation-Date: 2024-01-24T13:24:49+01:00\n" +"POT-Creation-Date: 2024-04-06T21:02:07+03:00\n" "PO-Revision-Date: 2023-08-25 14:28-0700\n" "Last-Translator: Yauheni Baltukha \n" "Language-Team: \n" @@ -56,7 +56,7 @@ msgstr "День 1: Утро" msgid "Welcome" msgstr "Добро пожаловать" -#: src/SUMMARY.md src/hello-world.md src/hello-world/hello-world.md +#: src/SUMMARY.md src/hello-world.md src/types-and-values/hello-world.md #, fuzzy msgid "Hello, World" msgstr "Привет, мир!" @@ -89,10 +89,6 @@ msgstr "" msgid "Arithmetic" msgstr "" -#: src/SUMMARY.md src/types-and-values/strings.md -msgid "Strings" -msgstr "Строки" - #: src/SUMMARY.md src/types-and-values/inference.md msgid "Type Inference" msgstr "" @@ -108,9 +104,9 @@ msgstr "" #: src/generics/solution.md src/std-types/solution.md #: src/std-traits/solution.md src/memory-management/solution.md #: src/smart-pointers/solution.md src/borrowing/solution.md -#: src/slices-and-lifetimes/solution.md src/iterators/solution.md -#: src/modules/solution.md src/testing/solution.md -#: src/error-handling/solution.md src/unsafe-rust/solution.md +#: src/lifetimes/solution.md src/iterators/solution.md src/modules/solution.md +#: src/testing/solution.md src/error-handling/solution.md +#: src/unsafe-rust/solution.md msgid "Solution" msgstr "" @@ -119,22 +115,39 @@ msgstr "" msgid "Control Flow Basics" msgstr "Поток управления" -#: src/SUMMARY.md src/control-flow-basics/conditionals.md -msgid "Conditionals" -msgstr "" +#: src/SUMMARY.md +#, fuzzy +msgid "`if` Expressions" +msgstr "Выражение `if`" #: src/SUMMARY.md src/control-flow-basics/loops.md msgid "Loops" msgstr "" +#: src/SUMMARY.md src/control-flow-basics/loops/for.md +msgid "`for`" +msgstr "" + +#: src/SUMMARY.md src/control-flow-basics/loops/loop.md +msgid "`loop`" +msgstr "" + #: src/SUMMARY.md src/control-flow-basics/break-continue.md msgid "`break` and `continue`" msgstr "" +#: src/SUMMARY.md src/control-flow-basics/break-continue/labels.md +msgid "Labels" +msgstr "" + #: src/SUMMARY.md src/control-flow-basics/blocks-and-scopes.md msgid "Blocks and Scopes" msgstr "" +#: src/SUMMARY.md src/control-flow-basics/blocks-and-scopes/scopes.md +msgid "Scopes and Shadowing" +msgstr "" + #: src/SUMMARY.md src/control-flow-basics/functions.md msgid "Functions" msgstr "Функции" @@ -152,22 +165,25 @@ msgid "Day 1: Afternoon" msgstr "" #: src/SUMMARY.md src/tuples-and-arrays.md -#: src/tuples-and-arrays/tuples-and-arrays.md msgid "Tuples and Arrays" msgstr "" +#: src/SUMMARY.md src/tuples-and-arrays/arrays.md +msgid "Arrays" +msgstr "Массивы" + +#: src/SUMMARY.md src/tuples-and-arrays/tuples.md +msgid "Tuples" +msgstr "Кортежи" + #: src/SUMMARY.md src/tuples-and-arrays/iteration.md msgid "Array Iteration" msgstr "" -#: src/SUMMARY.md src/tuples-and-arrays/match.md src/pattern-matching.md -msgid "Pattern Matching" -msgstr "" - #: src/SUMMARY.md src/tuples-and-arrays/destructuring.md -#: src/pattern-matching/destructuring.md -msgid "Destructuring" -msgstr "" +#, fuzzy +msgid "Patterns and Destructuring" +msgstr "Перечисления и сопоставление с образцом." #: src/SUMMARY.md src/tuples-and-arrays/exercise.md msgid "Exercise: Nested Arrays" @@ -187,6 +203,15 @@ msgstr "Ссылки" msgid "Exclusive References" msgstr "Висячие ссылки" +#: src/SUMMARY.md +#, fuzzy +msgid "Slices: `&[T]`" +msgstr "Срезы" + +#: src/SUMMARY.md src/references/strings.md +msgid "Strings" +msgstr "Строки" + #: src/SUMMARY.md src/references/exercise.md msgid "Exercise: Geometry" msgstr "" @@ -208,8 +233,12 @@ msgstr "" msgid "Enums" msgstr "" -#: src/SUMMARY.md src/user-defined-types/static-and-const.md -msgid "Static and Const" +#: src/SUMMARY.md +msgid "Static" +msgstr "" + +#: src/SUMMARY.md +msgid "Const" msgstr "" #: src/SUMMARY.md src/user-defined-types/aliases.md @@ -224,6 +253,18 @@ msgstr "" msgid "Day 2: Morning" msgstr "" +#: src/SUMMARY.md src/pattern-matching.md +msgid "Pattern Matching" +msgstr "" + +#: src/SUMMARY.md src/pattern-matching/match.md +msgid "Matching Values" +msgstr "" + +#: src/SUMMARY.md src/pattern-matching/destructuring.md +msgid "Destructuring" +msgstr "" + #: src/SUMMARY.md src/pattern-matching/let-control-flow.md #, fuzzy msgid "Let Control Flow" @@ -245,15 +286,24 @@ msgstr "Методы" msgid "Traits" msgstr "" +#: src/SUMMARY.md src/methods-and-traits/traits/implementing.md +msgid "Implementing Traits" +msgstr "" + +#: src/SUMMARY.md src/methods-and-traits/traits/supertraits.md +msgid "Supertraits" +msgstr "" + +#: src/SUMMARY.md src/methods-and-traits/traits/associated-types.md +#, fuzzy +msgid "Associated Types" +msgstr "Скалярные типы" + #: src/SUMMARY.md src/methods-and-traits/deriving.md msgid "Deriving" msgstr "" -#: src/SUMMARY.md src/methods-and-traits/trait-objects.md -msgid "Trait Objects" -msgstr "" - -#: src/SUMMARY.md src/methods-and-traits/exercise.md +#: src/SUMMARY.md msgid "Exercise: Generic Logger" msgstr "" @@ -270,6 +320,11 @@ msgstr "Функции" msgid "Generic Data Types" msgstr "" +#: src/SUMMARY.md src/generics/generic-traits.md +#, fuzzy +msgid "Generic Traits" +msgstr "Обобщения (generics)." + #: src/SUMMARY.md src/generics/trait-bounds.md msgid "Trait Bounds" msgstr "" @@ -306,7 +361,8 @@ msgstr "" msgid "`Result`" msgstr "" -#: src/SUMMARY.md src/android/interoperability/cpp/type-mapping.md +#: src/SUMMARY.md src/android/aidl/types/primitives.md +#: src/android/interoperability/cpp/type-mapping.md #, fuzzy msgid "`String`" msgstr "Строки" @@ -415,6 +471,10 @@ msgstr "" msgid "`Rc`" msgstr "" +#: src/SUMMARY.md src/smart-pointers/trait-objects.md +msgid "Trait Objects" +msgstr "" + #: src/SUMMARY.md src/smart-pointers/exercise.md msgid "Exercise: Binary Tree" msgstr "" @@ -443,21 +503,11 @@ msgstr "" msgid "Exercise: Health Statistics" msgstr "" -#: src/SUMMARY.md src/slices-and-lifetimes.md -msgid "Slices and Lifetimes" +#: src/SUMMARY.md src/lifetimes.md +msgid "Lifetimes" msgstr "" -#: src/SUMMARY.md -#, fuzzy -msgid "Slices: `&[T]`" -msgstr "Срезы" - -#: src/SUMMARY.md src/slices-and-lifetimes/str.md -#, fuzzy -msgid "String References" -msgstr "Висячие ссылки" - -#: src/SUMMARY.md src/slices-and-lifetimes/lifetime-annotations.md +#: src/SUMMARY.md src/lifetimes/lifetime-annotations.md msgid "Lifetime Annotations" msgstr "" @@ -469,7 +519,7 @@ msgstr "" msgid "Struct Lifetimes" msgstr "" -#: src/SUMMARY.md src/slices-and-lifetimes/exercise.md +#: src/SUMMARY.md src/lifetimes/exercise.md msgid "Exercise: Protobuf Parsing" msgstr "" @@ -530,18 +580,6 @@ msgstr "" msgid "Other Types of Tests" msgstr "" -#: src/SUMMARY.md src/testing/useful-crates.md -msgid "Useful Crates" -msgstr "" - -#: src/SUMMARY.md src/testing/googletest.md -msgid "GoogleTest" -msgstr "" - -#: src/SUMMARY.md src/testing/mocking.md -msgid "Mocking" -msgstr "" - #: src/SUMMARY.md src/testing/lints.md msgid "Compiler Lints and Clippy" msgstr "" @@ -641,19 +679,27 @@ msgstr "" msgid "AIDL" msgstr "" +#: src/SUMMARY.md src/android/aidl/birthday-service.md +msgid "Birthday Service Tutorial" +msgstr "" + #: src/SUMMARY.md msgid "Interface" msgstr "" #: src/SUMMARY.md -msgid "Implementation" +msgid "Service API" +msgstr "" + +#: src/SUMMARY.md +msgid "Service" msgstr "" #: src/SUMMARY.md msgid "Server" msgstr "" -#: src/SUMMARY.md src/android/aidl/deploy.md +#: src/SUMMARY.md src/android/aidl/example-service/deploy.md msgid "Deploy" msgstr "" @@ -661,10 +707,48 @@ msgstr "" msgid "Client" msgstr "" -#: src/SUMMARY.md src/android/aidl/changing.md +#: src/SUMMARY.md src/android/aidl/example-service/changing-definition.md msgid "Changing API" msgstr "" +#: src/SUMMARY.md +msgid "Updating Implementations" +msgstr "" + +#: src/SUMMARY.md +#, fuzzy +msgid "AIDL Types" +msgstr "Типы" + +#: src/SUMMARY.md src/android/aidl/types/primitives.md +msgid "Primitive Types" +msgstr "" + +#: src/SUMMARY.md src/android/aidl/types/arrays.md +#, fuzzy +msgid "Array Types" +msgstr "Массивы" + +#: src/SUMMARY.md src/android/aidl/types/objects.md +msgid "Sending Objects" +msgstr "" + +#: src/SUMMARY.md src/android/aidl/types/parcelables.md +msgid "Parcelables" +msgstr "" + +#: src/SUMMARY.md src/android/aidl/types/file-descriptor.md +msgid "Sending Files" +msgstr "" + +#: src/SUMMARY.md src/android/testing/googletest.md +msgid "GoogleTest" +msgstr "" + +#: src/SUMMARY.md src/android/testing/mocking.md +msgid "Mocking" +msgstr "" + #: src/SUMMARY.md src/android/logging.md src/bare-metal/aps/logging.md msgid "Logging" msgstr "" @@ -996,6 +1080,10 @@ msgstr "" msgid "Exceptions" msgstr "" +#: src/SUMMARY.md +msgid "Useful Crates" +msgstr "" + #: src/SUMMARY.md src/bare-metal/useful-crates/zerocopy.md msgid "`zerocopy`" msgstr "" @@ -1213,6 +1301,10 @@ msgid "" "for updates." msgstr "" +#: src/index.md +msgid "The course is also available [as a PDF](comprehensive-rust.pdf)." +msgstr "" + #: src/index.md msgid "" "The goal of the course is to teach you Rust. We assume you don't know " @@ -1489,7 +1581,7 @@ msgid "Course schedule:" msgstr "Структура курса" #: src/running-the-course/course-structure.md -msgid "Day 1 Morning (3 hours, including breaks)" +msgid "Day 1 Morning (2 hours and 5 minutes, including breaks)" msgstr "" #: src/running-the-course/course-structure.md @@ -1497,35 +1589,38 @@ msgid "[Welcome](../welcome-day-1.md) (5 minutes)" msgstr "" #: src/running-the-course/course-structure.md -msgid "[Hello, World](../hello-world.md) (20 minutes)" +msgid "[Hello, World](../hello-world.md) (15 minutes)" msgstr "" #: src/running-the-course/course-structure.md -msgid "[Types and Values](../types-and-values.md) (1 hour and 5 minutes)" +msgid "[Types and Values](../types-and-values.md) (40 minutes)" msgstr "" #: src/running-the-course/course-structure.md -msgid "[Control Flow Basics](../control-flow-basics.md) (1 hour)" +msgid "[Control Flow Basics](../control-flow-basics.md) (40 minutes)" msgstr "" #: src/running-the-course/course-structure.md -msgid "Day 1 Afternoon (2 hours and 55 minutes, including breaks)" +msgid "Day 1 Afternoon (2 hours and 35 minutes, including breaks)" msgstr "" #: src/running-the-course/course-structure.md -msgid "[Tuples and Arrays](../tuples-and-arrays.md) (1 hour)" +msgid "[Tuples and Arrays](../tuples-and-arrays.md) (35 minutes)" msgstr "" #: src/running-the-course/course-structure.md -msgid "[References](../references.md) (50 minutes)" +#, fuzzy +msgid "[References](../references.md) (55 minutes)" msgstr "" +"Больше информации об использовании шаблонов в языке Rust можно найти на " +"[странице про сопоставление с шаблоном](../pattern-matching.md)." #: src/running-the-course/course-structure.md msgid "[User-Defined Types](../user-defined-types.md) (50 minutes)" msgstr "" #: src/running-the-course/course-structure.md -msgid "Day 2 Morning (3 hours and 5 minutes, including breaks)" +msgid "Day 2 Morning (2 hours and 55 minutes, including breaks)" msgstr "" #: src/running-the-course/course-structure.md @@ -1534,25 +1629,25 @@ msgstr "" #: src/running-the-course/course-structure.md #, fuzzy -msgid "[Pattern Matching](../pattern-matching.md) (50 minutes)" +msgid "[Pattern Matching](../pattern-matching.md) (1 hour)" msgstr "" "Больше информации об использовании шаблонов в языке Rust можно найти на " "[странице про сопоставление с шаблоном](../pattern-matching.md)." #: src/running-the-course/course-structure.md -msgid "[Methods and Traits](../methods-and-traits.md) (55 minutes)" +msgid "[Methods and Traits](../methods-and-traits.md) (50 minutes)" msgstr "" #: src/running-the-course/course-structure.md -msgid "[Generics](../generics.md) (45 minutes)" +msgid "[Generics](../generics.md) (40 minutes)" msgstr "" #: src/running-the-course/course-structure.md -msgid "Day 2 Afternoon (3 hours, including breaks)" +msgid "Day 2 Afternoon (3 hours and 10 minutes, including breaks)" msgstr "" #: src/running-the-course/course-structure.md -msgid "[Standard Library Types](../std-types.md) (1 hour and 10 minutes)" +msgid "[Standard Library Types](../std-types.md) (1 hour and 20 minutes)" msgstr "" #: src/running-the-course/course-structure.md @@ -1560,7 +1655,7 @@ msgid "[Standard Library Traits](../std-traits.md) (1 hour and 40 minutes)" msgstr "" #: src/running-the-course/course-structure.md -msgid "Day 3 Morning (2 hours and 15 minutes, including breaks)" +msgid "Day 3 Morning (2 hours and 20 minutes, including breaks)" msgstr "" #: src/running-the-course/course-structure.md @@ -1568,28 +1663,36 @@ msgid "[Welcome](../welcome-day-3.md) (3 minutes)" msgstr "" #: src/running-the-course/course-structure.md -msgid "[Memory Management](../memory-management.md) (1 hour and 10 minutes)" +msgid "[Memory Management](../memory-management.md) (1 hour)" msgstr "" #: src/running-the-course/course-structure.md -msgid "[Smart Pointers](../smart-pointers.md) (45 minutes)" +#, fuzzy +msgid "[Smart Pointers](../smart-pointers.md) (55 minutes)" +msgstr "" +"Больше информации об использовании шаблонов в языке Rust можно найти на " +"[странице про сопоставление с шаблоном](../pattern-matching.md)." + +#: src/running-the-course/course-structure.md +msgid "Day 3 Afternoon (1 hour and 50 minutes, including breaks)" msgstr "" #: src/running-the-course/course-structure.md -msgid "Day 3 Afternoon (2 hours and 20 minutes, including breaks)" +#, fuzzy +msgid "[Borrowing](../borrowing.md) (50 minutes)" msgstr "" +"Больше информации об использовании шаблонов в языке Rust можно найти на " +"[странице про сопоставление с шаблоном](../pattern-matching.md)." #: src/running-the-course/course-structure.md -msgid "[Borrowing](../borrowing.md) (1 hour)" +#, fuzzy +msgid "[Lifetimes](../lifetimes.md) (50 minutes)" msgstr "" +"Больше информации об использовании шаблонов в языке Rust можно найти на " +"[странице про сопоставление с шаблоном](../pattern-matching.md)." #: src/running-the-course/course-structure.md -msgid "" -"[Slices and Lifetimes](../slices-and-lifetimes.md) (1 hour and 10 minutes)" -msgstr "" - -#: src/running-the-course/course-structure.md -msgid "Day 4 Morning (3 hours and 5 minutes, including breaks)" +msgid "Day 4 Morning (2 hours and 40 minutes, including breaks)" msgstr "" #: src/running-the-course/course-structure.md @@ -1605,16 +1708,22 @@ msgid "[Modules](../modules.md) (40 minutes)" msgstr "" #: src/running-the-course/course-structure.md -msgid "[Testing](../testing.md) (1 hour and 5 minutes)" +#, fuzzy +msgid "[Testing](../testing.md) (45 minutes)" +msgstr "" +"Больше информации об использовании шаблонов в языке Rust можно найти на " +"[странице про сопоставление с шаблоном](../pattern-matching.md)." + +#: src/running-the-course/course-structure.md +msgid "Day 4 Afternoon (2 hours and 10 minutes, including breaks)" msgstr "" #: src/running-the-course/course-structure.md -msgid "Day 4 Afternoon (2 hours, including breaks)" -msgstr "" - -#: src/running-the-course/course-structure.md -msgid "[Error Handling](../error-handling.md) (45 minutes)" +#, fuzzy +msgid "[Error Handling](../error-handling.md) (55 minutes)" msgstr "" +"Больше информации об использовании шаблонов в языке Rust можно найти на " +"[странице про сопоставление с шаблоном](../pattern-matching.md)." #: src/running-the-course/course-structure.md msgid "[Unsafe Rust](../unsafe-rust.md) (1 hour and 5 minutes)" @@ -1836,8 +1945,9 @@ msgstr "" #, fuzzy 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)." +"(https://github.com/keispace), [@jiyongp](https://github.com/jiyongp), " +"[@jooyunghan](https://github.com/jooyunghan), and [@namhyung](https://github." +"com/namhyung)." msgstr "" "[Корейский](https://google.github.io/comprehensive-rust/ko/) от [@keispace]" "(https://github.com/keispace), [@jiyongp](https://github.com/jiyongp) и " @@ -1891,6 +2001,17 @@ msgid "" "momotaro1105)." msgstr "" +#: src/running-the-course/translations.md +#, fuzzy +msgid "" +"[Italian](https://google.github.io/comprehensive-rust/it/) by " +"[@henrythebuilder](https://github.com/henrythebuilder) and [@detro](https://" +"github.com/detro)." +msgstr "" +"[Корейский](https://google.github.io/comprehensive-rust/ko/) от [@keispace]" +"(https://github.com/keispace), [@jiyongp](https://github.com/jiyongp) и " +"[@jooyunghan](https://github.com/jooyunghan)." + #: src/running-the-course/translations.md msgid "" "If you want to help with this effort, please see [our instructions](https://" @@ -2006,10 +2127,9 @@ msgstr "" "одновременно и `rustup` позволит вам переключаться между ними по мере " "необходимости." -#: src/cargo/rust-ecosystem.md src/hello-world/hello-world.md -#: src/tuples-and-arrays/tuples-and-arrays.md src/references/exclusive.md -#: src/pattern-matching/destructuring.md src/memory-management/move.md -#: src/error-handling/try.md src/android/setup.md src/concurrency/threads.md +#: src/cargo/rust-ecosystem.md src/types-and-values/hello-world.md +#: src/references/exclusive.md src/pattern-matching/destructuring.md +#: src/memory-management/move.md src/error-handling/try.md src/android/setup.md #: src/async/async-await.md msgid "Key points:" msgstr "Ключевые моменты:" @@ -2352,19 +2472,21 @@ msgid "[Welcome](./welcome-day-1.md) (5 minutes)" msgstr "" #: src/welcome-day-1.md -msgid "[Hello, World](./hello-world.md) (20 minutes)" +msgid "[Hello, World](./hello-world.md) (15 minutes)" msgstr "" #: src/welcome-day-1.md -msgid "[Types and Values](./types-and-values.md) (1 hour and 5 minutes)" +msgid "[Types and Values](./types-and-values.md) (40 minutes)" msgstr "" #: src/welcome-day-1.md -msgid "[Control Flow Basics](./control-flow-basics.md) (1 hour)" +msgid "[Control Flow Basics](./control-flow-basics.md) (40 minutes)" msgstr "" -#: src/welcome-day-1.md src/welcome-day-2-afternoon.md -msgid "Including 10 minute breaks, this session should take about 3 hours" +#: src/welcome-day-1.md +msgid "" +"Including 10 minute breaks, this session should take about 2 hours and 5 " +"minutes" msgstr "" #: src/welcome-day-1.md @@ -2434,9 +2556,8 @@ msgstr "" #: src/tuples-and-arrays.md src/references.md src/user-defined-types.md #: src/pattern-matching.md src/methods-and-traits.md src/generics.md #: src/std-types.md src/std-traits.md src/memory-management.md -#: src/smart-pointers.md src/borrowing.md src/slices-and-lifetimes.md -#: src/iterators.md src/modules.md src/testing.md src/error-handling.md -#: src/unsafe-rust.md +#: src/smart-pointers.md src/borrowing.md src/lifetimes.md src/iterators.md +#: src/modules.md src/testing.md src/error-handling.md src/unsafe-rust.md msgid "In this segment:" msgstr "" @@ -2444,10 +2565,6 @@ msgstr "" msgid "[What is Rust?](./hello-world/what-is-rust.md) (10 minutes)" msgstr "" -#: src/hello-world.md -msgid "[Hello, World](./hello-world/hello-world.md) (5 minutes)" -msgstr "" - #: src/hello-world.md msgid "[Benefits of Rust](./hello-world/benefits.md) (3 minutes)" msgstr "" @@ -2457,7 +2574,7 @@ msgid "[Playground](./hello-world/playground.md) (2 minutes)" msgstr "" #: src/hello-world.md -msgid "This segment should take about 20 minutes" +msgid "This segment should take about 15 minutes" msgstr "" #: src/hello-world/what-is-rust.md @@ -2547,98 +2664,6 @@ msgid "Focuses on reliability and safety without sacrificing performance." msgstr "" "Ориентирован на надежность и безопасность без ущерба для производительности." -#: src/hello-world/hello-world.md -msgid "" -"Let us jump into the simplest possible Rust program, a classic Hello World " -"program:" -msgstr "" -"Давайте перейдём к самой простой из возможных программ на Rust, классической " -"программе Привет, мир!" - -#: src/hello-world/hello-world.md -msgid "\"Hello 🌍!\"" -msgstr "" - -#: src/hello-world/hello-world.md -msgid "What you see:" -msgstr "Что вы видите:" - -#: src/hello-world/hello-world.md -msgid "Functions are introduced with `fn`." -msgstr "Функции объявляются с помощью `fn`." - -#: src/hello-world/hello-world.md -msgid "Blocks are delimited by curly braces like in C and C++." -msgstr "Блоки разделяются фигурными скобками, как в C и C++." - -#: src/hello-world/hello-world.md -msgid "The `main` function is the entry point of the program." -msgstr "Функция `main` является точкой входа в программу." - -#: src/hello-world/hello-world.md -msgid "Rust has hygienic macros, `println!` is an example of this." -msgstr "В Rust есть макросы, например `println!`." - -#: src/hello-world/hello-world.md -msgid "Rust strings are UTF-8 encoded and can contain any Unicode character." -msgstr "Строки закодированы в UTF-8 и могут содержать любой символ Юникода." - -#: src/hello-world/hello-world.md -#, fuzzy -msgid "" -"This slide tries to make the students comfortable with Rust code. They will " -"see a ton of it over the next four days so we start small with something " -"familiar." -msgstr "" -"На этом слайде мы пытаемся помочь студентам ознакомиться с кодом на Rust. В " -"течение следующих четырёх дней они увидят его в большом количестве, поэтому " -"мы начинаем с чего-то знакомого." - -#: src/hello-world/hello-world.md -#, fuzzy -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 "" -"Rust очень похож на другие языки, такие как C/C++/Java. Rust императивный " -"(не функциональный), и он не пытается что--то изобретать заново без крайней " -"необходимости." - -#: src/hello-world/hello-world.md -msgid "Rust is modern with full support for things like Unicode." -msgstr "" -"Rust --- это современный язык с полной поддержкой таких вещей, как Юникод." - -#: src/hello-world/hello-world.md -#, fuzzy -msgid "" -"Rust uses macros for situations where you want to have a variable number of " -"arguments (no function [overloading](../control-flow-basics/functions.md))." -msgstr "" -"Rust использует макросы для ситуаций, когда вы хотите иметь переменное " -"количество аргументов (без [перегрузки](basic-syntax/functions-interlude.md) " -"функций)." - -#: src/hello-world/hello-world.md -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 "" -"„Гигиеничность“ макросов означает, что они случайно не захватывают " -"идентификаторы из области, в которой они используются. Макросы в Rust на " -"самом деле гигиеничны лишь [частично](https://veykril.github.io/tlborm/decl-" -"macros/minutiae/hygiene.html)." - -#: src/hello-world/hello-world.md -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/benefits.md msgid "Some unique selling points of Rust:" msgstr "Некоторые уникальные преимущества Rust:" @@ -2806,32 +2831,125 @@ msgid "" "assembly." msgstr "" +#: src/types-and-values.md +msgid "[Hello, World](./types-and-values/hello-world.md) (5 minutes)" +msgstr "" + #: src/types-and-values.md msgid "[Variables](./types-and-values/variables.md) (5 minutes)" msgstr "" #: src/types-and-values.md -msgid "[Values](./types-and-values/values.md) (10 minutes)" +msgid "[Values](./types-and-values/values.md) (5 minutes)" msgstr "" #: src/types-and-values.md -msgid "[Arithmetic](./types-and-values/arithmetic.md) (5 minutes)" +msgid "[Arithmetic](./types-and-values/arithmetic.md) (3 minutes)" msgstr "" #: src/types-and-values.md -msgid "[Strings](./types-and-values/strings.md) (10 minutes)" +msgid "[Type Inference](./types-and-values/inference.md) (3 minutes)" msgstr "" #: src/types-and-values.md -msgid "[Type Inference](./types-and-values/inference.md) (5 minutes)" +msgid "[Exercise: Fibonacci](./types-and-values/exercise.md) (15 minutes)" msgstr "" -#: src/types-and-values.md -msgid "[Exercise: Fibonacci](./types-and-values/exercise.md) (30 minutes)" +#: src/types-and-values.md src/control-flow-basics.md src/generics.md +#: src/modules.md +msgid "This segment should take about 40 minutes" msgstr "" -#: src/types-and-values.md src/testing.md src/unsafe-rust.md -msgid "This segment should take about 1 hour and 5 minutes" +#: src/types-and-values/hello-world.md +msgid "" +"Let us jump into the simplest possible Rust program, a classic Hello World " +"program:" +msgstr "" +"Давайте перейдём к самой простой из возможных программ на Rust, классической " +"программе Привет, мир!" + +#: src/types-and-values/hello-world.md +msgid "\"Hello 🌍!\"" +msgstr "" + +#: src/types-and-values/hello-world.md +msgid "What you see:" +msgstr "Что вы видите:" + +#: src/types-and-values/hello-world.md +msgid "Functions are introduced with `fn`." +msgstr "Функции объявляются с помощью `fn`." + +#: src/types-and-values/hello-world.md +msgid "Blocks are delimited by curly braces like in C and C++." +msgstr "Блоки разделяются фигурными скобками, как в C и C++." + +#: src/types-and-values/hello-world.md +msgid "The `main` function is the entry point of the program." +msgstr "Функция `main` является точкой входа в программу." + +#: src/types-and-values/hello-world.md +msgid "Rust has hygienic macros, `println!` is an example of this." +msgstr "В Rust есть макросы, например `println!`." + +#: src/types-and-values/hello-world.md +msgid "Rust strings are UTF-8 encoded and can contain any Unicode character." +msgstr "Строки закодированы в UTF-8 и могут содержать любой символ Юникода." + +#: src/types-and-values/hello-world.md +#, fuzzy +msgid "" +"This slide tries to make the students comfortable with Rust code. They will " +"see a ton of it over the next four days so we start small with something " +"familiar." +msgstr "" +"На этом слайде мы пытаемся помочь студентам ознакомиться с кодом на Rust. В " +"течение следующих четырёх дней они увидят его в большом количестве, поэтому " +"мы начинаем с чего-то знакомого." + +#: src/types-and-values/hello-world.md +#, fuzzy +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 "" +"Rust очень похож на другие языки, такие как C/C++/Java. Rust императивный " +"(не функциональный), и он не пытается что--то изобретать заново без крайней " +"необходимости." + +#: src/types-and-values/hello-world.md +msgid "Rust is modern with full support for things like Unicode." +msgstr "" +"Rust --- это современный язык с полной поддержкой таких вещей, как Юникод." + +#: src/types-and-values/hello-world.md +#, fuzzy +msgid "" +"Rust uses macros for situations where you want to have a variable number of " +"arguments (no function [overloading](../control-flow-basics/functions.md))." +msgstr "" +"Rust использует макросы для ситуаций, когда вы хотите иметь переменное " +"количество аргументов (без [перегрузки](basic-syntax/functions-interlude.md) " +"функций)." + +#: src/types-and-values/hello-world.md +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 "" +"„Гигиеничность“ макросов означает, что они случайно не захватывают " +"идентификаторы из области, в которой они используются. Макросы в Rust на " +"самом деле гигиеничны лишь [частично](https://veykril.github.io/tlborm/decl-" +"macros/minutiae/hygiene.html)." + +#: src/types-and-values/hello-world.md +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/types-and-values/variables.md @@ -2840,16 +2958,17 @@ msgid "" "`let`:" msgstr "" -#: src/types-and-values/variables.md src/control-flow-basics/loops.md -#: src/control-flow-basics/break-continue.md +#: src/types-and-values/variables.md src/control-flow-basics/loops/for.md #: src/control-flow-basics/blocks-and-scopes.md msgid "\"x: {x}\"" msgstr "" #: src/types-and-values/variables.md -msgid "" -"// x = 20;\n" -" // println!(\"x: {x}\");\n" +msgid "// x = 20;" +msgstr "" + +#: src/types-and-values/variables.md +msgid "// println!(\"x: {x}\");" msgstr "" #: src/types-and-values/variables.md @@ -2871,12 +2990,11 @@ msgid "" "each type." msgstr "" -#: src/types-and-values/values.md src/tuples-and-arrays/tuples-and-arrays.md -#: src/unsafe-rust/exercise.md +#: src/types-and-values/values.md src/unsafe-rust/exercise.md msgid "Types" msgstr "Типы" -#: src/types-and-values/values.md src/tuples-and-arrays/tuples-and-arrays.md +#: src/types-and-values/values.md msgid "Literals" msgstr "Литералы" @@ -2923,7 +3041,7 @@ msgstr "`3.14`, `-10.0e20`, `2f32`" msgid "Unicode scalar values" msgstr "Символы Юникода" -#: src/types-and-values/values.md +#: src/types-and-values/values.md src/android/aidl/types/primitives.md msgid "`char`" msgstr "`char`" @@ -2935,7 +3053,7 @@ msgstr "`'a'`, `'α'`, `'∞'`" msgid "Booleans" msgstr "Логические значения" -#: src/types-and-values/values.md +#: src/types-and-values/values.md src/android/aidl/types/primitives.md msgid "`bool`" msgstr "`bool`" @@ -3013,85 +3131,6 @@ msgid "" "why the example requires a separate function." msgstr "" -#: src/types-and-values/strings.md -msgid "" -"Rust has two types to represent strings, both of which will be covered in " -"more depth later. Both _always_ store UTF-8 encoded strings." -msgstr "" - -#: src/types-and-values/strings.md -#, fuzzy -msgid "`String` - a modifiable, owned string." -msgstr "`String` --- изменяемый строковый буфер." - -#: src/types-and-values/strings.md -msgid "`&str` - a read-only string. String literals have this type." -msgstr "" - -#: src/types-and-values/strings.md -msgid "\"Greetings\"" -msgstr "" - -#: src/types-and-values/strings.md -msgid "\"🪐\"" -msgstr "" - -#: src/types-and-values/strings.md -msgid "\", \"" -msgstr "" - -#: src/types-and-values/strings.md -msgid "\"final sentence: {}\"" -msgstr "" - -#: src/types-and-values/strings.md src/async/control-flow/join.md -msgid "\"{:?}\"" -msgstr "" - -#: src/types-and-values/strings.md -msgid "//println!(\"{:?}\", &sentence[12..13]);\n" -msgstr "" - -#: src/types-and-values/strings.md -msgid "" -"This slide introduces strings. Everything here will be covered in more depth " -"later, but this is enough for subsequent slides and exercises to use strings." -msgstr "" - -#: src/types-and-values/strings.md -msgid "Invalid UTF-8 in a string is UB, and this not allowed in safe Rust." -msgstr "" - -#: src/types-and-values/strings.md -msgid "" -"`String` is a user-defined type with a constructor (`::new()`) and methods " -"like `s.push_str(..)`." -msgstr "" - -#: src/types-and-values/strings.md -msgid "" -"The `&` in `&str` indicates that this is a reference. We will cover " -"references later, so for now just think of `&str` as a unit meaning \"a read-" -"only string\"." -msgstr "" - -#: src/types-and-values/strings.md -msgid "" -"The commented-out line is indexing into the string by byte position. " -"`12..13` does not end on a character boundary, so the program panics. Adjust " -"it to a range that does, based on the error message." -msgstr "" - -#: src/types-and-values/strings.md -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 "" -"Сырые строки позволяют создавать значение `&str` с отключенным " -"экранированием: `r\"\\n\" == \"\\\\n\"`. Вы можете поставить двойные " -"кавычки, используя равное количество символов `#` с обеих сторон кавычек:" - #: src/types-and-values/inference.md msgid "Rust will look at how the variable is _used_ to determine the type:" msgstr "" @@ -3119,7 +3158,7 @@ msgid "" msgstr "" #: src/types-and-values/inference.md -msgid "// ERROR: no implementation for `{float} == {integer}`\n" +msgid "// ERROR: no implementation for `{float} == {integer}`" msgstr "" #: src/types-and-values/exercise.md @@ -3136,7 +3175,7 @@ msgid "" msgstr "" #: src/types-and-values/exercise.md -msgid "// The base case.\n" +msgid "// The base case." msgstr "" #: src/types-and-values/exercise.md src/control-flow-basics/exercise.md @@ -3144,15 +3183,15 @@ msgid "\"Implement this\"" msgstr "" #: src/types-and-values/exercise.md -msgid "// The recursive case.\n" +msgid "// The recursive case." msgstr "" #: src/types-and-values/exercise.md src/types-and-values/solution.md -msgid "\"fib(n) = {}\"" +msgid "\"fib({n}) = {}\"" msgstr "" #: src/control-flow-basics.md -msgid "[Conditionals](./control-flow-basics/conditionals.md) (5 minutes)" +msgid "[if Expressions](./control-flow-basics/if.md) (4 minutes)" msgstr "" #: src/control-flow-basics.md @@ -3161,12 +3200,12 @@ msgstr "" #: src/control-flow-basics.md msgid "" -"[break and continue](./control-flow-basics/break-continue.md) (5 minutes)" +"[break and continue](./control-flow-basics/break-continue.md) (4 minutes)" msgstr "" #: src/control-flow-basics.md msgid "" -"[Blocks and Scopes](./control-flow-basics/blocks-and-scopes.md) (10 minutes)" +"[Blocks and Scopes](./control-flow-basics/blocks-and-scopes.md) (5 minutes)" msgstr "" #: src/control-flow-basics.md @@ -3179,45 +3218,14 @@ msgstr "" #: src/control-flow-basics.md msgid "" -"[Exercise: Collatz Sequence](./control-flow-basics/exercise.md) (30 minutes)" +"[Exercise: Collatz Sequence](./control-flow-basics/exercise.md) (15 minutes)" msgstr "" -#: src/control-flow-basics.md src/tuples-and-arrays.md src/borrowing.md -msgid "This segment should take about 1 hour" -msgstr "" - -#: src/control-flow-basics/conditionals.md -msgid "Much of the Rust syntax will be familiar to you from C, C++ or Java:" -msgstr "Большая часть синтаксиса Rust будет знакома вам по C, C++ или Java:" - -#: src/control-flow-basics/conditionals.md -#, fuzzy -msgid "Blocks are delimited by curly braces." -msgstr "Блоки и области видимости разделены фигурными скобками." - -#: src/control-flow-basics/conditionals.md -msgid "" -"Line comments are started with `//`, block comments are delimited by `/* ... " -"*/`." -msgstr "" -"Строковые комментарии начинаются с `//`, блочные комментарии заключены в `/* " -"…*/`." - -#: src/control-flow-basics/conditionals.md -msgid "Keywords like `if` and `while` work the same." -msgstr "Ключевые слова, такие как `if` и `while`, работают так же." - -#: src/control-flow-basics/conditionals.md -msgid "Variable assignment is done with `=`, comparison is done with `==`." -msgstr "" -"Присваивание переменной выполняется с помощью `=`, сравнение выполняется с " -"помощью `==`." - -#: src/control-flow-basics/conditionals.md +#: src/control-flow-basics/if.md msgid "`if` expressions" msgstr "Выражение `if`" -#: src/control-flow-basics/conditionals.md +#: src/control-flow-basics/if.md msgid "" "You use [`if` expressions](https://doc.rust-lang.org/reference/expressions/" "if-expr.html#if-expressions) exactly like `if` statements in other languages:" @@ -3225,19 +3233,19 @@ msgstr "" "[Выражение `if`](https://doc.rust-lang.org/reference/expressions/if-expr." "html#if-expressions) работает так же, как и оператор `if` в других языках:" -#: src/control-flow-basics/conditionals.md -msgid "\"small\"" +#: src/control-flow-basics/if.md +msgid "\"zero!\"" msgstr "" -#: src/control-flow-basics/conditionals.md +#: src/control-flow-basics/if.md msgid "\"biggish\"" msgstr "" -#: src/control-flow-basics/conditionals.md +#: src/control-flow-basics/if.md msgid "\"huge\"" msgstr "" -#: src/control-flow-basics/conditionals.md +#: src/control-flow-basics/if.md msgid "" "In addition, you can use `if` as an expression. The last expression of each " "block becomes the value of the `if` expression:" @@ -3246,15 +3254,19 @@ msgstr "" "внутри одного из блоков (в зависимости от значения условия) становится " "значением всего выражения `if`:" -#: src/control-flow-basics/conditionals.md +#: src/control-flow-basics/if.md +msgid "\"small\"" +msgstr "" + +#: src/control-flow-basics/if.md msgid "\"large\"" msgstr "" -#: src/control-flow-basics/conditionals.md +#: src/control-flow-basics/if.md msgid "\"number size: {}\"" msgstr "" -#: src/control-flow-basics/conditionals.md +#: src/control-flow-basics/if.md #, fuzzy msgid "" "Because `if` is an expression and must have a particular type, both of its " @@ -3264,7 +3276,7 @@ msgstr "" "Обе ветки выражения `if` должны быть одинакового типа. Попробуйте показать, " "что происходит, если добавить `;` после `x / 2` во втором примере." -#: src/control-flow-basics/conditionals.md +#: src/control-flow-basics/if.md msgid "" "When `if` is used in an expression, the expression must have a `;` to " "separate it from the next statement. Remove the `;` before `println!` to see " @@ -3295,39 +3307,43 @@ msgstr "" msgid "\"Final x: {x}\"" msgstr "" -#: src/control-flow-basics/loops.md -msgid "`for`" -msgstr "" - -#: src/control-flow-basics/loops.md +#: src/control-flow-basics/loops/for.md msgid "" "The [`for` loop](https://doc.rust-lang.org/std/keyword.for.html) iterates " -"over ranges of values:" +"over ranges of values or the items in a collection:" msgstr "" -#: src/control-flow-basics/loops.md -msgid "`loop`" +#: src/control-flow-basics/loops/for.md +msgid "\"elem: {elem}\"" msgstr "" -#: src/control-flow-basics/loops.md +#: src/control-flow-basics/loops/for.md +msgid "" +"Under the hood `for` loops use a concept called \"iterators\" to handle " +"iterating over different kinds of ranges/collections. Iterators will be " +"discussed in more detail later." +msgstr "" + +#: src/control-flow-basics/loops/for.md +msgid "" +"Note that the `for` loop only iterates to `4`. Show the `1..=5` syntax for " +"an inclusive range." +msgstr "" + +#: src/control-flow-basics/loops/loop.md msgid "" "The [`loop` statement](https://doc.rust-lang.org/std/keyword.loop.html) just " "loops forever, until a `break`." msgstr "" -#: src/control-flow-basics/loops.md +#: src/control-flow-basics/loops/loop.md msgid "\"{i}\"" msgstr "" -#: src/control-flow-basics/loops.md +#: src/control-flow-basics/break-continue.md msgid "" -"We will discuss iteration later; for now, just stick to range expressions." -msgstr "" - -#: src/control-flow-basics/loops.md -msgid "" -"Note that the `for` loop only iterates to `4`. Show the `1..=5` syntax for " -"an inclusive range." +"If you want to immediately start the next iteration use [`continue`](https://" +"doc.rust-lang.org/reference/expressions/loop-expr.html#continue-expressions)." msgstr "" #: src/control-flow-basics/break-continue.md @@ -3338,32 +3354,26 @@ msgid "" "`loop` expression." msgstr "" -#: src/control-flow-basics/break-continue.md -msgid "" -"If you want to immediately start the next iteration use [`continue`](https://" -"doc.rust-lang.org/reference/expressions/loop-expr.html#continue-expressions)." +#: src/control-flow-basics/break-continue.md src/std-traits/exercise.md +#: src/std-traits/solution.md src/smart-pointers/trait-objects.md +#: src/modules/exercise.md src/modules/solution.md +#: src/android/build-rules/library.md +#: src/android/interoperability/cpp/rust-bridge.md +#: src/async/pitfalls/cancellation.md +msgid "\"{}\"" msgstr "" -#: src/control-flow-basics/break-continue.md -msgid "\"{result}\"" -msgstr "" - -#: src/control-flow-basics/break-continue.md +#: src/control-flow-basics/break-continue/labels.md msgid "" "Both `continue` and `break` can optionally take a label argument which is " "used to break out of nested loops:" msgstr "" -#: src/control-flow-basics/break-continue.md -msgid "\"x: {x}, i: {i}\"" +#: src/control-flow-basics/break-continue/labels.md +msgid "\"elements searched: {elements_searched}\"" msgstr "" -#: src/control-flow-basics/break-continue.md -msgid "" -"In this case we break the outer loop after 3 iterations of the inner loop." -msgstr "" - -#: src/control-flow-basics/break-continue.md +#: src/control-flow-basics/break-continue/labels.md msgid "" "Note that `loop` is the only looping construct which returns a non-trivial " "value. This is because it's guaranteed to be entered at least once (unlike " @@ -3397,41 +3407,6 @@ msgstr "" "Однако, если за последним выражением в блоке следует `;`, то результатом " "такого блока (а также его тип) будет `()`." -#: src/control-flow-basics/blocks-and-scopes.md -msgid "Scopes and Shadowing" -msgstr "" - -#: src/control-flow-basics/blocks-and-scopes.md -msgid "A variable's scope is limited to the enclosing block." -msgstr "" - -#: src/control-flow-basics/blocks-and-scopes.md -msgid "" -"You can shadow variables, both those from outer scopes and variables from " -"the same scope:" -msgstr "" - -#: src/control-flow-basics/blocks-and-scopes.md -msgid "\"before: {a}\"" -msgstr "" - -#: src/control-flow-basics/blocks-and-scopes.md src/std-traits/from-and-into.md -#: src/slices-and-lifetimes/solution.md -msgid "\"hello\"" -msgstr "" - -#: src/control-flow-basics/blocks-and-scopes.md -msgid "\"inner scope: {a}\"" -msgstr "" - -#: src/control-flow-basics/blocks-and-scopes.md -msgid "\"shadowed in inner scope: {a}\"" -msgstr "" - -#: src/control-flow-basics/blocks-and-scopes.md -msgid "\"after: {a}\"" -msgstr "" - #: src/control-flow-basics/blocks-and-scopes.md msgid "" "You can show how the value of the block changes by changing the last line in " @@ -3441,24 +3416,56 @@ msgstr "" "в блоке. Например, можно добавить/убрать точку с запятой или использовать " "`return`." -#: src/control-flow-basics/blocks-and-scopes.md +#: src/control-flow-basics/blocks-and-scopes/scopes.md +msgid "A variable's scope is limited to the enclosing block." +msgstr "" + +#: src/control-flow-basics/blocks-and-scopes/scopes.md +msgid "" +"You can shadow variables, both those from outer scopes and variables from " +"the same scope:" +msgstr "" + +#: src/control-flow-basics/blocks-and-scopes/scopes.md +msgid "\"before: {a}\"" +msgstr "" + +#: src/control-flow-basics/blocks-and-scopes/scopes.md src/generics/exercise.md +#: src/generics/solution.md src/std-traits/from-and-into.md +#: src/lifetimes/solution.md +msgid "\"hello\"" +msgstr "" + +#: src/control-flow-basics/blocks-and-scopes/scopes.md +msgid "\"inner scope: {a}\"" +msgstr "" + +#: src/control-flow-basics/blocks-and-scopes/scopes.md +msgid "\"shadowed in inner scope: {a}\"" +msgstr "" + +#: src/control-flow-basics/blocks-and-scopes/scopes.md +msgid "\"after: {a}\"" +msgstr "" + +#: src/control-flow-basics/blocks-and-scopes/scopes.md msgid "" "Show that a variable's scope is limited by adding a `b` in the inner block " "in the last example, and then trying to access it outside that block." msgstr "" -#: src/control-flow-basics/blocks-and-scopes.md +#: src/control-flow-basics/blocks-and-scopes/scopes.md msgid "" "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/control-flow-basics/blocks-and-scopes.md +#: src/control-flow-basics/blocks-and-scopes/scopes.md msgid "A shadowing variable can have a different type." msgstr "" -#: src/control-flow-basics/blocks-and-scopes.md +#: src/control-flow-basics/blocks-and-scopes/scopes.md msgid "" "Shadowing looks obscure at first, but is convenient for holding on to values " "after `.unwrap()`." @@ -3737,12 +3744,15 @@ msgid "Welcome Back" msgstr "Добро пожаловать" #: src/welcome-day-1-afternoon.md -msgid "[Tuples and Arrays](./tuples-and-arrays.md) (1 hour)" +msgid "[Tuples and Arrays](./tuples-and-arrays.md) (35 minutes)" msgstr "" #: src/welcome-day-1-afternoon.md -msgid "[References](./references.md) (50 minutes)" +#, fuzzy +msgid "[References](./references.md) (55 minutes)" msgstr "" +"Больше информации об использовании шаблонов в языке Rust можно найти на " +"[странице про сопоставление с шаблоном](../pattern-matching.md)." #: src/welcome-day-1-afternoon.md msgid "[User-Defined Types](./user-defined-types.md) (50 minutes)" @@ -3750,13 +3760,16 @@ msgstr "" #: src/welcome-day-1-afternoon.md msgid "" -"Including 10 minute breaks, this session should take about 2 hours and 55 " +"Including 10 minute breaks, this session should take about 2 hours and 35 " "minutes" msgstr "" #: src/tuples-and-arrays.md -msgid "" -"[Tuples and Arrays](./tuples-and-arrays/tuples-and-arrays.md) (10 minutes)" +msgid "[Arrays](./tuples-and-arrays/arrays.md) (5 minutes)" +msgstr "" + +#: src/tuples-and-arrays.md +msgid "[Tuples](./tuples-and-arrays/tuples.md) (5 minutes)" msgstr "" #: src/tuples-and-arrays.md @@ -3764,63 +3777,23 @@ msgid "[Array Iteration](./tuples-and-arrays/iteration.md) (3 minutes)" msgstr "" #: src/tuples-and-arrays.md -msgid "[Pattern Matching](./tuples-and-arrays/match.md) (10 minutes)" -msgstr "" - -#: src/tuples-and-arrays.md -msgid "[Destructuring](./tuples-and-arrays/destructuring.md) (5 minutes)" -msgstr "" - -#: src/tuples-and-arrays.md -msgid "[Exercise: Nested Arrays](./tuples-and-arrays/exercise.md) (30 minutes)" -msgstr "" - -#: src/tuples-and-arrays/tuples-and-arrays.md +#, fuzzy msgid "" -"Tuples and arrays are the first \"compound\" types we have seen. All " -"elements of an array have the same type, while tuples can accommodate " -"different types. Both types have a size fixed at compile time." +"[Patterns and Destructuring](./tuples-and-arrays/destructuring.md) (5 " +"minutes)" +msgstr "" +"Больше информации об использовании шаблонов в языке Rust можно найти на " +"[странице про сопоставление с шаблоном](../pattern-matching.md)." + +#: src/tuples-and-arrays.md +msgid "[Exercise: Nested Arrays](./tuples-and-arrays/exercise.md) (15 minutes)" msgstr "" -#: src/tuples-and-arrays/tuples-and-arrays.md -#: src/tuples-and-arrays/destructuring.md -msgid "Arrays" -msgstr "Массивы" +#: src/tuples-and-arrays.md +msgid "This segment should take about 35 minutes" +msgstr "" -#: src/tuples-and-arrays/tuples-and-arrays.md -msgid "`[T; N]`" -msgstr "`[T; N]`" - -#: src/tuples-and-arrays/tuples-and-arrays.md -msgid "`[20, 30, 40]`, `[0; 3]`" -msgstr "`[20, 30, 40]`, `[0; 3]`" - -#: src/tuples-and-arrays/tuples-and-arrays.md -#: src/tuples-and-arrays/destructuring.md -msgid "Tuples" -msgstr "Кортежи" - -#: src/tuples-and-arrays/tuples-and-arrays.md -msgid "`()`, `(T,)`, `(T1, T2)`, ..." -msgstr "`()`, `(T,)`, `(T1, T2)`, ..." - -#: src/tuples-and-arrays/tuples-and-arrays.md -msgid "`()`, `('x',)`, `('x', 1.2)`, ..." -msgstr "`()`, `('x',)`, `('x', 1.2)`, ..." - -#: src/tuples-and-arrays/tuples-and-arrays.md -msgid "Array assignment and access:" -msgstr "Объявление массива и доступ к нему:" - -#: src/tuples-and-arrays/tuples-and-arrays.md -msgid "Tuple assignment and access:" -msgstr "Объявление кортежа и доступ к нему:" - -#: src/tuples-and-arrays/tuples-and-arrays.md -msgid "Arrays:" -msgstr "Массивы:" - -#: src/tuples-and-arrays/tuples-and-arrays.md +#: src/tuples-and-arrays/arrays.md #, fuzzy msgid "" "A value of the array type `[T; N]` holds `N` (a compile-time constant) " @@ -3834,18 +3807,18 @@ msgstr "" "является _частью его типа_, это значит, что `[u8; 3]` и `[u8; 4]` являются " "двумя разными типами." -#: src/tuples-and-arrays/tuples-and-arrays.md +#: src/tuples-and-arrays/arrays.md msgid "" "Try accessing an out-of-bounds array element. Array accesses are checked at " "runtime. Rust can usually optimize these checks away, and they can be " "avoided using unsafe Rust." msgstr "" -#: src/tuples-and-arrays/tuples-and-arrays.md +#: src/tuples-and-arrays/arrays.md msgid "We can use literals to assign values to arrays." msgstr "Мы можем использовать литералы для присваивания значений массивам." -#: src/tuples-and-arrays/tuples-and-arrays.md +#: src/tuples-and-arrays/arrays.md #, fuzzy msgid "" "The `println!` macro asks for the debug implementation with the `?` format " @@ -3859,7 +3832,7 @@ msgstr "" "выдает отладочное представление. Мы также могли бы использовать `{a}` и " "`{a:?}` без указания значений после строки формата." -#: src/tuples-and-arrays/tuples-and-arrays.md +#: src/tuples-and-arrays/arrays.md msgid "" "Adding `#`, eg `{a:#?}`, invokes a \"pretty printing\" format, which can be " "easier to read." @@ -3867,19 +3840,15 @@ msgstr "" "Добавление `#`, например `{a:#?}`, позволяет использовать формат ”красивой " "печати”, который может облегчить чтение." -#: src/tuples-and-arrays/tuples-and-arrays.md -msgid "Tuples:" -msgstr "Кортежи:" - -#: src/tuples-and-arrays/tuples-and-arrays.md +#: src/tuples-and-arrays/tuples.md msgid "Like arrays, tuples have a fixed length." msgstr "Как и массивы, кортежи имеют фиксированную длину." -#: src/tuples-and-arrays/tuples-and-arrays.md +#: src/tuples-and-arrays/tuples.md msgid "Tuples group together values of different types into a compound type." msgstr "Кортежи группируют значения разных типов в составной тип." -#: src/tuples-and-arrays/tuples-and-arrays.md +#: src/tuples-and-arrays/tuples.md msgid "" "Fields of a tuple can be accessed by the period and the index of the value, " "e.g. `t.0`, `t.1`." @@ -3887,28 +3856,11 @@ msgstr "" "Доступ к полям кортежа можно получить используя точку и индекс значения, " "например `t.0`, `t.1`." -#: src/tuples-and-arrays/tuples-and-arrays.md -#, fuzzy +#: src/tuples-and-arrays/tuples.md 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." +"The empty tuple `()` is referred to as the \"unit type\" and signifies " +"absence of a return value, akin to `void` in other languages." msgstr "" -"Пустой кортеж `()` также известен как ”единичный тип”. Это одновременно и " -"тип, и единственное допустимое значение этого типа --- и тип, и его значение " -"выражаются как `()`. Он используется, например, для указания того, что " -"функция или выражение не имеет возвращаемого значения, как мы увидим на " -"следующем слайде." - -#: src/tuples-and-arrays/tuples-and-arrays.md -#, fuzzy -msgid "" -"You can think of it as `void` that can be familiar to you from other " -"programming languages." -msgstr "" -"Вы можете думать о нем как о `void`, который может быть знаком вам по другим " -"языкам программирования." #: src/tuples-and-arrays/iteration.md msgid "The `for` statement supports iterating over arrays (but not tuples)." @@ -3927,206 +3879,47 @@ msgid "" "`debug_assert!` compile to nothing in release builds." msgstr "" -#: src/tuples-and-arrays/match.md +#: src/tuples-and-arrays/destructuring.md msgid "" -"The `match` keyword lets you match a value against one or more _patterns_. " -"The comparisons are done from top to bottom and the first match wins." +"When working with tuples and other structured values it's common to want to " +"extract the inner values into local variables. This can be done manually by " +"directly accessing the inner values:" msgstr "" -#: src/tuples-and-arrays/match.md -msgid "The patterns can be simple values, similarly to `switch` in C and C++:" -msgstr "" - -#: src/tuples-and-arrays/match.md -msgid "'x'" -msgstr "" - -#: src/tuples-and-arrays/match.md -msgid "'q'" -msgstr "" - -#: src/tuples-and-arrays/match.md -msgid "\"Quitting\"" -msgstr "" - -#: src/tuples-and-arrays/match.md src/std-traits/solution.md -#: src/error-handling/exercise.md src/error-handling/solution.md -msgid "'a'" -msgstr "" - -#: src/tuples-and-arrays/match.md -msgid "'s'" -msgstr "" - -#: src/tuples-and-arrays/match.md -msgid "'w'" -msgstr "" - -#: src/tuples-and-arrays/match.md -msgid "'d'" -msgstr "" - -#: src/tuples-and-arrays/match.md -msgid "\"Moving around\"" -msgstr "" - -#: src/tuples-and-arrays/match.md src/error-handling/exercise.md -#: src/error-handling/solution.md -msgid "'0'" -msgstr "" - -#: src/tuples-and-arrays/match.md src/error-handling/exercise.md -#: src/error-handling/solution.md -msgid "'9'" -msgstr "" - -#: src/tuples-and-arrays/match.md -msgid "\"Number input\"" -msgstr "" - -#: src/tuples-and-arrays/match.md -msgid "\"Lowercase: {key}\"" -msgstr "" - -#: src/tuples-and-arrays/match.md -msgid "\"Something else\"" -msgstr "" - -#: src/tuples-and-arrays/match.md -msgid "" -"The `_` pattern is a wildcard pattern which matches any value. The " -"expressions _must_ be irrefutable, meaning that it covers every possibility, " -"so `_` is often used as the final catch-all case." -msgstr "" - -#: src/tuples-and-arrays/match.md -msgid "" -"Match can be used as an expression. Just like `if`, each match arm must have " -"the same type. The type is the last expression of the block, if any. In the " -"example above, the type is `()`." -msgstr "" - -#: src/tuples-and-arrays/match.md -msgid "" -"A variable in the pattern (`key` in this example) will create a binding that " -"can be used within the match arm." -msgstr "" - -#: src/tuples-and-arrays/match.md -msgid "A match guard causes the arm to match only if the condition is true." -msgstr "" - -#: src/tuples-and-arrays/match.md src/user-defined-types/named-structs.md -#: src/user-defined-types/enums.md src/methods-and-traits/methods.md -msgid "Key Points:" -msgstr "" - -#: src/tuples-and-arrays/match.md -msgid "" -"You might point out how some specific characters are being used when in a " -"pattern" -msgstr "" - -#: src/tuples-and-arrays/match.md -msgid "`|` as an `or`" -msgstr "" - -#: src/tuples-and-arrays/match.md -msgid "`..` can expand as much as it needs to be" -msgstr "" - -#: src/tuples-and-arrays/match.md -msgid "`1..=5` represents an inclusive range" -msgstr "" - -#: src/tuples-and-arrays/match.md -msgid "`_` is a wild card" -msgstr "" - -#: src/tuples-and-arrays/match.md -msgid "" -"Match guards as a separate syntax feature are important and necessary when " -"we wish to concisely express more complex ideas than patterns alone would " -"allow." -msgstr "" - -#: src/tuples-and-arrays/match.md -msgid "" -"They are not the same as separate `if` expression inside of the match arm. " -"An `if` expression inside of the branch block (after `=>`) happens after the " -"match arm is selected. Failing the `if` condition inside of that block won't " -"result in other arms of the original `match` expression being considered." -msgstr "" - -#: src/tuples-and-arrays/match.md -msgid "" -"The condition defined in the guard applies to every expression in a pattern " -"with an `|`." +#: src/tuples-and-arrays/destructuring.md +msgid "\"left: {left}, right: {right}\"" msgstr "" #: src/tuples-and-arrays/destructuring.md msgid "" -"Destructuring is a way of extracting data from a data structure by writing a " -"pattern that is matched up to the data structure, binding variables to " -"subcomponents of the data structure." -msgstr "" - -#: src/tuples-and-arrays/destructuring.md -msgid "You can destructure tuples and arrays by matching on their elements:" -msgstr "" - -#: src/tuples-and-arrays/destructuring.md -msgid "\"on Y axis\"" -msgstr "" - -#: src/tuples-and-arrays/destructuring.md -msgid "\"on X axis\"" -msgstr "" - -#: src/tuples-and-arrays/destructuring.md -msgid "\"left of Y axis\"" -msgstr "" - -#: src/tuples-and-arrays/destructuring.md -msgid "\"below X axis\"" -msgstr "" - -#: src/tuples-and-arrays/destructuring.md -msgid "\"first quadrant\"" -msgstr "" - -#: src/tuples-and-arrays/destructuring.md -msgid "\"Tell me about {triple:?}\"" -msgstr "" - -#: src/tuples-and-arrays/destructuring.md -msgid "\"First is 0, y = {y}, and z = {z}\"" -msgstr "" - -#: src/tuples-and-arrays/destructuring.md -msgid "\"First is 1 and the rest were ignored\"" -msgstr "" - -#: src/tuples-and-arrays/destructuring.md -msgid "\"All elements were ignored\"" -msgstr "" - -#: src/tuples-and-arrays/destructuring.md -msgid "Create a new array pattern using `_` to represent an element." -msgstr "" - -#: src/tuples-and-arrays/destructuring.md -msgid "Add more values to the array." +"However, Rust also supports using pattern matching to destructure a larger " +"value into its constituent parts:" msgstr "" #: src/tuples-and-arrays/destructuring.md msgid "" -"Point out that how `..` will expand to account for different number of " -"elements." +"The patterns used here are \"irrefutable\", meaning that the compiler can " +"statically verify that the value on the right of `=` has the same structure " +"as the pattern." msgstr "" #: src/tuples-and-arrays/destructuring.md -msgid "Show matching against the tail with patterns `[.., b]` and `[a@..,b]`" +msgid "" +"A variable name is an irrefutable pattern that always matches any value, " +"hence why we can also use `let` to declare a single variable." +msgstr "" + +#: src/tuples-and-arrays/destructuring.md +msgid "" +"Rust also supports using patterns in conditionals, allowing for equality " +"comparison and destructuring to happen at the same time. This form of " +"pattern matching will be discussed in more detail later." +msgstr "" + +#: src/tuples-and-arrays/destructuring.md +msgid "" +"Edit the examples above to show the compiler error when the pattern doesn't " +"match the value being matched on." msgstr "" #: src/tuples-and-arrays/exercise.md @@ -4163,7 +3956,11 @@ msgstr "" #: src/tuples-and-arrays/exercise.md src/borrowing/exercise.md #: src/unsafe-rust/exercise.md -msgid "// TODO: remove this when you're done with your implementation.\n" +msgid "// TODO: remove this when you're done with your implementation." +msgstr "" + +#: src/tuples-and-arrays/exercise.md src/tuples-and-arrays/solution.md +msgid "//\n" msgstr "" #: src/tuples-and-arrays/exercise.md src/tuples-and-arrays/solution.md @@ -4178,10 +3975,6 @@ msgstr "" msgid "\"transposed: {:#?}\"" msgstr "" -#: src/tuples-and-arrays/solution.md -msgid "//\n" -msgstr "" - #: src/references.md msgid "[Shared References](./references/shared.md) (10 minutes)" msgstr "" @@ -4191,11 +3984,22 @@ msgid "[Exclusive References](./references/exclusive.md) (10 minutes)" msgstr "" #: src/references.md -msgid "[Exercise: Geometry](./references/exercise.md) (30 minutes)" +msgid "[Slices: &\\[T\\]](./references/slices.md) (10 minutes)" msgstr "" -#: src/references.md src/user-defined-types.md src/pattern-matching.md -msgid "This segment should take about 50 minutes" +#: src/references.md +#, fuzzy +msgid "[Strings](./references/strings.md) (10 minutes)" +msgstr "" +"Больше информации об использовании шаблонов в языке Rust можно найти на " +"[странице про сопоставление с шаблоном](../pattern-matching.md)." + +#: src/references.md +msgid "[Exercise: Geometry](./references/exercise.md) (15 minutes)" +msgstr "" + +#: src/references.md src/smart-pointers.md src/error-handling.md +msgid "This segment should take about 55 minutes" msgstr "" #: src/references/shared.md @@ -4243,8 +4047,8 @@ msgstr "" #, fuzzy msgid "" "Rust will auto-dereference in some cases, in particular when invoking " -"methods (try `r.count_ones()`). There is no need for an `->` operator like " -"in C++." +"methods (try `r.is_ascii()`). There is no need for an `->` operator like in " +"C++." msgstr "" "В некоторых случаях Rust будет автоматически разыменовывать ссылки, в " "частности, при вызове методов (попробуйте `ref_x.count_ones()`)." @@ -4303,6 +4107,199 @@ msgstr "" "привязана к разным значениям, в то время как вторая --- ссылку на изменяемое " "значение." +#: src/references/slices.md +msgid "Slices" +msgstr "Срезы" + +#: src/references/slices.md +msgid "A slice gives you a view into a larger collection:" +msgstr "" +"Срезы позволяют ссылаться на непрерывную последовательность элементов в " +"коллекции:" + +#: src/references/slices.md +msgid "Slices borrow data from the sliced type." +msgstr "Срезы заимствуют данные у коллекции." + +#: src/references/slices.md +#, fuzzy +msgid "Question: What happens if you modify `a[3]` right before printing `s`?" +msgstr "Вопрос: Что произойдет, если вы измените значение в `a[3]`?" + +#: src/references/slices.md +msgid "" +"We create a slice by borrowing `a` and specifying the starting and ending " +"indexes in brackets." +msgstr "" +"Мы создаем срез, заимствуя `a` и указывая начальный и конечный индексы в " +"скобках." + +#: src/references/slices.md +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 "" +"Если срез начинается с индекса 0, синтаксис Rust позволяет отбросить " +"начальный индекс, таким образом, `&a[0..a.len()]` и `&a[..a.len()]` " +"идентичны ." + +#: src/references/slices.md +msgid "" +"The same is true for the last index, so `&a[2..a.len()]` and `&a[2..]` are " +"identical." +msgstr "" +"То же верно и для последнего индекса, поэтому `&a[2..a.len()]` и `&a[2..]` " +"идентичны." + +#: src/references/slices.md +msgid "" +"To easily create a slice of the full array, we can therefore use `&a[..]`." +msgstr "Чтобы создать срез всего массива, можно использовать `&a[..]`." + +#: src/references/slices.md +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 "" +"`s` --- это ссылка на срез элементов типа `i32`. Обратите внимание, что тип " +"`s` (`&[i32]`) больше не указывает длину массива. Это позволяет выполнять " +"вычисления на срезах разных размеров." + +#: src/references/slices.md +#, fuzzy +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 "" +"Срезы всегда заимствуют у другого объекта. В этом примере `a` должен " +"оставаться ‘живым’ (в области видимости) по крайней мере столько же, сколько " +"и срез." + +#: src/references/slices.md +#, fuzzy +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." +msgstr "" +"Вопрос об изменении `a[3]` может породить интересную дискуссию, но ответ " +"заключается в том, что по соображениям безопасности памяти вы не можете " +"сделать это через `a` после создания среза, но можете безопасно читать " +"данные как из `a`, так и из `s`. Более подробная информация будет изложена в " +"разделе анализатора заимствований." + +#: src/references/strings.md +msgid "We can now understand the two string types in Rust:" +msgstr "Теперь давайте разберемся с двумя типами строк в Rust:" + +#: src/references/strings.md +msgid "`&str` is a slice of UTF-8 encoded bytes, similar to `&[u8]`." +msgstr "" + +#: src/references/strings.md +msgid "`String` is an owned, heap-allocated buffer of UTF-8 bytes." +msgstr "" + +#: src/references/strings.md src/std-traits/read-and-write.md +msgid "\"World\"" +msgstr "" + +#: src/references/strings.md +msgid "\"s1: {s1}\"" +msgstr "" + +#: src/references/strings.md +#, fuzzy +msgid "\"Hello \"" +msgstr "Привет, мир!" + +#: src/references/strings.md src/memory-management/move.md +msgid "\"s2: {s2}\"" +msgstr "" + +#: src/references/strings.md +msgid "\"s3: {s3}\"" +msgstr "" + +#: src/references/strings.md +#, fuzzy +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 "" +"`&str` представляет срез строки, который является неизменяемой ссылкой на " +"строковые данные в кодировке UTF-8, хранящиеся в памяти. Строковые литералы " +"(`”Hello”`) хранятся в исполняемом файле программы." + +#: src/references/strings.md +#, fuzzy +msgid "" +"Rust's `String` type is a wrapper around a vector of bytes. As with a " +"`Vec`, it is owned." +msgstr "Тип `String` в Rust --- это обертка вокруг вектора байтов." + +#: src/references/strings.md +#, fuzzy +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 "" +"Как и во многих других типах, `String::from()` создает строку из строкового " +"литерала; `String::new()` создает новую пустую строку, в которую строковые " +"данные могут быть добавлены с помощью методов `push()` и `push_str()`." + +#: src/references/strings.md +#, fuzzy +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 "" +"Макрос `format!()` --- это удобный способ сгенерировать строку из " +"динамических значений. Он принимает ту же строку формата, что и `println!()`." + +#: src/references/strings.md +msgid "" +"You can borrow `&str` slices from `String` via `&` and optionally range " +"selection. If you select a byte range that is not aligned to character " +"boundaries, the expression will panic. The `chars` iterator iterates over " +"characters and is preferred over trying to get character boundaries right." +msgstr "" + +#: src/references/strings.md +#, fuzzy +msgid "" +"For C++ programmers: think of `&str` as `std::string_view` 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 "" +"Для программистов на C++: думайте о `&str` как о `const char*` из C++, но " +"таком, который всегда указывает на корректную строку в памяти. `String` в " +"Rust --- это примерный эквивалент `std::string` из C++ (основное отличие: " +"она может содержать только байты в кодировке UTF-8 и не будет использовать " +"оптимизацию для небольших строк)." + +#: src/references/strings.md +#, fuzzy +msgid "Byte strings literals allow you to create a `&[u8]` value directly:" +msgstr "Байтовые строки позволяют создать значение `&[u8]`:" + +#: src/references/strings.md +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 "" +"Сырые строки позволяют создавать значение `&str` с отключенным " +"экранированием: `r\"\\n\" == \"\\\\n\"`. Вы можете поставить двойные " +"кавычки, используя равное количество символов `#` с обеих сторон кавычек:" + #: src/references/exercise.md msgid "" "We will create a few utility functions for 3-dimensional geometry, " @@ -4313,20 +4310,30 @@ msgstr "" #: src/references/exercise.md msgid "" "// Calculate the magnitude of a vector by summing the squares of its " -"coordinates\n" -"// and taking the square root. Use the `sqrt()` method to calculate the " -"square\n" -"// root, like `v.sqrt()`.\n" +"coordinates" msgstr "" #: src/references/exercise.md msgid "" -"// Normalize a vector by calculating its magnitude and dividing all of its\n" -"// coordinates by that magnitude.\n" +"// and taking the square root. Use the `sqrt()` method to calculate the " +"square" msgstr "" #: src/references/exercise.md -msgid "// Use the following `main` to test your work.\n" +msgid "// root, like `v.sqrt()`." +msgstr "" + +#: src/references/exercise.md +msgid "" +"// Normalize a vector by calculating its magnitude and dividing all of its" +msgstr "" + +#: src/references/exercise.md +msgid "// coordinates by that magnitude." +msgstr "" + +#: src/references/exercise.md +msgid "// Use the following `main` to test your work." msgstr "" #: src/references/exercise.md src/references/solution.md @@ -4364,9 +4371,11 @@ msgid "[Enums](./user-defined-types/enums.md) (5 minutes)" msgstr "" #: src/user-defined-types.md -msgid "" -"[Static and Const](./user-defined-types/static-and-const.md) (5 minutes)" +#, fuzzy +msgid "[Static](./user-defined-types/static.md) (5 minutes)" msgstr "" +"Больше информации об использовании шаблонов в языке Rust можно найти на " +"[странице про сопоставление с шаблоном](../pattern-matching.md)." #: src/user-defined-types.md msgid "[Type Aliases](./user-defined-types/aliases.md) (2 minutes)" @@ -4377,6 +4386,11 @@ msgid "" "[Exercise: Elevator Events](./user-defined-types/exercise.md) (15 minutes)" msgstr "" +#: src/user-defined-types.md src/methods-and-traits.md src/borrowing.md +#: src/lifetimes.md +msgid "This segment should take about 50 minutes" +msgstr "" + #: src/user-defined-types/named-structs.md msgid "Like C and C++, Rust has support for custom structs:" msgstr "" @@ -4398,6 +4412,11 @@ msgstr "" msgid "\"Jackie\"" msgstr "" +#: src/user-defined-types/named-structs.md src/user-defined-types/enums.md +#: src/pattern-matching/match.md src/methods-and-traits/methods.md +msgid "Key Points:" +msgstr "" + #: src/user-defined-types/named-structs.md msgid "Structs work like in C or C++." msgstr "" @@ -4460,9 +4479,8 @@ msgstr "" #: src/user-defined-types/tuple-structs.md #: src/android/interoperability/cpp/cpp-bridge.md -#: src/bare-metal/microcontrollers/type-state.md #: src/async/pitfalls/cancellation.md -msgid "// ...\n" +msgid "// ..." msgstr "" #: src/user-defined-types/tuple-structs.md @@ -4510,15 +4528,15 @@ msgid "" msgstr "" #: src/user-defined-types/enums.md -msgid "// Simple variant\n" +msgid "// Simple variant" msgstr "" #: src/user-defined-types/enums.md -msgid "// Tuple variant\n" +msgid "// Tuple variant" msgstr "" #: src/user-defined-types/enums.md -msgid "// Struct variant\n" +msgid "// Struct variant" msgstr "" #: src/user-defined-types/enums.md @@ -4587,7 +4605,7 @@ msgid "" "bytes." msgstr "" -#: src/user-defined-types/enums.md src/user-defined-types/static-and-const.md +#: src/user-defined-types/enums.md src/user-defined-types/static.md #: src/memory-management/review.md src/memory-management/move.md #: src/smart-pointers/box.md src/borrowing/shared.md msgid "More to Explore" @@ -4613,55 +4631,26 @@ msgid "" "guarantees regarding this representation, therefore this is totally unsafe." msgstr "" -#: src/user-defined-types/static-and-const.md -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/user-defined-types/static-and-const.md -msgid "`const`" -msgstr "" - -#: src/user-defined-types/static-and-const.md -msgid "" -"Constant variables are evaluated at compile time and their values are " -"inlined wherever they are used:" -msgstr "" - -#: src/user-defined-types/static-and-const.md -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/user-defined-types/static-and-const.md -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/user-defined-types/static-and-const.md +#: src/user-defined-types/static.md msgid "`static`" msgstr "" -#: src/user-defined-types/static-and-const.md +#: src/user-defined-types/static.md msgid "" "Static variables will live during the whole execution of the program, and " "therefore will not move:" msgstr "" -#: src/user-defined-types/static-and-const.md +#: src/user-defined-types/static.md #, fuzzy msgid "\"Welcome to RustOS 3.14\"" msgstr "Добро пожаловать в День 1" -#: src/user-defined-types/static-and-const.md +#: src/user-defined-types/static.md msgid "\"{BANNER}\"" msgstr "" -#: src/user-defined-types/static-and-const.md +#: src/user-defined-types/static.md 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 " @@ -4671,99 +4660,59 @@ msgid "" "`const` is generally preferred." msgstr "" -#: src/user-defined-types/static-and-const.md -msgid "Mention that `const` behaves semantically similar to C++'s `constexpr`." +#: src/user-defined-types/static.md +msgid "`static` is similar to mutable global variables in C++." msgstr "" -#: src/user-defined-types/static-and-const.md -msgid "" -"`static`, on the other hand, is much more similar to a `const` or mutable " -"global variable in C++." -msgstr "" - -#: src/user-defined-types/static-and-const.md +#: src/user-defined-types/static.md msgid "" "`static` provides object identity: an address in memory and state as " "required by types with interior mutability such as `Mutex`." msgstr "" -#: src/user-defined-types/static-and-const.md -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/user-defined-types/static-and-const.md -msgid "Properties table:" -msgstr "" - -#: src/user-defined-types/static-and-const.md -#: src/chromium/adding-third-party-crates.md -msgid "Property" -msgstr "" - -#: src/user-defined-types/static-and-const.md -msgid "Static" -msgstr "" - -#: src/user-defined-types/static-and-const.md -msgid "Constant" -msgstr "" - -#: src/user-defined-types/static-and-const.md -msgid "Has an address in memory" -msgstr "" - -#: src/user-defined-types/static-and-const.md -#: src/chromium/adding-third-party-crates/resolving-problems.md -msgid "Yes" -msgstr "" - -#: src/user-defined-types/static-and-const.md -msgid "No (inlined)" -msgstr "" - -#: src/user-defined-types/static-and-const.md -#, fuzzy -msgid "Lives for the entire duration of the program" -msgstr "Функция `main` является точкой входа в программу." - -#: src/user-defined-types/static-and-const.md -#: src/chromium/adding-third-party-crates/resolving-problems.md -msgid "No" -msgstr "" - -#: src/user-defined-types/static-and-const.md -msgid "Can be mutable" -msgstr "" - -#: src/user-defined-types/static-and-const.md -msgid "Yes (unsafe)" -msgstr "" - -#: src/user-defined-types/static-and-const.md -msgid "Evaluated at compile time" -msgstr "" - -#: src/user-defined-types/static-and-const.md -msgid "Yes (initialised at compile time)" -msgstr "" - -#: src/user-defined-types/static-and-const.md -msgid "Inlined wherever it is used" -msgstr "" - -#: src/user-defined-types/static-and-const.md +#: src/user-defined-types/static.md 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." msgstr "" -#: src/user-defined-types/static-and-const.md +#: src/user-defined-types/static.md msgid "Thread-local data can be created with the macro `std::thread_local`." msgstr "" +#: src/user-defined-types/const.md +msgid "`const`" +msgstr "" + +#: src/user-defined-types/const.md +msgid "" +"Constants are evaluated at compile time and their values are inlined " +"wherever they are used:" +msgstr "" + +#: src/user-defined-types/const.md +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/user-defined-types/const.md +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/user-defined-types/const.md +msgid "Mention that `const` behaves semantically similar to C++'s `constexpr`" +msgstr "" + +#: src/user-defined-types/const.md +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/user-defined-types/aliases.md msgid "" "A type alias creates a name for another type. The two types can be used " @@ -4771,7 +4720,7 @@ msgid "" msgstr "" #: src/user-defined-types/aliases.md -msgid "// Aliases are more useful with long, complex types:\n" +msgid "// Aliases are more useful with long, complex types:" msgstr "" #: src/user-defined-types/aliases.md @@ -4799,7 +4748,7 @@ msgid "" msgstr "" #: src/user-defined-types/exercise.md -msgid "// TODO: add required variants\n" +msgid "// TODO: add required variants" msgstr "" #: src/user-defined-types/exercise.md src/user-defined-types/solution.md @@ -4921,25 +4870,32 @@ msgstr "" #: src/welcome-day-2.md #, fuzzy -msgid "[Pattern Matching](./pattern-matching.md) (50 minutes)" +msgid "[Pattern Matching](./pattern-matching.md) (1 hour)" msgstr "" "Больше информации об использовании шаблонов в языке Rust можно найти на " "[странице про сопоставление с шаблоном](../pattern-matching.md)." #: src/welcome-day-2.md -msgid "[Methods and Traits](./methods-and-traits.md) (55 minutes)" +msgid "[Methods and Traits](./methods-and-traits.md) (50 minutes)" msgstr "" #: src/welcome-day-2.md -msgid "[Generics](./generics.md) (45 minutes)" +msgid "[Generics](./generics.md) (40 minutes)" msgstr "" -#: src/welcome-day-2.md src/welcome-day-4.md +#: src/welcome-day-2.md msgid "" -"Including 10 minute breaks, this session should take about 3 hours and 5 " +"Including 10 minute breaks, this session should take about 2 hours and 55 " "minutes" msgstr "" +#: src/pattern-matching.md +#, fuzzy +msgid "[Matching Values](./pattern-matching/match.md) (10 minutes)" +msgstr "" +"Больше информации об использовании шаблонов в языке Rust можно найти на " +"[странице про сопоставление с шаблоном](../pattern-matching.md)." + #: src/pattern-matching.md msgid "[Destructuring](./pattern-matching/destructuring.md) (10 minutes)" msgstr "" @@ -4954,6 +4910,143 @@ msgid "" "minutes)" msgstr "" +#: src/pattern-matching.md src/memory-management.md +msgid "This segment should take about 1 hour" +msgstr "" + +#: src/pattern-matching/match.md +msgid "" +"The `match` keyword lets you match a value against one or more _patterns_. " +"The comparisons are done from top to bottom and the first match wins." +msgstr "" + +#: src/pattern-matching/match.md +msgid "The patterns can be simple values, similarly to `switch` in C and C++:" +msgstr "" + +#: src/pattern-matching/match.md +msgid "'x'" +msgstr "" + +#: src/pattern-matching/match.md +msgid "'q'" +msgstr "" + +#: src/pattern-matching/match.md +msgid "\"Quitting\"" +msgstr "" + +#: src/pattern-matching/match.md src/generics/exercise.md +#: src/generics/solution.md src/std-traits/solution.md +#: src/error-handling/exercise.md src/error-handling/solution.md +msgid "'a'" +msgstr "" + +#: src/pattern-matching/match.md +msgid "'s'" +msgstr "" + +#: src/pattern-matching/match.md +msgid "'w'" +msgstr "" + +#: src/pattern-matching/match.md +msgid "'d'" +msgstr "" + +#: src/pattern-matching/match.md +msgid "\"Moving around\"" +msgstr "" + +#: src/pattern-matching/match.md src/error-handling/exercise.md +#: src/error-handling/solution.md +msgid "'0'" +msgstr "" + +#: src/pattern-matching/match.md src/error-handling/exercise.md +#: src/error-handling/solution.md +msgid "'9'" +msgstr "" + +#: src/pattern-matching/match.md +msgid "\"Number input\"" +msgstr "" + +#: src/pattern-matching/match.md +msgid "\"Lowercase: {key}\"" +msgstr "" + +#: src/pattern-matching/match.md +msgid "\"Something else\"" +msgstr "" + +#: src/pattern-matching/match.md +msgid "" +"The `_` pattern is a wildcard pattern which matches any value. The " +"expressions _must_ be exhaustive, meaning that it covers every possibility, " +"so `_` is often used as the final catch-all case." +msgstr "" + +#: src/pattern-matching/match.md +msgid "" +"Match can be used as an expression. Just like `if`, each match arm must have " +"the same type. The type is the last expression of the block, if any. In the " +"example above, the type is `()`." +msgstr "" + +#: src/pattern-matching/match.md +msgid "" +"A variable in the pattern (`key` in this example) will create a binding that " +"can be used within the match arm." +msgstr "" + +#: src/pattern-matching/match.md +msgid "A match guard causes the arm to match only if the condition is true." +msgstr "" + +#: src/pattern-matching/match.md +msgid "" +"You might point out how some specific characters are being used when in a " +"pattern" +msgstr "" + +#: src/pattern-matching/match.md +msgid "`|` as an `or`" +msgstr "" + +#: src/pattern-matching/match.md +msgid "`..` can expand as much as it needs to be" +msgstr "" + +#: src/pattern-matching/match.md +msgid "`1..=5` represents an inclusive range" +msgstr "" + +#: src/pattern-matching/match.md +msgid "`_` is a wild card" +msgstr "" + +#: src/pattern-matching/match.md +msgid "" +"Match guards as a separate syntax feature are important and necessary when " +"we wish to concisely express more complex ideas than patterns alone would " +"allow." +msgstr "" + +#: src/pattern-matching/match.md +msgid "" +"They are not the same as separate `if` expression inside of the match arm. " +"An `if` expression inside of the branch block (after `=>`) happens after the " +"match arm is selected. Failing the `if` condition inside of that block won't " +"result in other arms of the original `match` expression being considered." +msgstr "" + +#: src/pattern-matching/match.md +msgid "" +"The condition defined in the guard applies to every expression in a pattern " +"with an `|`." +msgstr "" + #: src/pattern-matching/destructuring.md msgid "Like tuples, structs and enums can also be destructured by matching:" msgstr "" @@ -5113,8 +5206,8 @@ msgid "\"result: {:?}\"" msgstr "" #: src/pattern-matching/let-control-flow.md src/generics/trait-bounds.md -#: src/smart-pointers/solution.md src/testing/googletest.md -#: src/testing/solution.md +#: src/smart-pointers/solution.md src/testing/solution.md +#: src/android/testing.md src/android/testing/googletest.md msgid "\"foo\"" msgstr "" @@ -5273,26 +5366,21 @@ msgid "[Methods](./methods-and-traits/methods.md) (10 minutes)" msgstr "" #: src/methods-and-traits.md -msgid "[Traits](./methods-and-traits/traits.md) (10 minutes)" +msgid "[Traits](./methods-and-traits/traits.md) (15 minutes)" msgstr "" #: src/methods-and-traits.md -msgid "[Deriving](./methods-and-traits/deriving.md) (5 minutes)" -msgstr "" - -#: src/methods-and-traits.md -msgid "[Trait Objects](./methods-and-traits/trait-objects.md) (10 minutes)" +#, fuzzy +msgid "[Deriving](./methods-and-traits/deriving.md) (3 minutes)" msgstr "" +"Больше информации об использовании шаблонов в языке Rust можно найти на " +"[странице про сопоставление с шаблоном](../pattern-matching.md)." #: src/methods-and-traits.md msgid "" "[Exercise: Generic Logger](./methods-and-traits/exercise.md) (20 minutes)" msgstr "" -#: src/methods-and-traits.md -msgid "This segment should take about 55 minutes" -msgstr "" - #: src/methods-and-traits/methods.md msgid "" "Rust allows you to associate functions with your new types. You do this with " @@ -5300,15 +5388,15 @@ msgid "" msgstr "" #: src/methods-and-traits/methods.md -msgid "// No receiver, a static method\n" +msgid "// No receiver, a static method" msgstr "" #: src/methods-and-traits/methods.md -msgid "// Exclusive borrowed read-write access to self\n" +msgid "// Exclusive borrowed read-write access to self" msgstr "" #: src/methods-and-traits/methods.md -msgid "// Shared and read-only borrowed access to self\n" +msgid "// Shared and read-only borrowed access to self" msgstr "" #: src/methods-and-traits/methods.md @@ -5320,7 +5408,7 @@ msgid "\"Lap {idx}: {lap} sec\"" msgstr "" #: src/methods-and-traits/methods.md -msgid "// Exclusive ownership of self\n" +msgid "// Exclusive ownership of self" msgstr "" #: src/methods-and-traits/methods.md @@ -5332,7 +5420,7 @@ msgid "\"Monaco Grand Prix\"" msgstr "" #: src/methods-and-traits/methods.md -msgid "// race.add_lap(42);\n" +msgid "// race.add_lap(42);" msgstr "" #: src/methods-and-traits/methods.md @@ -5429,19 +5517,11 @@ msgid "" msgstr "" #: src/methods-and-traits/traits.md -msgid "\"Oh you're a cutie! What's your name? {}\"" +msgid "/// Return a sentence from this pet." msgstr "" -#: src/methods-and-traits/traits.md src/methods-and-traits/trait-objects.md -msgid "\"Woof, my name is {}!\"" -msgstr "" - -#: src/methods-and-traits/traits.md src/methods-and-traits/trait-objects.md -msgid "\"Miau!\"" -msgstr "" - -#: src/methods-and-traits/traits.md src/methods-and-traits/trait-objects.md -msgid "\"Fido\"" +#: src/methods-and-traits/traits.md +msgid "/// Print a string to the terminal greeting this pet." msgstr "" #: src/methods-and-traits/traits.md @@ -5451,14 +5531,89 @@ msgid "" msgstr "" #: src/methods-and-traits/traits.md -msgid "Traits are implemented in an `impl for { .. }` block." +msgid "" +"In the \"Generics\" segment, next, we will see how to build functionality " +"that is generic over all types implementing a trait." msgstr "" -#: src/methods-and-traits/traits.md +#: src/methods-and-traits/traits/implementing.md +msgid "\"Oh you're a cutie! What's your name? {}\"" +msgstr "" + +#: src/methods-and-traits/traits/implementing.md +#: src/smart-pointers/trait-objects.md +msgid "\"Woof, my name is {}!\"" +msgstr "" + +#: src/methods-and-traits/traits/implementing.md +#: src/smart-pointers/trait-objects.md +msgid "\"Fido\"" +msgstr "" + +#: src/methods-and-traits/traits/implementing.md msgid "" -"Traits may specify pre-implemented (provided) methods and methods that users " -"are required to implement themselves. Provided methods can rely on required " -"methods. In this case, `greet` is provided, and relies on `talk`." +"To implement `Trait` for `Type`, you use an `impl Trait for Type { .. }` " +"block." +msgstr "" + +#: src/methods-and-traits/traits/implementing.md +msgid "" +"Unlike Go interfaces, just having matching methods is not enough: a `Cat` " +"type with a `talk()` method would not automatically satisfy `Pet` unless it " +"is in an `impl Pet` block." +msgstr "" + +#: src/methods-and-traits/traits/implementing.md +msgid "" +"Traits may provide default implementations of some methods. Default " +"implementations can rely on all the methods of the trait. In this case, " +"`greet` is provided, and relies on `talk`." +msgstr "" + +#: src/methods-and-traits/traits/supertraits.md +msgid "" +"A trait can require that types implementing it also implement other traits, " +"called _supertraits_. Here, any type implementing `Pet` must implement " +"`Animal`." +msgstr "" + +#: src/methods-and-traits/traits/supertraits.md +#: src/async/control-flow/select.md +msgid "\"Rex\"" +msgstr "" + +#: src/methods-and-traits/traits/supertraits.md +msgid "\"{} has {} legs\"" +msgstr "" + +#: src/methods-and-traits/traits/supertraits.md +msgid "" +"This is sometimes called \"trait inheritance\" but students should not " +"expect this to behave like OO inheritance. It just specifies an additional " +"requirement on implementations of a trait." +msgstr "" + +#: src/methods-and-traits/traits/associated-types.md +msgid "" +"Associated types are placeholder types which are supplied by the trait " +"implementation." +msgstr "" + +#: src/methods-and-traits/traits/associated-types.md +#: src/async/control-flow/join.md +msgid "\"{:?}\"" +msgstr "" + +#: src/methods-and-traits/traits/associated-types.md +msgid "" +"Associated types are sometimes also called \"output types\". The key " +"observation is that the implementer, not the caller, chooses this type." +msgstr "" + +#: src/methods-and-traits/traits/associated-types.md +msgid "" +"Many standard library traits have associated types, including arithmetic " +"operators and `Iterator`." msgstr "" #: src/methods-and-traits/deriving.md @@ -5468,11 +5623,11 @@ msgid "" msgstr "" #: src/methods-and-traits/deriving.md -msgid "// Default trait adds `default` constructor.\n" +msgid "// Default trait adds `default` constructor." msgstr "" #: src/methods-and-traits/deriving.md -msgid "// Clone trait adds `clone` method.\n" +msgid "// Clone trait adds `clone` method." msgstr "" #: src/methods-and-traits/deriving.md @@ -5480,7 +5635,7 @@ msgid "\"EldurScrollz\"" msgstr "" #: src/methods-and-traits/deriving.md -msgid "// Debug trait adds support for printing with `{:?}`.\n" +msgid "// Debug trait adds support for printing with `{:?}`." msgstr "" #: src/methods-and-traits/deriving.md @@ -5494,128 +5649,10 @@ msgid "" "serialization support for a struct using `#[derive(Serialize)]`." msgstr "" -#: src/methods-and-traits/trait-objects.md -msgid "" -"Trait objects allow for values of different types, for instance in a " -"collection:" -msgstr "" - -#: src/methods-and-traits/trait-objects.md -msgid "\"Hello, who are you? {}\"" -msgstr "" - -#: src/methods-and-traits/trait-objects.md -msgid "Memory layout after allocating `pets`:" -msgstr "" - -#: src/methods-and-traits/trait-objects.md -msgid "" -"```bob\n" -" Stack Heap\n" -".- - - - - - - - - - - - - -. .- - - - - - - - - - - - - - - - - - - - - " -"- -.\n" -": : : :\n" -": pets : : +----+----+----+----" -"+ :\n" -": +-----------+-------+ : : +-----+-----+ .->| F | i | d | o " -"| :\n" -": | ptr | o---+---+-----+-->| o o | o o | | +----+----+----+----" -"+ :\n" -": | len | 2 | : : +-|-|-+-|-|-+ " -"`---------. :\n" -": | capacity | 2 | : : | | | | data " -"| :\n" -": +-----------+-------+ : : | | | | +-------+--|-------" -"+ :\n" -": : : | | | '-->| name | o, 4, 4 " -"| :\n" -": : : | | | | age | 5 " -"| :\n" -"`- - - - - - - - - - - - - -' : | | | +-------+----------" -"+ :\n" -" : | | " -"| :\n" -" : | | | " -"vtable :\n" -" : | | | +----------------------" -"+ :\n" -" : | | '---->| \"::talk\" " -"| :\n" -" : | | +----------------------" -"+ :\n" -" : | " -"| :\n" -" : | | " -"data :\n" -" : | | +-------+-------" -"+ :\n" -" : | '-->| lives | 9 " -"| :\n" -" : | +-------+-------" -"+ :\n" -" : " -"| :\n" -" : | " -"vtable :\n" -" : | +----------------------" -"+ :\n" -" : '---->| \"::talk\" " -"| :\n" -" : +----------------------" -"+ :\n" -" : :\n" -" '- - - - - - - - - - - - - - - - - - - - - " -"- -'\n" -"```" -msgstr "" - -#: src/methods-and-traits/trait-objects.md -msgid "" -"Types that implement a given trait may be of different sizes. This makes it " -"impossible to have things like `Vec` in the example above." -msgstr "" - -#: src/methods-and-traits/trait-objects.md -msgid "" -"`dyn Pet` is a way to tell the compiler about a dynamically sized type that " -"implements `Pet`." -msgstr "" - -#: src/methods-and-traits/trait-objects.md -msgid "" -"In the example, `pets` is allocated on the stack and the vector data is on " -"the heap. The two vector elements are _fat pointers_:" -msgstr "" - -#: src/methods-and-traits/trait-objects.md -msgid "" -"A fat pointer is a double-width pointer. It has two components: a pointer to " -"the actual object and a pointer to the [virtual method table](https://en." -"wikipedia.org/wiki/Virtual_method_table) (vtable) for the `Pet` " -"implementation of that particular object." -msgstr "" - -#: src/methods-and-traits/trait-objects.md -msgid "" -"The data for the `Dog` named Fido is the `name` and `age` fields. The `Cat` " -"has a `lives` field." -msgstr "" - -#: src/methods-and-traits/trait-objects.md -msgid "Compare these outputs in the above example:" -msgstr "" - -#: src/methods-and-traits/trait-objects.md src/std-traits/closures.md -msgid "\"{} {}\"" -msgstr "" - -#: src/methods-and-traits/trait-objects.md src/std-traits/exercise.md -#: src/std-traits/solution.md src/modules/exercise.md src/modules/solution.md -#: src/android/build-rules/library.md -#: src/android/interoperability/cpp/rust-bridge.md -#: src/async/pitfalls/cancellation.md -msgid "\"{}\"" -msgstr "" +#: src/methods-and-traits/exercise.md +#, fuzzy +msgid "Exercise: Logger Trait" +msgstr "Упражнения" #: src/methods-and-traits/exercise.md msgid "" @@ -5656,7 +5693,7 @@ msgid "\"Uhoh\"" msgstr "" #: src/methods-and-traits/exercise.md -msgid "// TODO: Define and implement `VerbosityFilter`.\n" +msgid "// TODO: Define and implement `VerbosityFilter`." msgstr "" #: src/methods-and-traits/solution.md @@ -5668,7 +5705,7 @@ msgid "[Generic Functions](./generics/generic-functions.md) (5 minutes)" msgstr "" #: src/generics.md -msgid "[Generic Data Types](./generics/generic-data.md) (15 minutes)" +msgid "[Generic Data Types](./generics/generic-data.md) (10 minutes)" msgstr "" #: src/generics.md @@ -5683,10 +5720,6 @@ msgstr "" msgid "[Exercise: Generic min](./generics/exercise.md) (10 minutes)" msgstr "" -#: src/generics.md src/smart-pointers.md src/iterators.md src/error-handling.md -msgid "This segment should take about 45 minutes" -msgstr "" - #: src/generics/generic-functions.md msgid "" "Rust supports generics, which lets you abstract algorithms or data " @@ -5694,7 +5727,7 @@ msgid "" msgstr "" #: src/generics/generic-functions.md -msgid "/// Pick `even` or `odd` depending on the value of `n`.\n" +msgid "/// Pick `even` or `odd` depending on the value of `n`." msgstr "" #: src/generics/generic-functions.md @@ -5740,7 +5773,7 @@ msgid "You can use generics to abstract over the concrete field type:" msgstr "" #: src/generics/generic-data.md -msgid "// fn set_x(&mut self, x: T)\n" +msgid "// fn set_x(&mut self, x: T)" msgstr "" #: src/generics/generic-data.md @@ -5784,6 +5817,54 @@ msgid "" "type variables, e.g., `T` and `U`." msgstr "" +#: src/generics/generic-traits.md +msgid "" +"Traits can also be generic, just like types and functions. A trait's " +"parameters get concrete types when it is used." +msgstr "" + +#: src/generics/generic-traits.md +msgid "\"Converted from integer: {from}\"" +msgstr "" + +#: src/generics/generic-traits.md +msgid "\"Converted from bool: {from}\"" +msgstr "" + +#: src/generics/generic-traits.md +msgid "\"{from_int:?}, {from_bool:?}\"" +msgstr "" + +#: src/generics/generic-traits.md +msgid "" +"The `From` trait will be covered later in the course, but its [definition in " +"the `std` docs](https://doc.rust-lang.org/std/convert/trait.From.html) is " +"simple." +msgstr "" + +#: src/generics/generic-traits.md +msgid "" +"Implementations of the trait do not need to cover all possible type " +"parameters. Here, `Foo::From(\"hello\")` would not compile because there is " +"no `From<&str>` implementation for `Foo`." +msgstr "" + +#: src/generics/generic-traits.md +msgid "" +"Generic traits take types as \"input\", while associated types are a kind of " +"\"output\" type. A trait can have multiple implementations for different " +"input types." +msgstr "" + +#: src/generics/generic-traits.md +msgid "" +"In fact, Rust requires that at most one implementation of a trait match for " +"any type T. Unlike some other languages, Rust has no heuristic for choosing " +"the \"most specific\" match. There is work on adding this support, called " +"[specialization](https://rust-lang.github.io/rfcs/1210-impl-specialization." +"html)." +msgstr "" + #: src/generics/trait-bounds.md msgid "" "When working with generics, you often want to require the types to implement " @@ -5795,7 +5876,7 @@ msgid "You can do this with `T: Trait` or `impl Trait`:" msgstr "" #: src/generics/trait-bounds.md -msgid "// struct NotClonable;\n" +msgid "// struct NotClonable;" msgstr "" #: src/generics/trait-bounds.md @@ -5841,9 +5922,11 @@ msgid "" msgstr "" #: src/generics/impl-trait.md -msgid "" -"// Syntactic sugar for:\n" -"// fn add_42_millions>(x: T) -> i32 {\n" +msgid "// Syntactic sugar for:" +msgstr "" + +#: src/generics/impl-trait.md +msgid "// fn add_42_millions>(x: T) -> i32 {" msgstr "" #: src/generics/impl-trait.md @@ -5896,33 +5979,60 @@ msgstr "" #: src/generics/exercise.md msgid "" "In this short exercise, you will implement a generic `min` function that " -"determines the minimum of two values, using a `LessThan` trait." -msgstr "" - -#: src/generics/exercise.md src/generics/solution.md -msgid "/// Return true if self is less than other.\n" +"determines the minimum of two values, using the [`Ord`](https://doc.rust-" +"lang.org/stable/std/cmp/trait.Ord.html) trait." msgstr "" #: src/generics/exercise.md -msgid "// TODO: implement the `min` function used in `main`.\n" +msgid "// TODO: implement the `min` function used in `main`." msgstr "" #: src/generics/exercise.md src/generics/solution.md -msgid "\"Shapiro\"" +#: src/error-handling/exercise.md src/error-handling/solution.md +msgid "'z'" msgstr "" #: src/generics/exercise.md src/generics/solution.md -msgid "\"Baumann\"" +msgid "'7'" +msgstr "" + +#: src/generics/exercise.md src/generics/solution.md +msgid "'1'" +msgstr "" + +#: src/generics/exercise.md src/generics/solution.md +msgid "\"goodbye\"" +msgstr "" + +#: src/generics/exercise.md src/generics/solution.md +msgid "\"bat\"" +msgstr "" + +#: src/generics/exercise.md src/generics/solution.md +msgid "\"armadillo\"" +msgstr "" + +#: src/generics/exercise.md +msgid "" +"Show students the [`Ord`](https://doc.rust-lang.org/stable/std/cmp/trait.Ord." +"html) trait and [`Ordering`](https://doc.rust-lang.org/stable/std/cmp/enum." +"Ordering.html) enum." msgstr "" #: src/welcome-day-2-afternoon.md -msgid "[Standard Library Types](./std-types.md) (1 hour and 10 minutes)" +msgid "[Standard Library Types](./std-types.md) (1 hour and 20 minutes)" msgstr "" #: src/welcome-day-2-afternoon.md msgid "[Standard Library Traits](./std-traits.md) (1 hour and 40 minutes)" msgstr "" +#: src/welcome-day-2-afternoon.md +msgid "" +"Including 10 minute breaks, this session should take about 3 hours and 10 " +"minutes" +msgstr "" + #: src/std-types.md msgid "[Standard Library](./std-types/std.md) (3 minutes)" msgstr "" @@ -5952,11 +6062,11 @@ msgid "[HashMap](./std-types/hashmap.md) (10 minutes)" msgstr "" #: src/std-types.md -msgid "[Exercise: Counter](./std-types/exercise.md) (10 minutes)" +msgid "[Exercise: Counter](./std-types/exercise.md) (20 minutes)" msgstr "" -#: src/std-types.md src/memory-management.md src/slices-and-lifetimes.md -msgid "This segment should take about 1 hour and 10 minutes" +#: src/std-types.md +msgid "This segment should take about 1 hour and 20 minutes" msgstr "" #: src/std-types.md @@ -6026,10 +6136,16 @@ msgstr "" #: src/std-types/docs.md msgid "" -"/// Determine whether the first argument is divisible by the second " -"argument.\n" -"///\n" -"/// If the second argument is zero, the result is false.\n" +"/// Determine whether the first argument is divisible by the second argument." +msgstr "" + +#: src/std-types/docs.md src/testing/other.md +#: src/unsafe-rust/unsafe-functions.md +msgid "///" +msgstr "" + +#: src/std-types/docs.md +msgid "/// If the second argument is zero, the result is false." msgstr "" #: src/std-types/docs.md @@ -6053,8 +6169,7 @@ msgstr "" #: src/std-types/docs.md msgid "" -"//! This module contains functionality relating to divisibility of " -"integers.\n" +"//! This module contains functionality relating to divisibility of integers." msgstr "" #: src/std-types/docs.md @@ -6171,7 +6286,7 @@ msgstr "" #: src/std-types/result.md msgid "" "`Result` is the standard type to implement error handling as we will see on " -"Day 3." +"Day 4." msgstr "" #: src/std-types/string.md @@ -6288,6 +6403,15 @@ msgid "" "boundaries or not." msgstr "" +#: src/std-types/string.md +msgid "" +"Many types can be converted to a string with the [`to_string`](https://doc." +"rust-lang.org/std/string/trait.ToString.html#tymethod.to_string) method. " +"This trait is automatically implemented for all types that implement " +"`Display`, so anything that can be formatted can also be converted to a " +"string." +msgstr "" + #: src/std-types/vec.md msgid "" "[`Vec`](https://doc.rust-lang.org/std/vec/struct.Vec.html) is the standard " @@ -6303,11 +6427,11 @@ msgid "\"v2: len = {}, capacity = {}\"" msgstr "" #: src/std-types/vec.md -msgid "// Canonical macro to initialize a vector with elements.\n" +msgid "// Canonical macro to initialize a vector with elements." msgstr "" #: src/std-types/vec.md -msgid "// Retain only the even elements.\n" +msgid "// Retain only the even elements." msgstr "" #: src/std-types/vec.md @@ -6315,7 +6439,7 @@ msgid "\"{v3:?}\"" msgstr "" #: src/std-types/vec.md -msgid "// Remove consecutive duplicates.\n" +msgid "// Remove consecutive duplicates." msgstr "" #: src/std-types/vec.md @@ -6395,7 +6519,7 @@ msgid "\"{book} is unknown.\"" msgstr "" #: src/std-types/hashmap.md -msgid "// Use the .entry() method to insert a value if nothing is found.\n" +msgid "// Use the .entry() method to insert a value if nothing is found." msgstr "" #: src/std-types/hashmap.md @@ -6483,21 +6607,21 @@ msgid "" "number of hash lookups required to implement the `count` method." msgstr "" -#: src/std-types/exercise.md src/std-types/solution.md +#: src/std-types/exercise.md msgid "" -"/// Counter counts the number of times each value of type T has been seen.\n" +"/// Counter counts the number of times each value of type T has been seen." msgstr "" -#: src/std-types/exercise.md src/std-types/solution.md -msgid "/// Create a new Counter.\n" +#: src/std-types/exercise.md +msgid "/// Create a new Counter." msgstr "" -#: src/std-types/exercise.md src/std-types/solution.md -msgid "/// Count an occurrence of the given value.\n" +#: src/std-types/exercise.md +msgid "/// Count an occurrence of the given value." msgstr "" -#: src/std-types/exercise.md src/std-types/solution.md -msgid "/// Return the number of times the given value has been seen.\n" +#: src/std-types/exercise.md +msgid "/// Return the number of times the given value has been seen." msgstr "" #: src/std-types/exercise.md src/std-types/solution.md @@ -6516,6 +6640,23 @@ msgstr "" msgid "\"got {} apples\"" msgstr "" +#: src/std-types/solution.md +msgid "" +"/// Counter counts the number of times each value of type T has been seen.\n" +msgstr "" + +#: src/std-types/solution.md +msgid "/// Create a new Counter.\n" +msgstr "" + +#: src/std-types/solution.md +msgid "/// Count an occurrence of the given value.\n" +msgstr "" + +#: src/std-types/solution.md +msgid "/// Return the number of times the given value has been seen.\n" +msgstr "" + #: src/std-traits.md msgid "[Comparisons](./std-traits/comparisons.md) (10 minutes)" msgstr "" @@ -6775,10 +6916,6 @@ msgstr "" msgid "\"\\n\"" msgstr "" -#: src/std-traits/read-and-write.md src/slices-and-lifetimes/str.md -msgid "\"World\"" -msgstr "" - #: src/std-traits/read-and-write.md msgid "\"Logged: {:?}\"" msgstr "" @@ -6809,8 +6946,8 @@ msgstr "" msgid "\"{almost_default_struct:#?}\"" msgstr "" -#: src/std-traits/default.md src/slices-and-lifetimes/exercise.md -#: src/slices-and-lifetimes/solution.md +#: src/std-traits/default.md src/lifetimes/exercise.md +#: src/lifetimes/solution.md msgid "\"{:#?}\"" msgstr "" @@ -6927,12 +7064,16 @@ msgid "" "keyword makes them capture by value." msgstr "" +#: src/std-traits/closures.md src/smart-pointers/trait-objects.md +msgid "\"{} {}\"" +msgstr "" + #: src/std-traits/closures.md msgid "\"Hi\"" msgstr "" #: src/std-traits/closures.md -msgid "\"there\"" +msgid "\"Greg\"" msgstr "" #: src/std-traits/exercise.md @@ -6944,7 +7085,7 @@ msgid "" msgstr "" #: src/std-traits/exercise.md -msgid "// Implement the `Read` trait for `RotDecoder`.\n" +msgid "// Implement the `Read` trait for `RotDecoder`." msgstr "" #: src/std-traits/exercise.md src/std-traits/solution.md @@ -6988,16 +7129,16 @@ msgid "[Welcome](./welcome-day-3.md) (3 minutes)" msgstr "" #: src/welcome-day-3.md -msgid "[Memory Management](./memory-management.md) (1 hour and 10 minutes)" +msgid "[Memory Management](./memory-management.md) (1 hour)" msgstr "" #: src/welcome-day-3.md -msgid "[Smart Pointers](./smart-pointers.md) (45 minutes)" +msgid "[Smart Pointers](./smart-pointers.md) (55 minutes)" msgstr "" #: src/welcome-day-3.md msgid "" -"Including 10 minute breaks, this session should take about 2 hours and 15 " +"Including 10 minute breaks, this session should take about 2 hours and 20 " "minutes" msgstr "" @@ -7016,7 +7157,7 @@ msgid "[Ownership](./memory-management/ownership.md) (5 minutes)" msgstr "" #: src/memory-management.md -msgid "[Move Semantics](./memory-management/move.md) (10 minutes)" +msgid "[Move Semantics](./memory-management/move.md) (5 minutes)" msgstr "" #: src/memory-management.md @@ -7110,15 +7251,21 @@ msgid "\"world\"" msgstr "" #: src/memory-management/review.md -msgid "" -"// 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" +msgid "// DON'T DO THIS AT HOME! For educational purposes only." msgstr "" #: src/memory-management/review.md -msgid "\"ptr = {ptr:#x}, len = {len}, capacity = {capacity}\"" +msgid "" +"// String provides no guarantees about its layout, so this could lead to" +msgstr "" + +#: src/memory-management/review.md +#, fuzzy +msgid "// undefined behavior." +msgstr "Отсутствие неопределенного поведения во время выполнения:" + +#: src/memory-management/review.md +msgid "\"capacity = {capacity}, ptr = {ptr:#x}, len = {len}\"" msgstr "" #: src/memory-management/approaches.md @@ -7246,12 +7393,8 @@ msgstr "" msgid "\"Hello!\"" msgstr "Привет, мир!" -#: src/memory-management/move.md src/slices-and-lifetimes/str.md -msgid "\"s2: {s2}\"" -msgstr "" - #: src/memory-management/move.md -msgid "// println!(\"s1: {s1}\");\n" +msgid "// println!(\"s1: {s1}\");" msgstr "" #: src/memory-management/move.md @@ -7278,20 +7421,20 @@ msgstr "" 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" +".- - - - - - - - - - - - - -. .- - - - - - - - - - - - - - - - - - -.\n" +": : : :\n" +": s1 \"(inaccessible)\" : : :\n" +": +-----------+-------+ : : +----+----+----+----+----+----+ :\n" +": | ptr | o---+---+--+--+-->| H | e | l | l | o | ! | :\n" +": | len | 6 | : | : +----+----+----+----+----+----+ :\n" +": | capacity | 6 | : | : :\n" +": +-----------+-------+ : | : :\n" +": : | `- - - - - - - - - - - - - - - - - - -'\n" ": s2 : |\n" ": +-----------+-------+ : |\n" ": | ptr | o---+---+--'\n" -": | len | 4 | :\n" -": | capacity | 4 | :\n" +": | len | 6 | :\n" +": | capacity | 6 | :\n" ": +-----------+-------+ :\n" ": :\n" "`- - - - - - - - - - - - - -'\n" @@ -7314,7 +7457,7 @@ msgid "\"Alice\"" msgstr "Срезы" #: src/memory-management/move.md -msgid "// say_hello(name);\n" +msgid "// say_hello(name);" msgstr "" #: src/memory-management/move.md @@ -7386,7 +7529,7 @@ msgid "\"Cpp\"" msgstr "" #: src/memory-management/move.md -msgid "// Duplicate the data in s1.\n" +msgid "// Duplicate the data in s1." msgstr "" #: src/memory-management/move.md @@ -7536,7 +7679,7 @@ msgstr "" msgid "\"a\"" msgstr "" -#: src/memory-management/drop.md src/testing/googletest.md +#: src/memory-management/drop.md src/android/testing/googletest.md msgid "\"b\"" msgstr "" @@ -7725,6 +7868,10 @@ msgstr "" msgid "[Rc](./smart-pointers/rc.md) (5 minutes)" msgstr "" +#: src/smart-pointers.md +msgid "[Trait Objects](./smart-pointers/trait-objects.md) (10 minutes)" +msgstr "" + #: src/smart-pointers.md msgid "[Exercise: Binary Tree](./smart-pointers/exercise.md) (30 minutes)" msgstr "" @@ -7752,11 +7899,11 @@ msgid "" msgstr "" #: src/smart-pointers/box.md -msgid "/// A non-empty list: first element and the rest of the list.\n" +msgid "/// A non-empty list: first element and the rest of the list." msgstr "" #: src/smart-pointers/box.md -msgid "/// An empty list.\n" +msgid "/// An empty list." msgstr "" #: src/smart-pointers/box.md @@ -7811,8 +7958,8 @@ msgstr "" #: src/smart-pointers/box.md msgid "" "If `Box` was not used and we attempted to embed a `List` directly into the " -"`List`, the compiler would not compute a fixed size of the struct in memory " -"(`List` would be of infinite size)." +"`List`, the compiler would not be able to compute a fixed size for the " +"struct in memory (the `List` would be of infinite size)." msgstr "" #: src/smart-pointers/box.md @@ -7823,9 +7970,10 @@ msgstr "" #: src/smart-pointers/box.md msgid "" -"Remove the `Box` in the List definition and show the compiler error. " -"\"Recursive with indirection\" is a hint you might want to use a Box or " -"reference of some kind, instead of storing a value directly." +"Remove the `Box` in the List definition and show the compiler error. We get " +"the message \"recursive without indirection\", because for data recursion, " +"we have to use indirection, a `Box` or reference of some kind, instead of " +"storing the value directly." msgstr "" #: src/smart-pointers/box.md @@ -7834,24 +7982,37 @@ msgstr "" #: src/smart-pointers/box.md msgid "" -"A `Box` cannot be empty, so the pointer is always valid and non-`null`. This " -"allows the compiler to optimize the memory layout:" +"Though `Box` looks like `std::unique_ptr` in C++, it cannot be empty/null. " +"This makes `Box` one of the types that allow the compiler to optimize " +"storage of some enums." msgstr "" #: src/smart-pointers/box.md msgid "" -"```bob\n" -" Stack Heap\n" -".- - - - - - - - - - - - - - . .- - - - - - - - - - - - - -.\n" -": : : :\n" -": list : : :\n" -": +---------+----+----+ : : +---------+----+----+ :\n" -": | Element | 1 | o--+----+-----+--->| Element | 2 | // | :\n" -": +---------+----+----+ : : +---------+----+----+ :\n" -": : : :\n" -": : : :\n" -"'- - - - - - - - - - - - - - ' '- - - - - - - - - - - - - -'\n" -"```" +"For example, `Option>` has the same size, as just `Box`, because " +"compiler uses NULL-value to discriminate variants instead of using explicit " +"tag ([\"Null Pointer Optimization\"](https://doc.rust-lang.org/std/option/" +"#representation)):" +msgstr "" + +#: src/smart-pointers/box.md +msgid "\"Just box\"" +msgstr "" + +#: src/smart-pointers/box.md +msgid "\"Optional box\"" +msgstr "" + +#: src/smart-pointers/box.md +msgid "\"Size of just_box: {}\"" +msgstr "" + +#: src/smart-pointers/box.md +msgid "\"Size of optional_box: {}\"" +msgstr "" + +#: src/smart-pointers/box.md +msgid "\"Size of none: {}\"" msgstr "" #: src/smart-pointers/rc.md @@ -7915,6 +8076,120 @@ msgid "" "cycles that will be dropped properly (likely in combination with `RefCell`)." msgstr "" +#: src/smart-pointers/trait-objects.md +msgid "" +"Trait objects allow for values of different types, for instance in a " +"collection:" +msgstr "" + +#: src/smart-pointers/trait-objects.md +msgid "\"Miau!\"" +msgstr "" + +#: src/smart-pointers/trait-objects.md +msgid "\"Hello, who are you? {}\"" +msgstr "" + +#: src/smart-pointers/trait-objects.md +msgid "Memory layout after allocating `pets`:" +msgstr "" + +#: src/smart-pointers/trait-objects.md +msgid "" +"```bob\n" +" Stack Heap\n" +".- - - - - - - - - - - - - -. .- - - - - - - - - - - - - - - - - - - - - " +"- -.\n" +": : : :\n" +": \"pets: Vec\" : : \"data: Cat\" +----+----+----" +"+----+ :\n" +": +-----------+-------+ : : +-------+-------+ | F | i | d | " +"o | :\n" +": | ptr | o---+---+--. : | lives | 9 | +----+----+----" +"+----+ :\n" +": | len | 2 | : | : +-------+-------+ " +"^ :\n" +": | capacity | 2 | : | : ^ " +"| :\n" +": +-----------+-------+ : | : | " +"'-------. :\n" +": : | : | data:" +"\"Dog\"| :\n" +": : | : | +-------+--|-------" +"+ :\n" +"`- - - - - - - - - - - - - -' | : +---|-+-----+ | name | o, 4, 4 " +"| :\n" +" `--+-->| o o | o o-|----->| age | 5 " +"| :\n" +" : +-|---+-|---+ +-------+----------" +"+ :\n" +" : | " +"| :\n" +" `- - -| - - |- - - - - - - - - - - - - - - " +"- -'\n" +" | |\n" +" | | " +"\"Program text\"\n" +" .- - -| - - |- - - - - - - - - - - - - - - " +"- -.\n" +" : | | " +"vtable :\n" +" : | | +----------------------" +"+ :\n" +" : | `----->| \"::" +"talk\" | :\n" +" : | +----------------------" +"+ :\n" +" : | " +"vtable :\n" +" : | +----------------------" +"+ :\n" +" : '----------->| \"::" +"talk\" | :\n" +" : +----------------------" +"+ :\n" +" : :\n" +" '- - - - - - - - - - - - - - - - - - - - - " +"- -'\n" +"```" +msgstr "" + +#: src/smart-pointers/trait-objects.md +msgid "" +"Types that implement a given trait may be of different sizes. This makes it " +"impossible to have things like `Vec` in the example above." +msgstr "" + +#: src/smart-pointers/trait-objects.md +msgid "" +"`dyn Pet` is a way to tell the compiler about a dynamically sized type that " +"implements `Pet`." +msgstr "" + +#: src/smart-pointers/trait-objects.md +msgid "" +"In the example, `pets` is allocated on the stack and the vector data is on " +"the heap. The two vector elements are _fat pointers_:" +msgstr "" + +#: src/smart-pointers/trait-objects.md +msgid "" +"A fat pointer is a double-width pointer. It has two components: a pointer to " +"the actual object and a pointer to the [virtual method table](https://en." +"wikipedia.org/wiki/Virtual_method_table) (vtable) for the `Pet` " +"implementation of that particular object." +msgstr "" + +#: src/smart-pointers/trait-objects.md +msgid "" +"The data for the `Dog` named Fido is the `name` and `age` fields. The `Cat` " +"has a `lives` field." +msgstr "" + +#: src/smart-pointers/trait-objects.md +msgid "Compare these outputs in the above example:" +msgstr "" + #: src/smart-pointers/exercise.md msgid "" "A binary tree is a tree-type data structure where every node has two " @@ -7949,29 +8224,31 @@ msgid "" msgstr "" #: src/smart-pointers/exercise.md -msgid "// Implement `new`, `insert`, `len`, and `has`.\n" +msgid "// Implement `new`, `insert`, `len`, and `has`." msgstr "" #: src/smart-pointers/exercise.md src/smart-pointers/solution.md msgid "// not a unique item\n" msgstr "" -#: src/smart-pointers/solution.md src/testing/googletest.md +#: src/smart-pointers/solution.md src/android/testing/googletest.md msgid "\"bar\"" msgstr "" #: src/welcome-day-3-afternoon.md -msgid "[Borrowing](./borrowing.md) (1 hour)" +#, fuzzy +msgid "[Borrowing](./borrowing.md) (50 minutes)" +msgstr "" +"Больше информации об использовании шаблонов в языке Rust можно найти на " +"[странице про сопоставление с шаблоном](../pattern-matching.md)." + +#: src/welcome-day-3-afternoon.md +msgid "[Lifetimes](./lifetimes.md) (50 minutes)" msgstr "" #: src/welcome-day-3-afternoon.md msgid "" -"[Slices and Lifetimes](./slices-and-lifetimes.md) (1 hour and 10 minutes)" -msgstr "" - -#: src/welcome-day-3-afternoon.md -msgid "" -"Including 10 minute breaks, this session should take about 2 hours and 20 " +"Including 10 minute breaks, this session should take about 1 hour and 50 " "minutes" msgstr "" @@ -7988,7 +8265,7 @@ msgid "[Interior Mutability](./borrowing/interior-mutability.md) (10 minutes)" msgstr "" #: src/borrowing.md -msgid "[Exercise: Health Statistics](./borrowing/exercise.md) (30 minutes)" +msgid "[Exercise: Health Statistics](./borrowing/exercise.md) (20 minutes)" msgstr "" #: src/borrowing/shared.md @@ -8202,7 +8479,8 @@ msgid "" msgstr "" #: src/borrowing/exercise.md src/borrowing/solution.md -#: src/android/build-rules/library.md src/android/aidl/client.md +#: src/android/build-rules/library.md +#: src/android/aidl/example-service/client.md msgid "\"Bob\"" msgstr "" @@ -8210,222 +8488,30 @@ msgstr "" msgid "\"I'm {} and my age is {}\"" msgstr "" -#: src/slices-and-lifetimes.md -msgid "[Slices: &\\[T\\]](./slices-and-lifetimes/slices.md) (10 minutes)" -msgstr "" - -#: src/slices-and-lifetimes.md -msgid "[String References](./slices-and-lifetimes/str.md) (10 minutes)" -msgstr "" - -#: src/slices-and-lifetimes.md +#: src/lifetimes.md msgid "" -"[Lifetime Annotations](./slices-and-lifetimes/lifetime-annotations.md) (10 " -"minutes)" +"[Lifetime Annotations](./lifetimes/lifetime-annotations.md) (10 minutes)" msgstr "" -#: src/slices-and-lifetimes.md -msgid "" -"[Lifetime Elision](./slices-and-lifetimes/lifetime-elision.md) (5 minutes)" +#: src/lifetimes.md +msgid "[Lifetime Elision](./lifetimes/lifetime-elision.md) (5 minutes)" msgstr "" -#: src/slices-and-lifetimes.md -msgid "" -"[Struct Lifetimes](./slices-and-lifetimes/struct-lifetimes.md) (5 minutes)" +#: src/lifetimes.md +msgid "[Struct Lifetimes](./lifetimes/struct-lifetimes.md) (5 minutes)" msgstr "" -#: src/slices-and-lifetimes.md -msgid "" -"[Exercise: Protobuf Parsing](./slices-and-lifetimes/exercise.md) (30 minutes)" +#: src/lifetimes.md +msgid "[Exercise: Protobuf Parsing](./lifetimes/exercise.md) (30 minutes)" msgstr "" -#: src/slices-and-lifetimes/slices.md -msgid "Slices" -msgstr "Срезы" - -#: src/slices-and-lifetimes/slices.md -msgid "A slice gives you a view into a larger collection:" -msgstr "" -"Срезы позволяют ссылаться на непрерывную последовательность элементов в " -"коллекции:" - -#: src/slices-and-lifetimes/slices.md -msgid "Slices borrow data from the sliced type." -msgstr "Срезы заимствуют данные у коллекции." - -#: src/slices-and-lifetimes/slices.md -#, fuzzy -msgid "Question: What happens if you modify `a[3]` right before printing `s`?" -msgstr "Вопрос: Что произойдет, если вы измените значение в `a[3]`?" - -#: src/slices-and-lifetimes/slices.md -msgid "" -"We create a slice by borrowing `a` and specifying the starting and ending " -"indexes in brackets." -msgstr "" -"Мы создаем срез, заимствуя `a` и указывая начальный и конечный индексы в " -"скобках." - -#: src/slices-and-lifetimes/slices.md -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 "" -"Если срез начинается с индекса 0, синтаксис Rust позволяет отбросить " -"начальный индекс, таким образом, `&a[0..a.len()]` и `&a[..a.len()]` " -"идентичны ." - -#: src/slices-and-lifetimes/slices.md -msgid "" -"The same is true for the last index, so `&a[2..a.len()]` and `&a[2..]` are " -"identical." -msgstr "" -"То же верно и для последнего индекса, поэтому `&a[2..a.len()]` и `&a[2..]` " -"идентичны." - -#: src/slices-and-lifetimes/slices.md -msgid "" -"To easily create a slice of the full array, we can therefore use `&a[..]`." -msgstr "Чтобы создать срез всего массива, можно использовать `&a[..]`." - -#: src/slices-and-lifetimes/slices.md -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 "" -"`s` --- это ссылка на срез элементов типа `i32`. Обратите внимание, что тип " -"`s` (`&[i32]`) больше не указывает длину массива. Это позволяет выполнять " -"вычисления на срезах разных размеров." - -#: src/slices-and-lifetimes/slices.md -#, fuzzy -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 "" -"Срезы всегда заимствуют у другого объекта. В этом примере `a` должен " -"оставаться ‘живым’ (в области видимости) по крайней мере столько же, сколько " -"и срез." - -#: src/slices-and-lifetimes/slices.md -#, fuzzy -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." -msgstr "" -"Вопрос об изменении `a[3]` может породить интересную дискуссию, но ответ " -"заключается в том, что по соображениям безопасности памяти вы не можете " -"сделать это через `a` после создания среза, но можете безопасно читать " -"данные как из `a`, так и из `s`. Более подробная информация будет изложена в " -"разделе анализатора заимствований." - -#: src/slices-and-lifetimes/str.md -msgid "" -"We can now understand the two string types in Rust: `&str` is almost like " -"`&[char]`, but with its data stored in a variable-length encoding (UTF-8)." -msgstr "" - -#: src/slices-and-lifetimes/str.md -msgid "\"s1: {s1}\"" -msgstr "" - -#: src/slices-and-lifetimes/str.md -#, fuzzy -msgid "\"Hello \"" -msgstr "Привет, мир!" - -#: src/slices-and-lifetimes/str.md -msgid "\"s3: {s3}\"" -msgstr "" - -#: src/slices-and-lifetimes/str.md -msgid "Rust terminology:" -msgstr "Терминология Rust:" - -#: src/slices-and-lifetimes/str.md -msgid "`&str` an immutable reference to a string slice." -msgstr "`&str` --- неизменяемая ссылка на срез строки." - -#: src/slices-and-lifetimes/str.md -msgid "`String` a mutable string buffer." -msgstr "`String` --- изменяемый строковый буфер." - -#: src/slices-and-lifetimes/str.md -#, fuzzy -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 "" -"`&str` представляет срез строки, который является неизменяемой ссылкой на " -"строковые данные в кодировке UTF-8, хранящиеся в памяти. Строковые литералы " -"(`”Hello”`) хранятся в исполняемом файле программы." - -#: src/slices-and-lifetimes/str.md -msgid "" -"Rust’s `String` type is a wrapper around a vector of bytes. As with a " -"`Vec`, it is owned." -msgstr "Тип `String` в Rust --- это обертка вокруг вектора байтов." - -#: src/slices-and-lifetimes/str.md -#, fuzzy -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 "" -"Как и во многих других типах, `String::from()` создает строку из строкового " -"литерала; `String::new()` создает новую пустую строку, в которую строковые " -"данные могут быть добавлены с помощью методов `push()` и `push_str()`." - -#: src/slices-and-lifetimes/str.md -#, fuzzy -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 "" -"Макрос `format!()` --- это удобный способ сгенерировать строку из " -"динамических значений. Он принимает ту же строку формата, что и `println!()`." - -#: src/slices-and-lifetimes/str.md -msgid "" -"You can borrow `&str` slices from `String` via `&` and optionally range " -"selection. If you select a byte range that is not aligned to character " -"boundaries, the expression will panic. The `chars` iterator iterates over " -"characters and is preferred over trying to get character boundaries right." -msgstr "" - -#: src/slices-and-lifetimes/str.md -#, fuzzy -msgid "" -"For C++ programmers: think of `&str` as `std::string_view` 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 "" -"Для программистов на C++: думайте о `&str` как о `const char*` из C++, но " -"таком, который всегда указывает на корректную строку в памяти. `String` в " -"Rust --- это примерный эквивалент `std::string` из C++ (основное отличие: " -"она может содержать только байты в кодировке UTF-8 и не будет использовать " -"оптимизацию для небольших строк)." - -#: src/slices-and-lifetimes/str.md -#, fuzzy -msgid "Byte strings literals allow you to create a `&[u8]` value directly:" -msgstr "Байтовые строки позволяют создать значение `&[u8]`:" - -#: src/slices-and-lifetimes/lifetime-annotations.md +#: src/lifetimes/lifetime-annotations.md msgid "" "A reference has a _lifetime_, which must not \"outlive\" the value it refers " "to. This is verified by the borrow checker." msgstr "" -#: src/slices-and-lifetimes/lifetime-annotations.md +#: src/lifetimes/lifetime-annotations.md msgid "" "The lifetime can be implicit - this is what we have seen so far. Lifetimes " "can also be explicit: `&'a Point`, `&'document str`. Lifetimes start with " @@ -8433,56 +8519,56 @@ msgid "" "`Point` which is valid for at least the lifetime `a`\"." msgstr "" -#: src/slices-and-lifetimes/lifetime-annotations.md +#: src/lifetimes/lifetime-annotations.md msgid "" "Lifetimes are always inferred by the compiler: you cannot assign a lifetime " "yourself. Explicit lifetime annotations create constraints where there is " "ambiguity; the compiler verifies that there is a valid solution." msgstr "" -#: src/slices-and-lifetimes/lifetime-annotations.md +#: src/lifetimes/lifetime-annotations.md msgid "" "Lifetimes become more complicated when considering passing values to and " "returning values from functions." msgstr "" -#: src/slices-and-lifetimes/lifetime-annotations.md -msgid "// What is the lifetime of p3?\n" +#: src/lifetimes/lifetime-annotations.md +msgid "// What is the lifetime of p3?" msgstr "" -#: src/slices-and-lifetimes/lifetime-annotations.md +#: src/lifetimes/lifetime-annotations.md msgid "\"p3: {p3:?}\"" msgstr "" -#: src/slices-and-lifetimes/lifetime-annotations.md +#: src/lifetimes/lifetime-annotations.md msgid "" -"In this example, the the compiler does not know what lifetime to infer for " -"`p3`. Looking inside the function body shows that it can only safely assume " -"that `p3`'s lifetime is the shorter of `p1` and `p2`. But just like types, " -"Rust requires explicit annotations of lifetimes on function arguments and " -"return values." +"In this example, the compiler does not know what lifetime to infer for `p3`. " +"Looking inside the function body shows that it can only safely assume that " +"`p3`'s lifetime is the shorter of `p1` and `p2`. But just like types, Rust " +"requires explicit annotations of lifetimes on function arguments and return " +"values." msgstr "" -#: src/slices-and-lifetimes/lifetime-annotations.md +#: src/lifetimes/lifetime-annotations.md msgid "Add `'a` appropriately to `left_most`:" msgstr "" -#: src/slices-and-lifetimes/lifetime-annotations.md +#: src/lifetimes/lifetime-annotations.md msgid "" "This says, \"given p1 and p2 which both outlive `'a`, the return value lives " "for at least `'a`." msgstr "" -#: src/slices-and-lifetimes/lifetime-annotations.md +#: src/lifetimes/lifetime-annotations.md msgid "" "In common cases, lifetimes can be elided, as described on the next slide." msgstr "" -#: src/slices-and-lifetimes/lifetime-elision.md +#: src/lifetimes/lifetime-elision.md msgid "Lifetimes in Function Calls" msgstr "" -#: src/slices-and-lifetimes/lifetime-elision.md +#: src/lifetimes/lifetime-elision.md 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 " @@ -8490,44 +8576,44 @@ msgid "" "inference -- it is just a syntactic shorthand." msgstr "" -#: src/slices-and-lifetimes/lifetime-elision.md +#: src/lifetimes/lifetime-elision.md msgid "Each argument which does not have a lifetime annotation is given one." msgstr "" -#: src/slices-and-lifetimes/lifetime-elision.md +#: src/lifetimes/lifetime-elision.md msgid "" "If there is only one argument lifetime, it is given to all un-annotated " "return values." msgstr "" -#: src/slices-and-lifetimes/lifetime-elision.md +#: src/lifetimes/lifetime-elision.md msgid "" "If there are multiple argument lifetimes, but the first one is for `self`, " "that lifetime is given to all un-annotated return values." msgstr "" -#: src/slices-and-lifetimes/lifetime-elision.md +#: src/lifetimes/lifetime-elision.md msgid "In this example, `cab_distance` is trivially elided." msgstr "" -#: src/slices-and-lifetimes/lifetime-elision.md +#: src/lifetimes/lifetime-elision.md msgid "" "The `nearest` function provides another example of a function with multiple " "references in its arguments that requires explicit annotation." msgstr "" -#: src/slices-and-lifetimes/lifetime-elision.md +#: src/lifetimes/lifetime-elision.md msgid "Try adjusting the signature to \"lie\" about the lifetimes returned:" msgstr "" -#: src/slices-and-lifetimes/lifetime-elision.md +#: src/lifetimes/lifetime-elision.md msgid "" "This won't compile, demonstrating that the annotations are checked for " "validity by the compiler. Note that this is not the case for raw pointers " "(unsafe), and this is a common source of errors with unsafe Rust." msgstr "" -#: src/slices-and-lifetimes/lifetime-elision.md +#: src/lifetimes/lifetime-elision.md msgid "" "Students may ask when to use lifetimes. Rust borrows _always_ have " "lifetimes. Most of the time, elision and type inference mean these don't " @@ -8536,60 +8622,60 @@ msgid "" "just work with owned data by cloning values where necessary." msgstr "" -#: src/slices-and-lifetimes/struct-lifetimes.md +#: src/lifetimes/struct-lifetimes.md msgid "Lifetimes in Data Structures" msgstr "" -#: src/slices-and-lifetimes/struct-lifetimes.md +#: src/lifetimes/struct-lifetimes.md msgid "" "If a data type stores borrowed data, it must be annotated with a lifetime:" msgstr "" -#: src/slices-and-lifetimes/struct-lifetimes.md +#: src/lifetimes/struct-lifetimes.md msgid "\"Bye {text}!\"" msgstr "" -#: src/slices-and-lifetimes/struct-lifetimes.md +#: src/lifetimes/struct-lifetimes.md msgid "\"The quick brown fox jumps over the lazy dog.\"" msgstr "" -#: src/slices-and-lifetimes/struct-lifetimes.md -msgid "// erase(text);\n" +#: src/lifetimes/struct-lifetimes.md +msgid "// erase(text);" msgstr "" -#: src/slices-and-lifetimes/struct-lifetimes.md +#: src/lifetimes/struct-lifetimes.md msgid "\"{fox:?}\"" msgstr "" -#: src/slices-and-lifetimes/struct-lifetimes.md +#: src/lifetimes/struct-lifetimes.md msgid "\"{dog:?}\"" msgstr "" -#: src/slices-and-lifetimes/struct-lifetimes.md +#: src/lifetimes/struct-lifetimes.md 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/slices-and-lifetimes/struct-lifetimes.md +#: src/lifetimes/struct-lifetimes.md msgid "" "If `text` is consumed before the end of the lifetime of `fox` (or `dog`), " "the borrow checker throws an error." msgstr "" -#: src/slices-and-lifetimes/struct-lifetimes.md +#: src/lifetimes/struct-lifetimes.md 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/slices-and-lifetimes/struct-lifetimes.md +#: src/lifetimes/struct-lifetimes.md msgid "When possible, make data structures own their data directly." msgstr "" -#: src/slices-and-lifetimes/struct-lifetimes.md +#: src/lifetimes/struct-lifetimes.md 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 " @@ -8597,7 +8683,7 @@ msgid "" "of the struct itself. Those are very advanced use cases." msgstr "" -#: src/slices-and-lifetimes/exercise.md +#: src/lifetimes/exercise.md msgid "" "In this exercise, you will build a parser for the [protobuf binary encoding]" "(https://protobuf.dev/programming-guides/encoding/). Don't worry, it's " @@ -8605,7 +8691,7 @@ msgid "" "slices of data. The underlying data itself is never copied." msgstr "" -#: src/slices-and-lifetimes/exercise.md +#: src/lifetimes/exercise.md msgid "" "Fully parsing a protobuf message requires knowing the types of the fields, " "indexed by their field numbers. That is typically provided in a `proto` " @@ -8613,11 +8699,11 @@ msgid "" "statements in functions that get called for each field." msgstr "" -#: src/slices-and-lifetimes/exercise.md +#: src/lifetimes/exercise.md msgid "We'll use the following proto:" msgstr "" -#: src/slices-and-lifetimes/exercise.md +#: src/lifetimes/exercise.md msgid "" "A proto message is encoded as a series of fields, one after the next. Each " "is implemented as a \"tag\" followed by the value. The tag contains a field " @@ -8625,7 +8711,7 @@ msgid "" "defining how the payload should be determined from the byte stream." msgstr "" -#: src/slices-and-lifetimes/exercise.md +#: src/lifetimes/exercise.md msgid "" "Integers, including the tag, are represented with a variable-length encoding " "called VARINT. Luckily, `parse_varint` is defined for you below. The given " @@ -8633,45 +8719,45 @@ msgid "" "to parse a message into a series of calls to those callbacks." msgstr "" -#: src/slices-and-lifetimes/exercise.md +#: src/lifetimes/exercise.md msgid "" "What remains for you is to implement the `parse_field` function and the " "`ProtoMessage` trait for `Person` and `PhoneNumber`." msgstr "" -#: src/slices-and-lifetimes/exercise.md src/slices-and-lifetimes/solution.md +#: src/lifetimes/exercise.md src/lifetimes/solution.md msgid "\"Invalid varint\"" msgstr "" -#: src/slices-and-lifetimes/exercise.md src/slices-and-lifetimes/solution.md +#: src/lifetimes/exercise.md src/lifetimes/solution.md msgid "\"Invalid wire-type\"" msgstr "" -#: src/slices-and-lifetimes/exercise.md src/slices-and-lifetimes/solution.md +#: src/lifetimes/exercise.md src/lifetimes/solution.md msgid "\"Unexpected EOF\"" msgstr "" -#: src/slices-and-lifetimes/exercise.md src/slices-and-lifetimes/solution.md +#: src/lifetimes/exercise.md src/lifetimes/solution.md msgid "\"Invalid length\"" msgstr "" -#: src/slices-and-lifetimes/exercise.md src/slices-and-lifetimes/solution.md +#: src/lifetimes/exercise.md src/lifetimes/solution.md msgid "\"Unexpected wire-type)\"" msgstr "" -#: src/slices-and-lifetimes/exercise.md src/slices-and-lifetimes/solution.md +#: src/lifetimes/exercise.md src/lifetimes/solution.md msgid "\"Invalid string (not UTF-8)\"" msgstr "" -#: src/slices-and-lifetimes/exercise.md src/slices-and-lifetimes/solution.md +#: src/lifetimes/exercise.md src/lifetimes/solution.md msgid "/// A wire type as seen on the wire.\n" msgstr "" -#: src/slices-and-lifetimes/exercise.md src/slices-and-lifetimes/solution.md +#: src/lifetimes/exercise.md src/lifetimes/solution.md msgid "/// The Varint WireType indicates the value is a single VARINT.\n" msgstr "" -#: src/slices-and-lifetimes/exercise.md src/slices-and-lifetimes/solution.md +#: src/lifetimes/exercise.md src/lifetimes/solution.md msgid "" "//I64, -- not needed for this exercise\n" " /// The Len WireType indicates that the value is a length represented as " @@ -8679,62 +8765,62 @@ msgid "" " /// VARINT followed by exactly that number of bytes.\n" msgstr "" -#: src/slices-and-lifetimes/exercise.md src/slices-and-lifetimes/solution.md +#: src/lifetimes/exercise.md src/lifetimes/solution.md msgid "" "/// The I32 WireType indicates that the value is precisely 4 bytes in\n" " /// little-endian order containing a 32-bit signed integer.\n" msgstr "" -#: src/slices-and-lifetimes/exercise.md src/slices-and-lifetimes/solution.md +#: src/lifetimes/exercise.md src/lifetimes/solution.md msgid "/// A field's value, typed based on the wire type.\n" msgstr "" -#: src/slices-and-lifetimes/exercise.md src/slices-and-lifetimes/solution.md +#: src/lifetimes/exercise.md src/lifetimes/solution.md msgid "//I64(i64), -- not needed for this exercise\n" msgstr "" -#: src/slices-and-lifetimes/exercise.md src/slices-and-lifetimes/solution.md +#: src/lifetimes/exercise.md src/lifetimes/solution.md msgid "/// A field, containing the field number and its value.\n" msgstr "" -#: src/slices-and-lifetimes/exercise.md src/slices-and-lifetimes/solution.md +#: src/lifetimes/exercise.md src/lifetimes/solution.md msgid "//1 => WireType::I64, -- not needed for this exercise\n" msgstr "" -#: src/slices-and-lifetimes/exercise.md src/slices-and-lifetimes/solution.md +#: src/lifetimes/exercise.md src/lifetimes/solution.md msgid "" "/// Parse a VARINT, returning the parsed value and the remaining bytes.\n" msgstr "" -#: src/slices-and-lifetimes/exercise.md src/slices-and-lifetimes/solution.md +#: src/lifetimes/exercise.md src/lifetimes/solution.md msgid "" "// This is the last byte of the VARINT, so convert it to\n" " // a u64 and return it.\n" msgstr "" -#: src/slices-and-lifetimes/exercise.md src/slices-and-lifetimes/solution.md +#: src/lifetimes/exercise.md src/lifetimes/solution.md msgid "// More than 7 bytes is invalid.\n" msgstr "" -#: src/slices-and-lifetimes/exercise.md src/slices-and-lifetimes/solution.md +#: src/lifetimes/exercise.md src/lifetimes/solution.md msgid "/// Convert a tag into a field number and a WireType.\n" msgstr "" -#: src/slices-and-lifetimes/exercise.md src/slices-and-lifetimes/solution.md +#: src/lifetimes/exercise.md src/lifetimes/solution.md msgid "/// Parse a field, returning the remaining bytes\n" msgstr "" -#: src/slices-and-lifetimes/exercise.md +#: src/lifetimes/exercise.md msgid "" "\"Based on the wire type, build a Field, consuming as many bytes as " "necessary.\"" msgstr "" -#: src/slices-and-lifetimes/exercise.md +#: src/lifetimes/exercise.md msgid "\"Return the field, and any un-consumed bytes.\"" msgstr "" -#: src/slices-and-lifetimes/exercise.md src/slices-and-lifetimes/solution.md +#: src/lifetimes/exercise.md src/lifetimes/solution.md msgid "" "/// Parse a message in the given data, calling `T::add_field` for each field " "in\n" @@ -8743,19 +8829,19 @@ msgid "" "/// The entire input is consumed.\n" msgstr "" -#: src/slices-and-lifetimes/exercise.md -msgid "// TODO: Implement ProtoMessage for Person and PhoneNumber.\n" +#: src/lifetimes/exercise.md +msgid "// TODO: Implement ProtoMessage for Person and PhoneNumber." msgstr "" -#: src/slices-and-lifetimes/solution.md +#: src/lifetimes/solution.md msgid "// Unwrap error because `value` is definitely 4 bytes long.\n" msgstr "" -#: src/slices-and-lifetimes/solution.md +#: src/lifetimes/solution.md msgid "// skip everything else\n" msgstr "" -#: src/slices-and-lifetimes/solution.md +#: src/lifetimes/solution.md msgid "b\"hello\"" msgstr "" @@ -8803,7 +8889,16 @@ msgid "[Modules](./modules.md) (40 minutes)" msgstr "" #: src/welcome-day-4.md -msgid "[Testing](./testing.md) (1 hour and 5 minutes)" +#, fuzzy +msgid "[Testing](./testing.md) (45 minutes)" +msgstr "" +"Больше информации об использовании шаблонов в языке Rust можно найти на " +"[странице про сопоставление с шаблоном](../pattern-matching.md)." + +#: src/welcome-day-4.md +msgid "" +"Including 10 minute breaks, this session should take about 2 hours and 40 " +"minutes" msgstr "" #: src/iterators.md @@ -8823,6 +8918,10 @@ msgid "" "[Exercise: Iterator Method Chaining](./iterators/exercise.md) (30 minutes)" msgstr "" +#: src/iterators.md src/testing.md +msgid "This segment should take about 45 minutes" +msgstr "" + #: src/iterators/iterator.md msgid "" "The [`Iterator`](https://doc.rust-lang.org/std/iter/trait.Iterator.html) " @@ -8975,7 +9074,7 @@ msgid "" msgstr "" #: src/modules.md -msgid "[Modules](./modules/modules.md) (5 minutes)" +msgid "[Modules](./modules/modules.md) (3 minutes)" msgstr "" #: src/modules.md @@ -8995,10 +9094,6 @@ msgid "" "[Exercise: Modules for a GUI Library](./modules/exercise.md) (15 minutes)" msgstr "" -#: src/modules.md -msgid "This segment should take about 40 minutes" -msgstr "" - #: src/modules/modules.md msgid "We have seen how `impl` blocks let us namespace functions to a type." msgstr "" @@ -9065,20 +9160,23 @@ msgstr "" #: src/modules/filesystem.md msgid "" "//! This module implements the garden, including a highly performant " -"germination\n" -"//! implementation.\n" +"germination" msgstr "" #: src/modules/filesystem.md -msgid "// Re-export types from this module.\n" +msgid "//! implementation." msgstr "" #: src/modules/filesystem.md -msgid "/// Sow the given seed packets.\n" +msgid "// Re-export types from this module." msgstr "" #: src/modules/filesystem.md -msgid "/// Harvest the produce in the garden that is ready.\n" +msgid "/// Sow the given seed packets." +msgstr "" + +#: src/modules/filesystem.md +msgid "/// Harvest the produce in the garden that is ready." msgstr "" #: src/modules/filesystem.md @@ -9284,15 +9382,15 @@ msgstr "" msgid "Here's the single-module implementation of the GUI library:" msgstr "" -#: src/modules/exercise.md src/modules/solution.md +#: src/modules/exercise.md msgid "/// Natural width of `self`.\n" msgstr "" -#: src/modules/exercise.md src/modules/solution.md +#: src/modules/exercise.md msgid "/// Draw the widget into a buffer.\n" msgstr "" -#: src/modules/exercise.md src/modules/solution.md +#: src/modules/exercise.md msgid "/// Draw the widget on standard output.\n" msgstr "" @@ -9332,7 +9430,7 @@ msgstr "" msgid "\"| {:inner_width$} |\"" msgstr "" -#: src/modules/exercise.md src/modules/solution.md +#: src/modules/exercise.md msgid "// add a bit of padding\n" msgstr "" @@ -9364,68 +9462,91 @@ msgid "" msgstr "" #: src/modules/solution.md -msgid "// ---- src/widgets.rs ----\n" +msgid "// ---- src/widgets.rs ----" msgstr "" #: src/modules/solution.md -msgid "// ---- src/widgets/label.rs ----\n" +msgid "/// Natural width of `self`." msgstr "" #: src/modules/solution.md -msgid "// ANCHOR_END: Label-width\n" +msgid "/// Draw the widget into a buffer." msgstr "" #: src/modules/solution.md -msgid "// ANCHOR: Label-draw_into\n" +msgid "/// Draw the widget on standard output." msgstr "" #: src/modules/solution.md -msgid "// ANCHOR_END: Label-draw_into\n" +msgid "// ---- src/widgets/label.rs ----" msgstr "" #: src/modules/solution.md -msgid "// ---- src/widgets/button.rs ----\n" +msgid "// ANCHOR_END: Label-width" msgstr "" #: src/modules/solution.md -msgid "// ANCHOR_END: Button-width\n" +msgid "// ANCHOR: Label-draw_into" msgstr "" #: src/modules/solution.md -msgid "// ANCHOR: Button-draw_into\n" +msgid "// ANCHOR_END: Label-draw_into" msgstr "" #: src/modules/solution.md -msgid "// ANCHOR_END: Button-draw_into\n" +msgid "// ---- src/widgets/button.rs ----" msgstr "" #: src/modules/solution.md -msgid "// ---- src/widgets/window.rs ----\n" +msgid "// ANCHOR_END: Button-width" msgstr "" #: src/modules/solution.md -msgid "" -"// ANCHOR_END: Window-width\n" -" // Add 4 paddings for borders\n" +msgid "// add a bit of padding" msgstr "" #: src/modules/solution.md -msgid "// ANCHOR: Window-draw_into\n" +msgid "// ANCHOR: Button-draw_into" msgstr "" #: src/modules/solution.md -msgid "// ANCHOR_END: Window-draw_into\n" +msgid "// ANCHOR_END: Button-draw_into" msgstr "" #: src/modules/solution.md -msgid "" -"// TODO: after learning about error handling, you can change\n" -" // draw_into to return Result<(), std::fmt::Error>. Then use\n" -" // the ?-operator here instead of .unwrap().\n" +msgid "// ---- src/widgets/window.rs ----" msgstr "" #: src/modules/solution.md -msgid "// ---- src/main.rs ----\n" +msgid "// ANCHOR_END: Window-width" +msgstr "" + +#: src/modules/solution.md +msgid "// Add 4 paddings for borders" +msgstr "" + +#: src/modules/solution.md +msgid "// ANCHOR: Window-draw_into" +msgstr "" + +#: src/modules/solution.md +msgid "// ANCHOR_END: Window-draw_into" +msgstr "" + +#: src/modules/solution.md +msgid "// TODO: after learning about error handling, you can change" +msgstr "" + +#: src/modules/solution.md +msgid "// draw_into to return Result<(), std::fmt::Error>. Then use" +msgstr "" + +#: src/modules/solution.md +msgid "// the ?-operator here instead of .unwrap()." +msgstr "" + +#: src/modules/solution.md +msgid "// ---- src/main.rs ----" msgstr "" #: src/testing.md @@ -9433,23 +9554,11 @@ msgid "[Test Modules](./testing/unit-tests.md) (5 minutes)" msgstr "" #: src/testing.md -msgid "[Other Types of Tests](./testing/other.md) (10 minutes)" +msgid "[Other Types of Tests](./testing/other.md) (5 minutes)" msgstr "" #: src/testing.md -msgid "[Useful Crates](./testing/useful-crates.md) (3 minutes)" -msgstr "" - -#: src/testing.md -msgid "[GoogleTest](./testing/googletest.md) (5 minutes)" -msgstr "" - -#: src/testing.md -msgid "[Mocking](./testing/mocking.md) (5 minutes)" -msgstr "" - -#: src/testing.md -msgid "[Compiler Lints and Clippy](./testing/lints.md) (5 minutes)" +msgid "[Compiler Lints and Clippy](./testing/lints.md) (3 minutes)" msgstr "" #: src/testing.md @@ -9509,7 +9618,7 @@ msgid "Create a `.rs` file under `tests/`:" msgstr "" #: src/testing/other.md -msgid "// tests/my_library.rs\n" +msgid "// tests/my_library.rs" msgstr "" #: src/testing/other.md @@ -9525,14 +9634,23 @@ msgid "Rust has built-in support for documentation tests:" msgstr "" #: src/testing/other.md -msgid "" -"/// Shortens a string to the given length.\n" -"///\n" -"/// ```\n" -"/// # use playground::shorten_string;\n" -"/// assert_eq!(shorten_string(\"Hello World\", 5), \"Hello\");\n" -"/// assert_eq!(shorten_string(\"Hello World\", 20), \"Hello World\");\n" -"/// ```\n" +msgid "/// Shortens a string to the given length." +msgstr "" + +#: src/testing/other.md +msgid "/// ```" +msgstr "" + +#: src/testing/other.md +msgid "/// # use playground::shorten_string;" +msgstr "" + +#: src/testing/other.md +msgid "/// assert_eq!(shorten_string(\"Hello World\", 5), \"Hello\");" +msgstr "" + +#: src/testing/other.md +msgid "/// assert_eq!(shorten_string(\"Hello World\", 20), \"Hello World\");" msgstr "" #: src/testing/other.md @@ -9555,162 +9673,6 @@ msgid "" "version=stable&mode=debug&edition=2021&gist=3ce2ad13ea1302f6572cb15cd96becf0)." msgstr "" -#: src/testing/useful-crates.md -msgid "Rust comes with only basic support for writing tests." -msgstr "" - -#: src/testing/useful-crates.md -msgid "Here are some additional crates which we recommend for writing tests:" -msgstr "" - -#: src/testing/useful-crates.md -msgid "" -"[googletest](https://docs.rs/googletest): Comprehensive test assertion " -"library in the tradition of GoogleTest for C++." -msgstr "" - -#: src/testing/useful-crates.md -msgid "[proptest](https://docs.rs/proptest): Property-based testing for Rust." -msgstr "" - -#: src/testing/useful-crates.md -msgid "" -"[rstest](https://docs.rs/rstest): Support for fixtures and parameterised " -"tests." -msgstr "" - -#: src/testing/googletest.md -msgid "" -"The [GoogleTest](https://docs.rs/googletest/) crate allows for flexible test " -"assertions using _matchers_:" -msgstr "" - -#: src/testing/googletest.md -msgid "\"baz\"" -msgstr "" - -#: src/testing/googletest.md -msgid "\"xyz\"" -msgstr "" - -#: src/testing/googletest.md -msgid "" -"If we change the last element to `\"!\"`, the test fails with a structured " -"error message pin-pointing the error:" -msgstr "" - -#: src/testing/googletest.md -msgid "" -"GoogleTest is not part of the Rust Playground, so you need to run this " -"example in a local environment. Use `cargo add googletest` to quickly add it " -"to an existing Cargo project." -msgstr "" - -#: src/testing/googletest.md -msgid "" -"The `use googletest::prelude::*;` line imports a number of [commonly used " -"macros and types](https://docs.rs/googletest/latest/googletest/prelude/index." -"html)." -msgstr "" - -#: src/testing/googletest.md -msgid "This just scratches the surface, there are many builtin matchers." -msgstr "" - -#: src/testing/googletest.md -msgid "" -"A particularly nice feature is that mismatches in multi-line strings strings " -"are shown as a diff:" -msgstr "" - -#: src/testing/googletest.md -msgid "" -"\"Memory safety found,\\n\\\n" -" Rust's strong typing guides the way,\\n\\\n" -" Secure code you'll write.\"" -msgstr "" - -#: src/testing/googletest.md -msgid "" -"\"Memory safety found,\\n\\\n" -" Rust's silly humor guides the way,\\n\\\n" -" Secure code you'll write.\"" -msgstr "" - -#: src/testing/googletest.md -msgid "shows a color-coded diff (colors not shown here):" -msgstr "" - -#: src/testing/googletest.md -msgid "" -"The crate is a Rust port of [GoogleTest for C++](https://google.github.io/" -"googletest/)." -msgstr "" - -#: src/testing/googletest.md -msgid "GoogleTest is available for use in AOSP." -msgstr "" - -#: src/testing/mocking.md -msgid "" -"For mocking, [Mockall](https://docs.rs/mockall/) is a widely used library. " -"You need to refactor your code to use traits, which you can then quickly " -"mock:" -msgstr "" - -#: src/testing/mocking.md -msgid "" -"The advice here is for Android (AOSP) where Mockall is the recommended " -"mocking library. There are other [mocking libraries available on crates.io]" -"(https://crates.io/keywords/mock), in particular in the area of mocking HTTP " -"services. The other mocking libraries work in a similar fashion as Mockall, " -"meaning that they make it easy to get a mock implementation of a given trait." -msgstr "" - -#: src/testing/mocking.md -msgid "" -"Note that mocking is somewhat _controversial_: mocks allow you to completely " -"isolate a test from its dependencies. The immediate result is faster and " -"more stable test execution. On the other hand, the mocks can be configured " -"wrongly and return output different from what the real dependencies would do." -msgstr "" - -#: src/testing/mocking.md -msgid "" -"If at all possible, it is recommended that you use the real dependencies. As " -"an example, many databases allow you to configure an in-memory backend. This " -"means that you get the correct behavior in your tests, plus they are fast " -"and will automatically clean up after themselves." -msgstr "" - -#: src/testing/mocking.md -msgid "" -"Similarly, many web frameworks allow you to start an in-process server which " -"binds to a random port on `localhost`. Always prefer this over mocking away " -"the framework since it helps you test your code in the real environment." -msgstr "" - -#: src/testing/mocking.md -msgid "" -"Mockall is not part of the Rust Playground, so you need to run this example " -"in a local environment. Use `cargo add mockall` to quickly add Mockall to an " -"existing Cargo project." -msgstr "" - -#: src/testing/mocking.md -msgid "" -"Mockall has a lot more functionality. In particular, you can set up " -"expectations which depend on the arguments passed. Here we use this to mock " -"a cat which becomes hungry 3 hours after the last time it was fed:" -msgstr "" - -#: src/testing/mocking.md -msgid "" -"You can use `.times(n)` to limit the number of times a mock method can be " -"called to `n` --- the mock will automatically panic when dropped if this " -"isn't satisfied." -msgstr "" - #: src/testing/lints.md msgid "" "The Rust compiler produces fantastic error messages, as well as helpful " @@ -9754,7 +9716,7 @@ msgid "" msgstr "" #: src/testing/exercise.md -msgid "Ignore all spaces. Reject number with less than two digits." +msgid "Ignore all spaces. Reject number with fewer than two digits." msgstr "" #: src/testing/exercise.md @@ -9867,15 +9829,20 @@ msgid "\" 0 0 \"" msgstr "" #: src/welcome-day-4-afternoon.md -msgid "[Error Handling](./error-handling.md) (45 minutes)" +#, fuzzy +msgid "[Error Handling](./error-handling.md) (55 minutes)" msgstr "" +"Больше информации об использовании шаблонов в языке Rust можно найти на " +"[странице про сопоставление с шаблоном](../pattern-matching.md)." #: src/welcome-day-4-afternoon.md msgid "[Unsafe Rust](./unsafe-rust.md) (1 hour and 5 minutes)" msgstr "" #: src/welcome-day-4-afternoon.md -msgid "Including 10 minute breaks, this session should take about 2 hours" +msgid "" +"Including 10 minute breaks, this session should take about 2 hours and 10 " +"minutes" msgstr "" #: src/error-handling.md @@ -9901,7 +9868,7 @@ msgstr "" #: src/error-handling.md msgid "" -"[Exercise: Rewriting with Result](./error-handling/exercise.md) (20 minutes)" +"[Exercise: Rewriting with Result](./error-handling/exercise.md) (30 minutes)" msgstr "" #: src/error-handling/panics.md @@ -9998,7 +9965,7 @@ msgid "We can use this to simplify our error handling code:" msgstr "" #: src/error-handling/try.md -msgid "//fs::write(\"config.dat\", \"alice\").unwrap();\n" +msgid "//fs::write(\"config.dat\", \"alice\").unwrap();" msgstr "" #: src/error-handling/try.md src/error-handling/try-conversions.md @@ -10027,7 +9994,7 @@ msgstr "" #: src/error-handling/try.md msgid "" "Note that `main` can return a `Result<(), E>` as long as it implements `std::" -"process:Termination`. In practice, this means that `E` implements `Debug`. " +"process::Termination`. In practice, this means that `E` implements `Debug`. " "The executable will print the `Err` variant and return a nonzero exit status " "on error." msgstr "" @@ -10059,7 +10026,7 @@ msgstr "" #: src/error-handling/try-conversions.md #: src/error-handling/thiserror-and-anyhow.md -msgid "//fs::write(\"config.dat\", \"\").unwrap();\n" +msgid "//fs::write(\"config.dat\", \"\").unwrap();" msgstr "" #: src/error-handling/try-conversions.md @@ -10276,10 +10243,6 @@ msgstr "" msgid "/// A binary operation.\n" msgstr "" -#: src/error-handling/exercise.md src/error-handling/solution.md -msgid "'z'" -msgstr "" - #: src/error-handling/exercise.md src/error-handling/solution.md msgid "'_'" msgstr "" @@ -10365,6 +10328,10 @@ msgstr "" msgid "[Exercise: FFI Wrapper](./unsafe-rust/exercise.md) (30 minutes)" msgstr "" +#: src/unsafe-rust.md +msgid "This segment should take about 1 hour and 5 minutes" +msgstr "" + #: src/unsafe-rust/unsafe.md msgid "The Rust language has two parts:" msgstr "" @@ -10438,14 +10405,25 @@ msgstr "" msgid "\"careful!\"" msgstr "" +#: src/unsafe-rust/dereferencing.md +msgid "// Safe because r1 and r2 were obtained from references and so are" +msgstr "" + #: src/unsafe-rust/dereferencing.md msgid "" -"// Safe because r1 and r2 were obtained from references and so are\n" -" // guaranteed to be non-null and properly aligned, the objects " -"underlying\n" -" // the references from which they were obtained are live throughout the\n" -" // whole unsafe block, and they are not accessed either through the\n" -" // references or concurrently through any other pointers.\n" +"// guaranteed to be non-null and properly aligned, the objects underlying" +msgstr "" + +#: src/unsafe-rust/dereferencing.md +msgid "// the references from which they were obtained are live throughout the" +msgstr "" + +#: src/unsafe-rust/dereferencing.md +msgid "// whole unsafe block, and they are not accessed either through the" +msgstr "" + +#: src/unsafe-rust/dereferencing.md +msgid "// references or concurrently through any other pointers." msgstr "" #: src/unsafe-rust/dereferencing.md @@ -10461,13 +10439,11 @@ msgid "\"r2 is: {}\"" msgstr "" #: src/unsafe-rust/dereferencing.md -msgid "" -"// NOT SAFE. DO NOT DO THIS.\n" -" /*\n" -" let r3: &String = unsafe { &*r1 };\n" -" drop(s);\n" -" println!(\"r3 is: {}\", *r3);\n" -" */" +msgid "// NOT SAFE. DO NOT DO THIS." +msgstr "" + +#: src/unsafe-rust/dereferencing.md +msgid "/*" msgstr "" #: src/unsafe-rust/dereferencing.md @@ -10570,7 +10546,7 @@ msgstr "" #: src/unsafe-rust/unions.md #, fuzzy -msgid "// Undefined behavior!\n" +msgid "// Undefined behavior!" msgstr "Отсутствие неопределенного поведения во время выполнения:" #: src/unsafe-rust/unions.md @@ -10603,7 +10579,6 @@ msgstr "" #: src/android/interoperability/cpp/cpp-bridge.md #: src/exercises/chromium/build-rules.md src/bare-metal/aps/inline-assembly.md #: src/bare-metal/aps/better-uart/using.md src/bare-metal/aps/logging/using.md -#: src/exercises/bare-metal/rtc.md #: src/exercises/bare-metal/solutions-afternoon.md msgid "\"C\"" msgstr "" @@ -10614,8 +10589,11 @@ msgstr "" #: src/unsafe-rust/unsafe-functions.md msgid "" -"// Safe because the indices are in the correct order, within the bounds of\n" -" // the string slice, and lie on UTF-8 sequence boundaries.\n" +"// Safe because the indices are in the correct order, within the bounds of" +msgstr "" + +#: src/unsafe-rust/unsafe-functions.md +msgid "// the string slice, and lie on UTF-8 sequence boundaries." msgstr "" #: src/unsafe-rust/unsafe-functions.md @@ -10628,7 +10606,7 @@ msgstr "" #: src/unsafe-rust/unsafe-functions.md #, fuzzy -msgid "// Undefined behavior if abs misbehaves.\n" +msgid "// Undefined behavior if abs misbehaves." msgstr "Отсутствие неопределенного поведения во время выполнения:" #: src/unsafe-rust/unsafe-functions.md @@ -10636,11 +10614,19 @@ msgid "\"Absolute value of -3 according to C: {}\"" msgstr "" #: src/unsafe-rust/unsafe-functions.md -msgid "" -"// Not upholding the UTF-8 encoding requirement breaks memory safety!\n" -" // println!(\"emoji: {}\", unsafe { emojis.get_unchecked(0..3) });\n" -" // println!(\"char count: {}\", count_chars(unsafe {\n" -" // emojis.get_unchecked(0..3) }));\n" +msgid "// Not upholding the UTF-8 encoding requirement breaks memory safety!" +msgstr "" + +#: src/unsafe-rust/unsafe-functions.md +msgid "// println!(\"emoji: {}\", unsafe { emojis.get_unchecked(0..3) });" +msgstr "" + +#: src/unsafe-rust/unsafe-functions.md +msgid "// println!(\"char count: {}\", count_chars(unsafe {" +msgstr "" + +#: src/unsafe-rust/unsafe-functions.md +msgid "// emojis.get_unchecked(0..3) }));" msgstr "" #: src/unsafe-rust/unsafe-functions.md @@ -10654,16 +10640,19 @@ msgid "" msgstr "" #: src/unsafe-rust/unsafe-functions.md -msgid "" -"/// Swaps the values pointed to by the given pointers.\n" -"///\n" -"/// # Safety\n" -"///\n" -"/// The pointers must be valid and properly aligned.\n" +msgid "/// Swaps the values pointed to by the given pointers." +msgstr "" + +#: src/unsafe-rust/unsafe-functions.md src/unsafe-rust/unsafe-traits.md +msgid "/// # Safety" msgstr "" #: src/unsafe-rust/unsafe-functions.md -msgid "// Safe because ...\n" +msgid "/// The pointers must be valid and properly aligned." +msgstr "" + +#: src/unsafe-rust/unsafe-functions.md +msgid "// Safe because ..." msgstr "" #: src/unsafe-rust/unsafe-functions.md @@ -10717,14 +10706,15 @@ msgid "" msgstr "" #: src/unsafe-rust/unsafe-traits.md -msgid "" -"/// ...\n" -"/// # Safety\n" -"/// The type must have a defined representation and no padding.\n" +msgid "/// ..." msgstr "" #: src/unsafe-rust/unsafe-traits.md -msgid "// Safe because u32 has a defined representation and no padding.\n" +msgid "/// The type must have a defined representation and no padding." +msgstr "" + +#: src/unsafe-rust/unsafe-traits.md +msgid "// Safe because u32 has a defined representation and no padding." msgstr "" #: src/unsafe-rust/unsafe-traits.md @@ -10915,18 +10905,18 @@ msgstr "" msgid "\"readdir$INODE64\"" msgstr "" -#: src/unsafe-rust/exercise.md src/unsafe-rust/solution.md +#: src/unsafe-rust/exercise.md msgid "" "// Call opendir and return a Ok value if that worked,\n" -" // otherwise return Err with a message.\n" +" // otherwise return Err with a message." msgstr "" #: src/unsafe-rust/exercise.md -msgid "// Keep calling readdir until we get a NULL pointer back.\n" +msgid "// Keep calling readdir until we get a NULL pointer back." msgstr "" -#: src/unsafe-rust/exercise.md src/unsafe-rust/solution.md -msgid "// Call closedir as needed.\n" +#: src/unsafe-rust/exercise.md +msgid "// Call closedir as needed." msgstr "" #: src/unsafe-rust/exercise.md src/unsafe-rust/solution.md @@ -10938,6 +10928,12 @@ msgstr "" msgid "\"files: {:#?}\"" msgstr "" +#: src/unsafe-rust/solution.md +msgid "" +"// Call opendir and return a Ok value if that worked,\n" +" // otherwise return Err with a message.\n" +msgstr "" + #: src/unsafe-rust/solution.md msgid "\"Invalid path: {err}\"" msgstr "" @@ -10966,6 +10962,10 @@ msgid "" " // terminated.\n" msgstr "" +#: src/unsafe-rust/solution.md +msgid "// Call closedir as needed.\n" +msgstr "" + #: src/unsafe-rust/solution.md msgid "// SAFETY: self.dir is not NULL.\n" msgstr "" @@ -11304,7 +11304,8 @@ msgstr "" msgid "\"greetings\"" msgstr "" -#: src/android/build-rules/library.md src/android/aidl/implementation.md +#: src/android/build-rules/library.md +#: src/android/aidl/example-service/service.md src/android/testing.md #: src/android/interoperability/java.md msgid "\"src/lib.rs\"" msgstr "" @@ -11353,139 +11354,241 @@ msgstr "" msgid "You can create new AIDL servers in Rust." msgstr "" -#: src/android/aidl/interface.md +#: src/android/aidl/birthday-service.md +msgid "" +"To illustrate how to use Rust with Binder, we're going to walk through the " +"process of creating a Binder interface. We're then going to both implement " +"the described service and write client code that talks to that service." +msgstr "" + +#: src/android/aidl/example-service/interface.md msgid "AIDL Interfaces" msgstr "" -#: src/android/aidl/interface.md +#: src/android/aidl/example-service/interface.md msgid "You declare the API of your service using an AIDL interface:" msgstr "" -#: src/android/aidl/interface.md +#: src/android/aidl/example-service/interface.md +#: src/android/aidl/example-service/service-bindings.md msgid "" "_birthday_service/aidl/com/example/birthdayservice/IBirthdayService.aidl_:" msgstr "" -#: src/android/aidl/interface.md src/android/aidl/changing.md +#: src/android/aidl/example-service/interface.md +#: src/android/aidl/example-service/service-bindings.md +#: src/android/aidl/example-service/changing-definition.md msgid "/** Birthday service interface. */" msgstr "" -#: src/android/aidl/interface.md src/android/aidl/changing.md +#: src/android/aidl/example-service/interface.md +#: src/android/aidl/example-service/service-bindings.md +#: src/android/aidl/example-service/changing-definition.md msgid "/** Generate a Happy Birthday message. */" msgstr "" -#: src/android/aidl/interface.md +#: src/android/aidl/example-service/interface.md msgid "_birthday_service/aidl/Android.bp_:" msgstr "" -#: src/android/aidl/interface.md +#: src/android/aidl/example-service/interface.md msgid "\"com.example.birthdayservice\"" msgstr "" -#: src/android/aidl/interface.md +#: src/android/aidl/example-service/interface.md msgid "\"com/example/birthdayservice/*.aidl\"" msgstr "" -#: src/android/aidl/interface.md +#: src/android/aidl/example-service/interface.md msgid "// Rust is not enabled by default\n" msgstr "" -#: src/android/aidl/interface.md +#: src/android/aidl/example-service/interface.md msgid "" -"Add `vendor_available: true` if your AIDL file is used by a binary in the " -"vendor partition." +"Note that the directory structure under the `aidl/` directory needs to match " +"the package name used in the AIDL file, i.e. the package is `com.example." +"birthdayservice` and the file is at `aidl/com/example/IBirthdayService.aidl`." msgstr "" -#: src/android/aidl/implementation.md +#: src/android/aidl/example-service/service-bindings.md +msgid "Generated Service API" +msgstr "" + +#: src/android/aidl/example-service/service-bindings.md +msgid "" +"Binder generates a trait corresponding to the interface definition. trait to " +"talk to the service." +msgstr "" + +#: src/android/aidl/example-service/service-bindings.md +msgid "_Generated trait_:" +msgstr "" + +#: src/android/aidl/example-service/service-bindings.md +msgid "" +"Your service will need to implement this trait, and your client will use " +"this trait to talk to the service." +msgstr "" + +#: src/android/aidl/example-service/service-bindings.md +msgid "" +"The generated bindings can be found at `out/soong/.intermediates//`." +msgstr "" + +#: src/android/aidl/example-service/service-bindings.md +msgid "" +"Point out how the generated function signature, specifically the argument " +"and return types, correspond the interface definition." +msgstr "" + +#: src/android/aidl/example-service/service-bindings.md +msgid "" +"`String` for an argument results in a different Rust type than `String` as a " +"return type." +msgstr "" + +#: src/android/aidl/example-service/service.md msgid "Service Implementation" msgstr "" -#: src/android/aidl/implementation.md +#: src/android/aidl/example-service/service.md msgid "We can now implement the AIDL service:" msgstr "" -#: src/android/aidl/implementation.md +#: src/android/aidl/example-service/service.md +#: src/android/aidl/example-service/changing-implementation.md msgid "_birthday_service/src/lib.rs_:" msgstr "" -#: src/android/aidl/implementation.md -msgid "//! Implementation of the `IBirthdayService` AIDL interface.\n" -msgstr "" - -#: src/android/aidl/implementation.md +#: src/android/aidl/example-service/service.md msgid "/// The `IBirthdayService` implementation.\n" msgstr "" -#: src/android/aidl/implementation.md +#: src/android/aidl/example-service/service.md +#: src/android/aidl/example-service/changing-implementation.md +#: src/android/aidl/types/file-descriptor.md msgid "\"Happy Birthday {name}, congratulations with the {years} years!\"" msgstr "" -#: src/android/aidl/implementation.md src/android/aidl/server.md -#: src/android/aidl/client.md +#: src/android/aidl/example-service/service.md +#: src/android/aidl/example-service/server.md +#: src/android/aidl/example-service/client.md msgid "_birthday_service/Android.bp_:" msgstr "" -#: src/android/aidl/implementation.md src/android/aidl/server.md +#: src/android/aidl/example-service/service.md +#: src/android/aidl/example-service/server.md msgid "\"libbirthdayservice\"" msgstr "" -#: src/android/aidl/implementation.md src/android/aidl/server.md -#: src/android/aidl/client.md +#: src/android/aidl/example-service/service.md +#: src/android/aidl/example-service/server.md +#: src/android/aidl/example-service/client.md msgid "\"birthdayservice\"" msgstr "" -#: src/android/aidl/implementation.md src/android/aidl/server.md -#: src/android/aidl/client.md +#: src/android/aidl/example-service/service.md +#: src/android/aidl/example-service/server.md +#: src/android/aidl/example-service/client.md msgid "\"com.example.birthdayservice-rust\"" msgstr "" -#: src/android/aidl/implementation.md src/android/aidl/server.md -#: src/android/aidl/client.md +#: src/android/aidl/example-service/service.md +#: src/android/aidl/example-service/server.md +#: src/android/aidl/example-service/client.md msgid "\"libbinder_rs\"" msgstr "" -#: src/android/aidl/server.md +#: src/android/aidl/example-service/service.md +msgid "" +"Point out the path to the generated `IBirthdayService` trait, and explain " +"why each of the segments is necessary." +msgstr "" + +#: src/android/aidl/example-service/service.md +msgid "" +"TODO: What does the `binder::Interface` trait do? Are there methods to " +"override? Where source?" +msgstr "" + +#: src/android/aidl/example-service/server.md msgid "AIDL Server" msgstr "" -#: src/android/aidl/server.md +#: src/android/aidl/example-service/server.md msgid "Finally, we can create a server which exposes the service:" msgstr "" -#: src/android/aidl/server.md +#: src/android/aidl/example-service/server.md msgid "_birthday_service/src/server.rs_:" msgstr "" -#: src/android/aidl/server.md src/android/aidl/client.md +#: src/android/aidl/example-service/server.md msgid "//! Birthday service.\n" msgstr "" -#: src/android/aidl/server.md +#: src/android/aidl/example-service/server.md msgid "/// Entry point for birthday service.\n" msgstr "" -#: src/android/aidl/server.md +#: src/android/aidl/example-service/server.md msgid "\"Failed to register service\"" msgstr "" -#: src/android/aidl/server.md +#: src/android/aidl/example-service/server.md msgid "\"birthday_server\"" msgstr "" -#: src/android/aidl/server.md +#: src/android/aidl/example-service/server.md #, fuzzy msgid "\"src/server.rs\"" msgstr "серверы." -#: src/android/aidl/server.md src/android/aidl/client.md +#: src/android/aidl/example-service/server.md +#: src/android/aidl/example-service/client.md msgid "// To avoid dynamic link error.\n" msgstr "" -#: src/android/aidl/deploy.md +#: src/android/aidl/example-service/server.md +msgid "" +"The process for taking a user-defined service implementation (in this case " +"the `BirthdayService` type, which implements the `IBirthdayService`) and " +"starting it as a Binder service has multiple steps, and may appear more " +"complicated than students are used to if they've used Binder from C++ or " +"another language. Explain to students why each step is necessary." +msgstr "" + +#: src/android/aidl/example-service/server.md +msgid "Create an instance of your service type (`BirthdayService`)." +msgstr "" + +#: src/android/aidl/example-service/server.md +msgid "" +"Wrap the service object in corresponding `Bn*` type (`BnBirthdayService` in " +"this case). This type is generated by Binder and provides the common Binder " +"functionality that would be provided by the `BnBinder` base class in C++. We " +"don't have inheritance in Rust, so instead we use composition, putting our " +"`BirthdayService` within the generated `BnBinderService`." +msgstr "" + +#: src/android/aidl/example-service/server.md +msgid "" +"Call `add_service`, giving it a service identifier and your service object " +"(the `BnBirthdayService` object in the example)." +msgstr "" + +#: src/android/aidl/example-service/server.md +msgid "" +"Call `join_thread_pool` to add the current thread to Binder's thread pool " +"and start listening for connections." +msgstr "" + +#: src/android/aidl/example-service/deploy.md msgid "We can now build, push, and start the service:" msgstr "" -#: src/android/aidl/deploy.md +#: src/android/aidl/example-service/deploy.md msgid "" "```shell\n" "m birthday_server\n" @@ -11496,59 +11599,62 @@ msgid "" "```" msgstr "" -#: src/android/aidl/deploy.md +#: src/android/aidl/example-service/deploy.md msgid "In another terminal, check that the service runs:" msgstr "" -#: src/android/aidl/deploy.md +#: src/android/aidl/example-service/deploy.md msgid "You can also call the service with `service call`:" msgstr "" -#: src/android/aidl/client.md +#: src/android/aidl/example-service/client.md msgid "AIDL Client" msgstr "" -#: src/android/aidl/client.md +#: src/android/aidl/example-service/client.md msgid "Finally, we can create a Rust client for our new service." msgstr "" -#: src/android/aidl/client.md +#: src/android/aidl/example-service/client.md +#: src/android/aidl/example-service/changing-implementation.md msgid "_birthday_service/src/client.rs_:" msgstr "" -#: src/android/aidl/client.md -msgid "/// Connect to the BirthdayService.\n" -msgstr "" - -#: src/android/aidl/client.md +#: src/android/aidl/example-service/client.md msgid "/// Call the birthday service.\n" msgstr "" -#: src/android/aidl/client.md +#: src/android/aidl/example-service/client.md src/android/aidl/types/objects.md +#: src/android/aidl/types/parcelables.md +#: src/android/aidl/types/file-descriptor.md msgid "\"Failed to connect to BirthdayService\"" msgstr "" -#: src/android/aidl/client.md +#: src/android/aidl/example-service/client.md +msgid "// Call the service.\n" +msgstr "" + +#: src/android/aidl/example-service/client.md msgid "\"{msg}\"" msgstr "" -#: src/android/aidl/client.md +#: src/android/aidl/example-service/client.md msgid "\"birthday_client\"" msgstr "" -#: src/android/aidl/client.md +#: src/android/aidl/example-service/client.md msgid "\"src/client.rs\"" msgstr "" -#: src/android/aidl/client.md +#: src/android/aidl/example-service/client.md msgid "Notice that the client does not depend on `libbirthdayservice`." msgstr "" -#: src/android/aidl/client.md +#: src/android/aidl/example-service/client.md msgid "Build, push, and run the client on your device:" msgstr "" -#: src/android/aidl/client.md +#: src/android/aidl/example-service/client.md msgid "" "```shell\n" "m birthday_client\n" @@ -11558,12 +11664,578 @@ msgid "" "```" msgstr "" -#: src/android/aidl/changing.md +#: src/android/aidl/example-service/client.md +msgid "" +"`Strong` is the trait object representing the service " +"that the client has connected to." +msgstr "" + +#: src/android/aidl/example-service/client.md +msgid "" +"`Strong` is a custom smart pointer type for Binder. It handles both an in-" +"process ref count for the service trait object, and the global Binder ref " +"count that tracks how many processes have a reference to the object." +msgstr "" + +#: src/android/aidl/example-service/client.md +msgid "" +"Note that the trait object that the client uses to talk to the service uses " +"the exact same trait that the server implements. For a given Binder " +"interface, there is a single Rust trait generated that both client and " +"server use." +msgstr "" + +#: src/android/aidl/example-service/client.md +msgid "" +"Use the same service identifier used when registering the service. This " +"should ideally be defined in a common crate that both the client and server " +"can depend on." +msgstr "" + +#: src/android/aidl/example-service/changing-definition.md msgid "" "Let us extend the API with more functionality: we want to let clients " "specify a list of lines for the birthday card:" msgstr "" +#: src/android/aidl/example-service/changing-definition.md +msgid "This results in an updated trait definition for `IBirthdayService`:" +msgstr "" + +#: src/android/aidl/example-service/changing-definition.md +msgid "" +"Note how the `String[]` in the AIDL definition is translated as a " +"`&[String]` in Rust, i.e. that idiomatic Rust types are used in the " +"generated bindings wherever possible:" +msgstr "" + +#: src/android/aidl/example-service/changing-definition.md +msgid "`in` array arguments are translated to slices." +msgstr "" + +#: src/android/aidl/example-service/changing-definition.md +msgid "`out` and `inout` args are translated to `&mut Vec`." +msgstr "" + +#: src/android/aidl/example-service/changing-definition.md +msgid "Return values are translated to returning a `Vec`." +msgstr "" + +#: src/android/aidl/example-service/changing-implementation.md +msgid "Updating Client and Service" +msgstr "" + +#: src/android/aidl/example-service/changing-implementation.md +msgid "Update the client and server code to account for the new API." +msgstr "" + +#: src/android/aidl/example-service/changing-implementation.md +msgid "'\\n'" +msgstr "" + +#: src/android/aidl/example-service/changing-implementation.md +msgid "\"Habby birfday to yuuuuu\"" +msgstr "" + +#: src/android/aidl/example-service/changing-implementation.md +msgid "\"And also: many more\"" +msgstr "" + +#: src/android/aidl/example-service/changing-implementation.md +msgid "" +"TODO: Move code snippets into project files where they'll actually be built?" +msgstr "" + +#: src/android/aidl/types.md +msgid "Working With AIDL Types" +msgstr "" + +#: src/android/aidl/types.md +msgid "AIDL types translate into the appropriate idiomatic Rust type:" +msgstr "" + +#: src/android/aidl/types.md +msgid "Primitive types map (mostly) to idiomatic Rust types." +msgstr "" + +#: src/android/aidl/types.md +msgid "Collection types like slices, `Vec`s and string types are supported." +msgstr "" + +#: src/android/aidl/types.md +msgid "" +"References to AIDL objects and file handles can be sent between clients and " +"services." +msgstr "" + +#: src/android/aidl/types.md +msgid "File handles and parcelables are fully supported." +msgstr "" + +#: src/android/aidl/types/primitives.md +msgid "Primitive types map (mostly) idiomatically:" +msgstr "" + +#: src/android/aidl/types/primitives.md +msgid "AIDL Type" +msgstr "" + +#: src/android/aidl/types/primitives.md src/android/aidl/types/arrays.md +#: src/android/interoperability/cpp/type-mapping.md +#, fuzzy +msgid "Rust Type" +msgstr "Экосистема Rust" + +#: src/android/aidl/types/primitives.md +msgid "Note" +msgstr "" + +#: src/android/aidl/types/primitives.md +#, fuzzy +msgid "`boolean`" +msgstr "`bool`" + +#: src/android/aidl/types/primitives.md +msgid "`byte`" +msgstr "" + +#: src/android/aidl/types/primitives.md +msgid "`i8`" +msgstr "" + +#: src/android/aidl/types/primitives.md +msgid "Note that bytes are signed." +msgstr "" + +#: src/android/aidl/types/primitives.md +msgid "`u16`" +msgstr "" + +#: src/android/aidl/types/primitives.md +msgid "Note the usage of `u16`, NOT `u32`." +msgstr "" + +#: src/android/aidl/types/primitives.md +msgid "`int`" +msgstr "" + +#: src/android/aidl/types/primitives.md +msgid "`i32`" +msgstr "" + +#: src/android/aidl/types/primitives.md +msgid "`long`" +msgstr "" + +#: src/android/aidl/types/primitives.md +msgid "`i64`" +msgstr "" + +#: src/android/aidl/types/primitives.md +msgid "`float`" +msgstr "" + +#: src/android/aidl/types/primitives.md +msgid "`f32`" +msgstr "" + +#: src/android/aidl/types/primitives.md +msgid "`double`" +msgstr "" + +#: src/android/aidl/types/primitives.md +msgid "`f64`" +msgstr "" + +#: src/android/aidl/types/arrays.md +msgid "" +"The array types (`T[]`, `byte[]`, and `List`) get translated to the " +"appropriate Rust array type depending on how they are used in the function " +"signature:" +msgstr "" + +#: src/android/aidl/types/arrays.md +msgid "Position" +msgstr "" + +#: src/android/aidl/types/arrays.md +msgid "`in` argument" +msgstr "" + +#: src/android/aidl/types/arrays.md +#, fuzzy +msgid "`&[T]`" +msgstr "Срезы" + +#: src/android/aidl/types/arrays.md +msgid "`out`/`inout` argument" +msgstr "" + +#: src/android/aidl/types/arrays.md +msgid "`&mut Vec`" +msgstr "" + +#: src/android/aidl/types/arrays.md +msgid "Return" +msgstr "" + +#: src/android/aidl/types/arrays.md +#: src/android/interoperability/cpp/type-mapping.md +msgid "`Vec`" +msgstr "" + +#: src/android/aidl/types/arrays.md +msgid "" +"In Android 13 or higher, fixed-size arrays are supported, i.e. `T[N]` " +"becomes `[T; N]`. Fixed-size arrays can have multiple dimensions (e.g. " +"int\\[3\\]\\[4\\]). In the Java backend, fixed-size arrays are represented " +"as array types." +msgstr "" + +#: src/android/aidl/types/arrays.md +msgid "Arrays in parcelable fields always get translated to `Vec`." +msgstr "" + +#: src/android/aidl/types/objects.md +msgid "" +"AIDL objects can be sent either as a concrete AIDL type or as the type-" +"erased `IBinder` interface:" +msgstr "" + +#: src/android/aidl/types/objects.md +msgid "" +"**birthday_service/aidl/com/example/birthdayservice/IBirthdayInfoProvider." +"aidl**:" +msgstr "" + +#: src/android/aidl/types/objects.md src/android/aidl/types/parcelables.md +#: src/android/aidl/types/file-descriptor.md +msgid "" +"**birthday_service/aidl/com/example/birthdayservice/IBirthdayService.aidl**:" +msgstr "" + +#: src/android/aidl/types/objects.md +msgid "/** The same thing, but using a binder object. */" +msgstr "" + +#: src/android/aidl/types/objects.md +msgid "/** The same thing, but using `IBinder`. */" +msgstr "" + +#: src/android/aidl/types/objects.md src/android/aidl/types/parcelables.md +#: src/android/aidl/types/file-descriptor.md +msgid "**birthday_service/src/client.rs**:" +msgstr "" + +#: src/android/aidl/types/objects.md +msgid "/// Rust struct implementing the `IBirthdayInfoProvider` interface.\n" +msgstr "" + +#: src/android/aidl/types/objects.md +msgid "// Create a binder object for the `IBirthdayInfoProvider` interface.\n" +msgstr "" + +#: src/android/aidl/types/objects.md +msgid "// Send the binder object to the service.\n" +msgstr "" + +#: src/android/aidl/types/objects.md +msgid "" +"// Perform the same operation but passing the provider as an `SpIBinder`.\n" +msgstr "" + +#: src/android/aidl/types/objects.md +msgid "" +"Note the usage of `BnBirthdayInfoProvider`. This serves the same purpose as " +"`BnBirthdayService` that we saw previously." +msgstr "" + +#: src/android/aidl/types/parcelables.md +msgid "Binder for Rust supports sending parcelables directly:" +msgstr "" + +#: src/android/aidl/types/parcelables.md +msgid "" +"**birthday_service/aidl/com/example/birthdayservice/BirthdayInfo.aidl**:" +msgstr "" + +#: src/android/aidl/types/parcelables.md +msgid "/** The same thing, but with a parcelable. */" +msgstr "" + +#: src/android/aidl/types/file-descriptor.md +msgid "" +"Files can be sent between Binder clients/servers using the " +"`ParcelFileDescriptor` type:" +msgstr "" + +#: src/android/aidl/types/file-descriptor.md +msgid "/** The same thing, but loads info from a file. */" +msgstr "" + +#: src/android/aidl/types/file-descriptor.md +msgid "// Open a file and put the birthday info in it.\n" +msgstr "" + +#: src/android/aidl/types/file-descriptor.md +msgid "\"/data/local/tmp/birthday.info\"" +msgstr "" + +#: src/android/aidl/types/file-descriptor.md +msgid "\"{name}\"" +msgstr "" + +#: src/android/aidl/types/file-descriptor.md +msgid "\"{years}\"" +msgstr "" + +#: src/android/aidl/types/file-descriptor.md +msgid "// Create a `ParcelFileDescriptor` from the file and send it.\n" +msgstr "" + +#: src/android/aidl/types/file-descriptor.md +msgid "**birthday_service/src/lib.rs**:" +msgstr "" + +#: src/android/aidl/types/file-descriptor.md +msgid "" +"// Convert the file descriptor to a `File`. `ParcelFileDescriptor` wraps\n" +" // an `OwnedFd`, which can be cloned and then used to create a " +"`File`\n" +" // object.\n" +msgstr "" + +#: src/android/aidl/types/file-descriptor.md +msgid "\"Invalid file handle\"" +msgstr "" + +#: src/android/aidl/types/file-descriptor.md +msgid "" +"`ParcelFileDescriptor` wraps an `OwnedFd`, and so can be created from a " +"`File` (or any other type that wraps an `OwnedFd`), and can be used to " +"create a new `File` handle on the other side." +msgstr "" + +#: src/android/aidl/types/file-descriptor.md +msgid "" +"Other types of file descriptors can be wrapped and sent, e.g. TCP, UDP, and " +"UNIX sockets." +msgstr "" + +#: src/android/testing.md +msgid "Testing in Android" +msgstr "" + +#: src/android/testing.md +msgid "" +"Building on [Testing](../testing.md), we will now look at how unit tests " +"work in AOSP. Use the `rust_test` module for your unit tests:" +msgstr "" + +#: src/android/testing.md +msgid "_testing/Android.bp_:" +msgstr "" + +#: src/android/testing.md +msgid "\"libleftpad\"" +msgstr "" + +#: src/android/testing.md +msgid "\"leftpad\"" +msgstr "" + +#: src/android/testing.md +msgid "\"libleftpad_test\"" +msgstr "" + +#: src/android/testing.md +msgid "\"leftpad_test\"" +msgstr "" + +#: src/android/testing.md src/android/interoperability/with-c/bindgen.md +msgid "\"general-tests\"" +msgstr "" + +#: src/android/testing.md +msgid "_testing/src/lib.rs_:" +msgstr "" + +#: src/android/testing.md +msgid "//! Left-padding library.\n" +msgstr "" + +#: src/android/testing.md +msgid "/// Left-pad `s` to `width`.\n" +msgstr "" + +#: src/android/testing.md +msgid "\"{s:>width$}\"" +msgstr "" + +#: src/android/testing.md +msgid "\" foo\"" +msgstr "" + +#: src/android/testing.md +msgid "\"foobar\"" +msgstr "" + +#: src/android/testing.md +msgid "You can now run the test with" +msgstr "" + +#: src/android/testing.md +msgid "The output looks like this:" +msgstr "" + +#: src/android/testing.md +msgid "" +"```text\n" +"INFO: Elapsed time: 2.666s, Critical Path: 2.40s\n" +"INFO: 3 processes: 2 internal, 1 linux-sandbox.\n" +"INFO: Build completed successfully, 3 total actions\n" +"//comprehensive-rust-android/testing:libleftpad_test_host PASSED " +"in 2.3s\n" +" PASSED libleftpad_test.tests::long_string (0.0s)\n" +" PASSED libleftpad_test.tests::short_string (0.0s)\n" +"Test cases: finished with 2 passing and 0 failing out of 2 test cases\n" +"```" +msgstr "" + +#: src/android/testing.md +msgid "" +"Notice how you only mention the root of the library crate. Tests are found " +"recursively in nested modules." +msgstr "" + +#: src/android/testing/googletest.md +msgid "" +"The [GoogleTest](https://docs.rs/googletest/) crate allows for flexible test " +"assertions using _matchers_:" +msgstr "" + +#: src/android/testing/googletest.md +msgid "\"baz\"" +msgstr "" + +#: src/android/testing/googletest.md +msgid "\"xyz\"" +msgstr "" + +#: src/android/testing/googletest.md +msgid "" +"If we change the last element to `\"!\"`, the test fails with a structured " +"error message pin-pointing the error:" +msgstr "" + +#: src/android/testing/googletest.md +msgid "" +"GoogleTest is not part of the Rust Playground, so you need to run this " +"example in a local environment. Use `cargo add googletest` to quickly add it " +"to an existing Cargo project." +msgstr "" + +#: src/android/testing/googletest.md +msgid "" +"The `use googletest::prelude::*;` line imports a number of [commonly used " +"macros and types](https://docs.rs/googletest/latest/googletest/prelude/index." +"html)." +msgstr "" + +#: src/android/testing/googletest.md +msgid "This just scratches the surface, there are many builtin matchers." +msgstr "" + +#: src/android/testing/googletest.md +msgid "" +"A particularly nice feature is that mismatches in multi-line strings are " +"shown as a diff:" +msgstr "" + +#: src/android/testing/googletest.md +msgid "" +"\"Memory safety found,\\n\\\n" +" Rust's strong typing guides the way,\\n\\\n" +" Secure code you'll write.\"" +msgstr "" + +#: src/android/testing/googletest.md +msgid "" +"\"Memory safety found,\\n\\\n" +" Rust's silly humor guides the way,\\n\\\n" +" Secure code you'll write.\"" +msgstr "" + +#: src/android/testing/googletest.md +msgid "shows a color-coded diff (colors not shown here):" +msgstr "" + +#: src/android/testing/googletest.md +msgid "" +"The crate is a Rust port of [GoogleTest for C++](https://google.github.io/" +"googletest/)." +msgstr "" + +#: src/android/testing/mocking.md +msgid "" +"For mocking, [Mockall](https://docs.rs/mockall/) is a widely used library. " +"You need to refactor your code to use traits, which you can then quickly " +"mock:" +msgstr "" + +#: src/android/testing/mocking.md +msgid "" +"Mockall is the recommended mocking library in Android (AOSP). There are " +"other [mocking libraries available on crates.io](https://crates.io/keywords/" +"mock), in particular in the area of mocking HTTP services. The other mocking " +"libraries work in a similar fashion as Mockall, meaning that they make it " +"easy to get a mock implementation of a given trait." +msgstr "" + +#: src/android/testing/mocking.md +msgid "" +"Note that mocking is somewhat _controversial_: mocks allow you to completely " +"isolate a test from its dependencies. The immediate result is faster and " +"more stable test execution. On the other hand, the mocks can be configured " +"wrongly and return output different from what the real dependencies would do." +msgstr "" + +#: src/android/testing/mocking.md +msgid "" +"If at all possible, it is recommended that you use the real dependencies. As " +"an example, many databases allow you to configure an in-memory backend. This " +"means that you get the correct behavior in your tests, plus they are fast " +"and will automatically clean up after themselves." +msgstr "" + +#: src/android/testing/mocking.md +msgid "" +"Similarly, many web frameworks allow you to start an in-process server which " +"binds to a random port on `localhost`. Always prefer this over mocking away " +"the framework since it helps you test your code in the real environment." +msgstr "" + +#: src/android/testing/mocking.md +msgid "" +"Mockall is not part of the Rust Playground, so you need to run this example " +"in a local environment. Use `cargo add mockall` to quickly add Mockall to an " +"existing Cargo project." +msgstr "" + +#: src/android/testing/mocking.md +msgid "" +"Mockall has a lot more functionality. In particular, you can set up " +"expectations which depend on the arguments passed. Here we use this to mock " +"a cat which becomes hungry 3 hours after the last time it was fed:" +msgstr "" + +#: src/android/testing/mocking.md +msgid "" +"You can use `.times(n)` to limit the number of times a mock method can be " +"called to `n` --- the mock will automatically panic when dropped if this " +"isn't satisfied." +msgstr "" + #: src/android/logging.md msgid "" "You should use the `log` crate to automatically log to `logcat` (on-device) " @@ -11821,10 +12493,6 @@ msgstr "" msgid "\":libbirthday_bindgen\"" msgstr "" -#: src/android/interoperability/with-c/bindgen.md -msgid "\"general-tests\"" -msgstr "" - #: src/android/interoperability/with-c/bindgen.md msgid "\"none\"" msgstr "" @@ -12148,11 +12816,6 @@ msgid "" "through a `noexcept` C++ function." msgstr "" -#: src/android/interoperability/cpp/type-mapping.md -#, fuzzy -msgid "Rust Type" -msgstr "Экосистема Rust" - #: src/android/interoperability/cpp/type-mapping.md #, fuzzy msgid "C++ Type" @@ -12199,10 +12862,6 @@ msgstr "" msgid "`std::unique_ptr`" msgstr "" -#: src/android/interoperability/cpp/type-mapping.md -msgid "`Vec`" -msgstr "" - #: src/android/interoperability/cpp/type-mapping.md msgid "`rust::Vec`" msgstr "" @@ -12308,9 +12967,11 @@ msgid "" msgstr "" #: src/android/interoperability/cpp/android-cpp-genrules.md -msgid "" -"// Generate a C++ header containing the C++ bindings\n" -"// to the Rust exported functions in lib.rs.\n" +msgid "// Generate a C++ header containing the C++ bindings" +msgstr "" + +#: src/android/interoperability/cpp/android-cpp-genrules.md +msgid "// to the Rust exported functions in lib.rs." msgstr "" #: src/android/interoperability/cpp/android-cpp-genrules.md @@ -12331,7 +12992,7 @@ msgid "\"lib.rs.h\"" msgstr "" #: src/android/interoperability/cpp/android-cpp-genrules.md -msgid "// Generate the C++ code that Rust calls into.\n" +msgid "// Generate the C++ code that Rust calls into." msgstr "" #: src/android/interoperability/cpp/android-cpp-genrules.md @@ -12521,9 +13182,9 @@ msgstr "" #: src/chromium/cargo.md msgid "" -"Rust community typically uses `cargo` and libraries from [crates.io](https://" -"crates.io/). Chromium is built using `gn` and `ninja` and a curated set of " -"dependencies." +"The Rust community typically uses `cargo` and libraries from [crates.io]" +"(https://crates.io/). Chromium is built using `gn` and `ninja` and a curated " +"set of dependencies." msgstr "" #: src/chromium/cargo.md @@ -12677,13 +13338,13 @@ msgstr "" msgid "" "Disclaimer: a unique reason for using `cargo` was unavailability of `gn` " "when building and bootstrapping Rust standard library when building Rust " -"toolchain.)" +"toolchain." msgstr "" #: src/chromium/cargo.md msgid "" "`run_gnrt.py` uses Chromium's copy of `cargo` and `rustc`. `gnrt` depends on " -"third-party libraries downloaded from the internet, by `run_gnrt.py` asks " +"third-party libraries downloaded from the internet, but `run_gnrt.py` asks " "`cargo` that only `--locked` content is allowed via `Cargo.lock`.)" msgstr "" @@ -13006,7 +13667,7 @@ msgstr "" #: src/exercises/chromium/build-rules.md msgid "" "**Important**: note that `no_mangle` here is considered a type of unsafety " -"by the Rust compiler, so you'll need to to allow unsafe code in your `gn` " +"by the Rust compiler, so you'll need to allow unsafe code in your `gn` " "target." msgstr "" @@ -13374,7 +14035,7 @@ msgid "\"example/include/blobstore.h\"" msgstr "" #: src/chromium/interoperability-with-cpp/example-bindings.md -msgid "// Definitions of Rust types and functions go here\n" +msgid "// Definitions of Rust types and functions go here" msgstr "" #: src/chromium/interoperability-with-cpp/example-bindings.md @@ -13570,17 +14231,19 @@ msgid "\"gfx::rust_bindings\"" msgstr "" #: src/chromium/interoperability-with-cpp/error-handling-png.md -msgid "" -"/// This returns an FFI-friendly equivalent of `Result,\n" -" /// ()>`.\n" +msgid "/// This returns an FFI-friendly equivalent of `Result," msgstr "" #: src/chromium/interoperability-with-cpp/error-handling-png.md -msgid "/// C++ bindings for the `crate::png::ResultOfPngReader` type.\n" +msgid "/// ()>`." msgstr "" #: src/chromium/interoperability-with-cpp/error-handling-png.md -msgid "/// C++ bindings for the `crate::png::PngReader` type.\n" +msgid "/// C++ bindings for the `crate::png::ResultOfPngReader` type." +msgstr "" + +#: src/chromium/interoperability-with-cpp/error-handling-png.md +msgid "/// C++ bindings for the `crate::png::PngReader` type." msgstr "" #: src/chromium/interoperability-with-cpp/error-handling-png.md @@ -13826,6 +14489,10 @@ msgid "" "they do!" msgstr "" +#: src/chromium/adding-third-party-crates.md +msgid "Property" +msgstr "" + #: src/chromium/adding-third-party-crates.md msgid "C++ library" msgstr "" @@ -14084,6 +14751,10 @@ msgstr "" msgid "Checking rustc version to configure features on and off" msgstr "" +#: src/chromium/adding-third-party-crates/resolving-problems.md +msgid "Yes" +msgstr "" + #: src/chromium/adding-third-party-crates/resolving-problems.md msgid "None" msgstr "" @@ -14104,6 +14775,10 @@ msgstr "" msgid "Building C/C++" msgstr "" +#: src/chromium/adding-third-party-crates/resolving-problems.md +msgid "No" +msgstr "" + #: src/chromium/adding-third-party-crates/resolving-problems.md msgid "Patch around it" msgstr "" @@ -14918,6 +15593,10 @@ msgstr "" msgid "// let gpio0_01_again = gpio0.p0_01; // Error, moved.\n" msgstr "" +#: src/bare-metal/microcontrollers/type-state.md +msgid "// ...\n" +msgstr "" + #: src/bare-metal/microcontrollers/type-state.md msgid "// pin_input.is_high(); // Error, moved.\n" msgstr "" @@ -15250,33 +15929,6 @@ msgstr "" msgid "_src/main.rs_:" msgstr "" -#: src/exercises/bare-metal/compass.md -#: src/exercises/bare-metal/solutions-morning.md -msgid "// Configure serial port.\n" -msgstr "" - -#: src/exercises/bare-metal/compass.md -#: src/exercises/bare-metal/solutions-morning.md -msgid "// Use the system timer as a delay provider.\n" -msgstr "" - -#: src/exercises/bare-metal/compass.md -msgid "" -"// Set up the I2C controller and Inertial Measurement Unit.\n" -" // TODO\n" -msgstr "" - -#: src/exercises/bare-metal/compass.md -#: src/exercises/bare-metal/solutions-morning.md -msgid "\"Ready.\"" -msgstr "" - -#: src/exercises/bare-metal/compass.md -msgid "" -"// Read compass data and log it to the serial port.\n" -" // TODO\n" -msgstr "" - #: src/exercises/bare-metal/compass.md src/exercises/bare-metal/rtc.md msgid "_Cargo.toml_ (you shouldn't need to change this):" msgstr "" @@ -15310,6 +15962,14 @@ msgstr "" msgid "([back to exercise](compass.md))" msgstr "" +#: src/exercises/bare-metal/solutions-morning.md +msgid "// Configure serial port.\n" +msgstr "" + +#: src/exercises/bare-metal/solutions-morning.md +msgid "// Use the system timer as a delay provider.\n" +msgstr "" + #: src/exercises/bare-metal/solutions-morning.md msgid "// Set up the I2C controller and Inertial Measurement Unit.\n" msgstr "" @@ -15322,6 +15982,10 @@ msgstr "" msgid "// Set up display and timer.\n" msgstr "" +#: src/exercises/bare-metal/solutions-morning.md +msgid "\"Ready.\"" +msgstr "" + #: src/exercises/bare-metal/solutions-morning.md msgid "// Read compass data and log it to the serial port.\n" msgstr "" @@ -15680,12 +16344,10 @@ msgid "" msgstr "" #: src/bare-metal/aps/uart.md src/bare-metal/aps/better-uart/driver.md -#: src/exercises/bare-metal/rtc.md msgid "/// Writes a single byte to the UART.\n" msgstr "" #: src/bare-metal/aps/uart.md src/bare-metal/aps/better-uart/driver.md -#: src/exercises/bare-metal/rtc.md msgid "// Wait until there is room in the TX buffer.\n" msgstr "" @@ -15696,12 +16358,10 @@ msgid "" msgstr "" #: src/bare-metal/aps/uart.md src/bare-metal/aps/better-uart/driver.md -#: src/exercises/bare-metal/rtc.md msgid "// Write to the TX buffer.\n" msgstr "" #: src/bare-metal/aps/uart.md src/bare-metal/aps/better-uart/driver.md -#: src/exercises/bare-metal/rtc.md msgid "// Wait until the UART is no longer busy.\n" msgstr "" @@ -15739,7 +16399,7 @@ msgid "" "traits too." msgstr "" -#: src/bare-metal/aps/uart/traits.md src/exercises/bare-metal/rtc.md +#: src/bare-metal/aps/uart/traits.md #: src/exercises/bare-metal/solutions-afternoon.md msgid "" "// Safe because it just contains a pointer to device memory, which can be\n" @@ -15921,43 +16581,43 @@ msgid "" "working with bitflags." msgstr "" -#: src/bare-metal/aps/better-uart/bitflags.md src/exercises/bare-metal/rtc.md +#: src/bare-metal/aps/better-uart/bitflags.md msgid "/// Flags from the UART flag register.\n" msgstr "" -#: src/bare-metal/aps/better-uart/bitflags.md src/exercises/bare-metal/rtc.md +#: src/bare-metal/aps/better-uart/bitflags.md msgid "/// Clear to send.\n" msgstr "" -#: src/bare-metal/aps/better-uart/bitflags.md src/exercises/bare-metal/rtc.md +#: src/bare-metal/aps/better-uart/bitflags.md msgid "/// Data set ready.\n" msgstr "" -#: src/bare-metal/aps/better-uart/bitflags.md src/exercises/bare-metal/rtc.md +#: src/bare-metal/aps/better-uart/bitflags.md msgid "/// Data carrier detect.\n" msgstr "" -#: src/bare-metal/aps/better-uart/bitflags.md src/exercises/bare-metal/rtc.md +#: src/bare-metal/aps/better-uart/bitflags.md msgid "/// UART busy transmitting data.\n" msgstr "" -#: src/bare-metal/aps/better-uart/bitflags.md src/exercises/bare-metal/rtc.md +#: src/bare-metal/aps/better-uart/bitflags.md msgid "/// Receive FIFO is empty.\n" msgstr "" -#: src/bare-metal/aps/better-uart/bitflags.md src/exercises/bare-metal/rtc.md +#: src/bare-metal/aps/better-uart/bitflags.md msgid "/// Transmit FIFO is full.\n" msgstr "" -#: src/bare-metal/aps/better-uart/bitflags.md src/exercises/bare-metal/rtc.md +#: src/bare-metal/aps/better-uart/bitflags.md msgid "/// Receive FIFO is full.\n" msgstr "" -#: src/bare-metal/aps/better-uart/bitflags.md src/exercises/bare-metal/rtc.md +#: src/bare-metal/aps/better-uart/bitflags.md msgid "/// Transmit FIFO is empty.\n" msgstr "" -#: src/bare-metal/aps/better-uart/bitflags.md src/exercises/bare-metal/rtc.md +#: src/bare-metal/aps/better-uart/bitflags.md msgid "/// Ring indicator.\n" msgstr "" @@ -15993,19 +16653,19 @@ msgstr "" msgid "/// Driver for a PL011 UART.\n" msgstr "" -#: src/bare-metal/aps/better-uart/driver.md src/exercises/bare-metal/rtc.md +#: src/bare-metal/aps/better-uart/driver.md msgid "" "// Safe because we know that self.registers points to the control\n" " // registers of a PL011 device which is appropriately mapped.\n" msgstr "" -#: src/bare-metal/aps/better-uart/driver.md src/exercises/bare-metal/rtc.md +#: src/bare-metal/aps/better-uart/driver.md msgid "" "/// Reads and returns a pending byte, or `None` if nothing has been\n" " /// received.\n" msgstr "" -#: src/bare-metal/aps/better-uart/driver.md src/exercises/bare-metal/rtc.md +#: src/bare-metal/aps/better-uart/driver.md msgid "// TODO: Check for error conditions in bits 8-11.\n" msgstr "" @@ -16026,13 +16686,11 @@ msgid "" msgstr "" #: src/bare-metal/aps/better-uart/using.md src/bare-metal/aps/logging/using.md -#: src/exercises/bare-metal/rtc.md #: src/exercises/bare-metal/solutions-afternoon.md msgid "/// Base address of the primary PL011 UART.\n" msgstr "" #: src/bare-metal/aps/better-uart/using.md src/bare-metal/aps/logging/using.md -#: src/exercises/bare-metal/rtc.md #: src/exercises/bare-metal/solutions-afternoon.md msgid "" "// Safe because `PL011_BASE_ADDRESS` is the base address of a PL011 device,\n" @@ -16078,11 +16736,11 @@ msgid "" "`Log` trait." msgstr "" -#: src/bare-metal/aps/logging.md src/exercises/bare-metal/rtc.md +#: src/bare-metal/aps/logging.md msgid "\"[{}] {}\"" msgstr "" -#: src/bare-metal/aps/logging.md src/exercises/bare-metal/rtc.md +#: src/bare-metal/aps/logging.md msgid "/// Initialises UART logger.\n" msgstr "" @@ -16096,7 +16754,7 @@ msgstr "" msgid "We need to initialise the logger before we use it." msgstr "" -#: src/bare-metal/aps/logging/using.md src/exercises/bare-metal/rtc.md +#: src/bare-metal/aps/logging/using.md #: src/exercises/bare-metal/solutions-afternoon.md msgid "\"{info}\"" msgstr "" @@ -16270,15 +16928,15 @@ msgid "" msgstr "" #: src/bare-metal/useful-crates/aarch64-paging.md -msgid "// Create a new page table with identity mapping.\n" +msgid "// Create a new page table with identity mapping." msgstr "" #: src/bare-metal/useful-crates/aarch64-paging.md -msgid "// Map a 2 MiB region of memory as read-only.\n" +msgid "// Map a 2 MiB region of memory as read-only." msgstr "" #: src/bare-metal/useful-crates/aarch64-paging.md -msgid "// Set `TTBR0_EL1` to activate the page table.\n" +msgid "// Set `TTBR0_EL1` to activate the page table." msgstr "" #: src/bare-metal/useful-crates/aarch64-paging.md @@ -16471,760 +17129,44 @@ msgid "" "look in the `rtc` directory for the following files." msgstr "" -#: src/exercises/bare-metal/rtc.md -#: src/exercises/bare-metal/solutions-afternoon.md -msgid "/// Base addresses of the GICv3.\n" -msgstr "" - -#: src/exercises/bare-metal/rtc.md -#: src/exercises/bare-metal/solutions-afternoon.md -msgid "\"main({:#x}, {:#x}, {:#x}, {:#x})\"" -msgstr "" - -#: src/exercises/bare-metal/rtc.md -#: src/exercises/bare-metal/solutions-afternoon.md -msgid "" -"// Safe because `GICD_BASE_ADDRESS` and `GICR_BASE_ADDRESS` are the base\n" -" // addresses of a GICv3 distributor and redistributor respectively, and\n" -" // nothing else accesses those address ranges.\n" -msgstr "" - -#: src/exercises/bare-metal/rtc.md -msgid "// TODO: Create instance of RTC driver and print current time.\n" -msgstr "" - -#: src/exercises/bare-metal/rtc.md -msgid "// TODO: Wait for 3 seconds.\n" -msgstr "" - #: src/exercises/bare-metal/rtc.md msgid "" "_src/exceptions.rs_ (you should only need to change this for the 3rd part of " "the exercise):" msgstr "" -#: src/exercises/bare-metal/rtc.md -msgid "" -"// Copyright 2023 Google LLC\n" -"//\n" -"// Licensed under the Apache License, Version 2.0 (the \"License\");\n" -"// you may not use this file except in compliance with the License.\n" -"// You may obtain a copy of the License at\n" -"//\n" -"// http://www.apache.org/licenses/LICENSE-2.0\n" -"//\n" -"// Unless required by applicable law or agreed to in writing, software\n" -"// distributed under the License is distributed on an \"AS IS\" BASIS,\n" -"// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n" -"// See the License for the specific language governing permissions and\n" -"// limitations under the License.\n" -msgstr "" - -#: src/exercises/bare-metal/rtc.md -msgid "\"sync_exception_current\"" -msgstr "" - -#: src/exercises/bare-metal/rtc.md -msgid "\"irq_current\"" -msgstr "" - -#: src/exercises/bare-metal/rtc.md -msgid "\"No pending interrupt\"" -msgstr "" - -#: src/exercises/bare-metal/rtc.md -msgid "\"IRQ {intid:?}\"" -msgstr "" - -#: src/exercises/bare-metal/rtc.md -msgid "\"fiq_current\"" -msgstr "" - -#: src/exercises/bare-metal/rtc.md -msgid "\"serr_current\"" -msgstr "" - -#: src/exercises/bare-metal/rtc.md -msgid "\"sync_lower\"" -msgstr "" - -#: src/exercises/bare-metal/rtc.md -msgid "\"irq_lower\"" -msgstr "" - -#: src/exercises/bare-metal/rtc.md -msgid "\"fiq_lower\"" -msgstr "" - -#: src/exercises/bare-metal/rtc.md -msgid "\"serr_lower\"" -msgstr "" - #: src/exercises/bare-metal/rtc.md msgid "_src/logger.rs_ (you shouldn't need to change this):" msgstr "" -#: src/exercises/bare-metal/rtc.md -msgid "// ANCHOR: main\n" -msgstr "" - #: src/exercises/bare-metal/rtc.md msgid "_src/pl011.rs_ (you shouldn't need to change this):" msgstr "" -#: src/exercises/bare-metal/rtc.md -msgid "// ANCHOR: Flags\n" -msgstr "" - -#: src/exercises/bare-metal/rtc.md -msgid "// ANCHOR_END: Flags\n" -msgstr "" - -#: src/exercises/bare-metal/rtc.md -msgid "" -"/// Flags from the UART Receive Status Register / Error Clear Register.\n" -msgstr "" - -#: src/exercises/bare-metal/rtc.md -msgid "/// Framing error.\n" -msgstr "" - -#: src/exercises/bare-metal/rtc.md -msgid "/// Parity error.\n" -msgstr "" - -#: src/exercises/bare-metal/rtc.md -msgid "/// Break error.\n" -msgstr "" - -#: src/exercises/bare-metal/rtc.md -msgid "/// Overrun error.\n" -msgstr "" - -#: src/exercises/bare-metal/rtc.md -msgid "// ANCHOR: Registers\n" -msgstr "" - -#: src/exercises/bare-metal/rtc.md -msgid "// ANCHOR_END: Registers\n" -msgstr "" - -#: src/exercises/bare-metal/rtc.md -msgid "" -"// ANCHOR: Uart\n" -"/// Driver for a PL011 UART.\n" -msgstr "" - -#: src/exercises/bare-metal/rtc.md -msgid "" -"/// Constructs a new instance of the UART driver for a PL011 device at the\n" -" /// given base address.\n" -" ///\n" -" /// # Safety\n" -" ///\n" -" /// The given base address must point to the MMIO control registers of " -"a\n" -" /// PL011 device, which must be mapped into the address space of the " -"process\n" -" /// as device memory and not have any other aliases.\n" -msgstr "" - -#: src/exercises/bare-metal/rtc.md -msgid "// ANCHOR_END: Uart\n" -msgstr "" - #: src/exercises/bare-metal/rtc.md msgid "_build.rs_ (you shouldn't need to change this):" msgstr "" -#: src/exercises/bare-metal/rtc.md -msgid "\"linux\"" -msgstr "" - -#: src/exercises/bare-metal/rtc.md -msgid "\"CROSS_COMPILE\"" -msgstr "" - -#: src/exercises/bare-metal/rtc.md -msgid "\"aarch64-linux-gnu\"" -msgstr "" - -#: src/exercises/bare-metal/rtc.md -msgid "\"aarch64-none-elf\"" -msgstr "" - -#: src/exercises/bare-metal/rtc.md -msgid "\"entry.S\"" -msgstr "" - -#: src/exercises/bare-metal/rtc.md -msgid "\"exceptions.S\"" -msgstr "" - -#: src/exercises/bare-metal/rtc.md -msgid "\"idmap.S\"" -msgstr "" - -#: src/exercises/bare-metal/rtc.md -msgid "\"empty\"" -msgstr "" - #: src/exercises/bare-metal/rtc.md msgid "_entry.S_ (you shouldn't need to change this):" msgstr "" -#: src/exercises/bare-metal/rtc.md -msgid "" -"```armasm\n" -"/*\n" -" * Copyright 2023 Google LLC\n" -" *\n" -" * Licensed under the Apache License, Version 2.0 (the \"License\");\n" -" * you may not use this file except in compliance with the License.\n" -" * You may obtain a copy of the License at\n" -" *\n" -" * https://www.apache.org/licenses/LICENSE-2.0\n" -" *\n" -" * Unless required by applicable law or agreed to in writing, software\n" -" * distributed under the License is distributed on an \"AS IS\" BASIS,\n" -" * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n" -" * See the License for the specific language governing permissions and\n" -" * limitations under the License.\n" -" */\n" -"\n" -".macro adr_l, reg:req, sym:req\n" -"\tadrp \\reg, \\sym\n" -"\tadd \\reg, \\reg, :lo12:\\sym\n" -".endm\n" -"\n" -".macro mov_i, reg:req, imm:req\n" -"\tmovz \\reg, :abs_g3:\\imm\n" -"\tmovk \\reg, :abs_g2_nc:\\imm\n" -"\tmovk \\reg, :abs_g1_nc:\\imm\n" -"\tmovk \\reg, :abs_g0_nc:\\imm\n" -".endm\n" -"\n" -".set .L_MAIR_DEV_nGnRE,\t0x04\n" -".set .L_MAIR_MEM_WBWA,\t0xff\n" -".set .Lmairval, .L_MAIR_DEV_nGnRE | (.L_MAIR_MEM_WBWA << 8)\n" -"\n" -"/* 4 KiB granule size for TTBR0_EL1. */\n" -".set .L_TCR_TG0_4KB, 0x0 << 14\n" -"/* 4 KiB granule size for TTBR1_EL1. */\n" -".set .L_TCR_TG1_4KB, 0x2 << 30\n" -"/* Disable translation table walk for TTBR1_EL1, generating a translation " -"fault instead. */\n" -".set .L_TCR_EPD1, 0x1 << 23\n" -"/* Translation table walks for TTBR0_EL1 are inner sharable. */\n" -".set .L_TCR_SH_INNER, 0x3 << 12\n" -"/*\n" -" * Translation table walks for TTBR0_EL1 are outer write-back read-allocate " -"write-allocate\n" -" * cacheable.\n" -" */\n" -".set .L_TCR_RGN_OWB, 0x1 << 10\n" -"/*\n" -" * Translation table walks for TTBR0_EL1 are inner write-back read-allocate " -"write-allocate\n" -" * cacheable.\n" -" */\n" -".set .L_TCR_RGN_IWB, 0x1 << 8\n" -"/* Size offset for TTBR0_EL1 is 2**39 bytes (512 GiB). */\n" -".set .L_TCR_T0SZ_512, 64 - 39\n" -".set .Ltcrval, .L_TCR_TG0_4KB | .L_TCR_TG1_4KB | .L_TCR_EPD1 | ." -"L_TCR_RGN_OWB\n" -".set .Ltcrval, .Ltcrval | .L_TCR_RGN_IWB | .L_TCR_SH_INNER | ." -"L_TCR_T0SZ_512\n" -"\n" -"/* Stage 1 instruction access cacheability is unaffected. */\n" -".set .L_SCTLR_ELx_I, 0x1 << 12\n" -"/* SP alignment fault if SP is not aligned to a 16 byte boundary. */\n" -".set .L_SCTLR_ELx_SA, 0x1 << 3\n" -"/* Stage 1 data access cacheability is unaffected. */\n" -".set .L_SCTLR_ELx_C, 0x1 << 2\n" -"/* EL0 and EL1 stage 1 MMU enabled. */\n" -".set .L_SCTLR_ELx_M, 0x1 << 0\n" -"/* Privileged Access Never is unchanged on taking an exception to EL1. */\n" -".set .L_SCTLR_EL1_SPAN, 0x1 << 23\n" -"/* SETEND instruction disabled at EL0 in aarch32 mode. */\n" -".set .L_SCTLR_EL1_SED, 0x1 << 8\n" -"/* Various IT instructions are disabled at EL0 in aarch32 mode. */\n" -".set .L_SCTLR_EL1_ITD, 0x1 << 7\n" -".set .L_SCTLR_EL1_RES1, (0x1 << 11) | (0x1 << 20) | (0x1 << 22) | (0x1 << " -"28) | (0x1 << 29)\n" -".set .Lsctlrval, .L_SCTLR_ELx_M | .L_SCTLR_ELx_C | .L_SCTLR_ELx_SA | ." -"L_SCTLR_EL1_ITD | .L_SCTLR_EL1_SED\n" -".set .Lsctlrval, .Lsctlrval | .L_SCTLR_ELx_I | .L_SCTLR_EL1_SPAN | ." -"L_SCTLR_EL1_RES1\n" -"\n" -"/**\n" -" * This is a generic entry point for an image. It carries out the operations " -"required to prepare the\n" -" * loaded image to be run. Specifically, it zeroes the bss section using " -"registers x25 and above,\n" -" * prepares the stack, enables floating point, and sets up the exception " -"vector. It preserves x0-x3\n" -" * for the Rust entry point, as these may contain boot parameters.\n" -" */\n" -".section .init.entry, \"ax\"\n" -".global entry\n" -"entry:\n" -"\t/* Load and apply the memory management configuration, ready to enable MMU " -"and caches. */\n" -"\tadrp x30, idmap\n" -"\tmsr ttbr0_el1, x30\n" -"\n" -"\tmov_i x30, .Lmairval\n" -"\tmsr mair_el1, x30\n" -"\n" -"\tmov_i x30, .Ltcrval\n" -"\t/* Copy the supported PA range into TCR_EL1.IPS. */\n" -"\tmrs x29, id_aa64mmfr0_el1\n" -"\tbfi x30, x29, #32, #4\n" -"\n" -"\tmsr tcr_el1, x30\n" -"\n" -"\tmov_i x30, .Lsctlrval\n" -"\n" -"\t/*\n" -"\t * Ensure everything before this point has completed, then invalidate any " -"potentially stale\n" -"\t * local TLB entries before they start being used.\n" -"\t */\n" -"\tisb\n" -"\ttlbi vmalle1\n" -"\tic iallu\n" -"\tdsb nsh\n" -"\tisb\n" -"\n" -"\t/*\n" -"\t * Configure sctlr_el1 to enable MMU and cache and don't proceed until " -"this has completed.\n" -"\t */\n" -"\tmsr sctlr_el1, x30\n" -"\tisb\n" -"\n" -"\t/* Disable trapping floating point access in EL1. */\n" -"\tmrs x30, cpacr_el1\n" -"\torr x30, x30, #(0x3 << 20)\n" -"\tmsr cpacr_el1, x30\n" -"\tisb\n" -"\n" -"\t/* Zero out the bss section. */\n" -"\tadr_l x29, bss_begin\n" -"\tadr_l x30, bss_end\n" -"0:\tcmp x29, x30\n" -"\tb.hs 1f\n" -"\tstp xzr, xzr, [x29], #16\n" -"\tb 0b\n" -"\n" -"1:\t/* Prepare the stack. */\n" -"\tadr_l x30, boot_stack_end\n" -"\tmov sp, x30\n" -"\n" -"\t/* Set up exception vector. */\n" -"\tadr x30, vector_table_el1\n" -"\tmsr vbar_el1, x30\n" -"\n" -"\t/* Call into Rust code. */\n" -"\tbl main\n" -"\n" -"\t/* Loop forever waiting for interrupts. */\n" -"2:\twfi\n" -"\tb 2b\n" -"```" -msgstr "" - #: src/exercises/bare-metal/rtc.md msgid "_exceptions.S_ (you shouldn't need to change this):" msgstr "" -#: src/exercises/bare-metal/rtc.md -msgid "" -"```armasm\n" -"/*\n" -" * Copyright 2023 Google LLC\n" -" *\n" -" * Licensed under the Apache License, Version 2.0 (the \"License\");\n" -" * you may not use this file except in compliance with the License.\n" -" * You may obtain a copy of the License at\n" -" *\n" -" * https://www.apache.org/licenses/LICENSE-2.0\n" -" *\n" -" * Unless required by applicable law or agreed to in writing, software\n" -" * distributed under the License is distributed on an \"AS IS\" BASIS,\n" -" * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n" -" * See the License for the specific language governing permissions and\n" -" * limitations under the License.\n" -" */\n" -"\n" -"/**\n" -" * Saves the volatile registers onto the stack. This currently takes 14\n" -" * instructions, so it can be used in exception handlers with 18 " -"instructions\n" -" * left.\n" -" *\n" -" * On return, x0 and x1 are initialised to elr_el2 and spsr_el2 " -"respectively,\n" -" * which can be used as the first and second arguments of a subsequent " -"call.\n" -" */\n" -".macro save_volatile_to_stack\n" -"\t/* Reserve stack space and save registers x0-x18, x29 & x30. */\n" -"\tstp x0, x1, [sp, #-(8 * 24)]!\n" -"\tstp x2, x3, [sp, #8 * 2]\n" -"\tstp x4, x5, [sp, #8 * 4]\n" -"\tstp x6, x7, [sp, #8 * 6]\n" -"\tstp x8, x9, [sp, #8 * 8]\n" -"\tstp x10, x11, [sp, #8 * 10]\n" -"\tstp x12, x13, [sp, #8 * 12]\n" -"\tstp x14, x15, [sp, #8 * 14]\n" -"\tstp x16, x17, [sp, #8 * 16]\n" -"\tstr x18, [sp, #8 * 18]\n" -"\tstp x29, x30, [sp, #8 * 20]\n" -"\n" -"\t/*\n" -"\t * Save elr_el1 & spsr_el1. This such that we can take nested exception\n" -"\t * and still be able to unwind.\n" -"\t */\n" -"\tmrs x0, elr_el1\n" -"\tmrs x1, spsr_el1\n" -"\tstp x0, x1, [sp, #8 * 22]\n" -".endm\n" -"\n" -"/**\n" -" * Restores the volatile registers from the stack. This currently takes 14\n" -" * instructions, so it can be used in exception handlers while still leaving " -"18\n" -" * instructions left; if paired with save_volatile_to_stack, there are 4\n" -" * instructions to spare.\n" -" */\n" -".macro restore_volatile_from_stack\n" -"\t/* Restore registers x2-x18, x29 & x30. */\n" -"\tldp x2, x3, [sp, #8 * 2]\n" -"\tldp x4, x5, [sp, #8 * 4]\n" -"\tldp x6, x7, [sp, #8 * 6]\n" -"\tldp x8, x9, [sp, #8 * 8]\n" -"\tldp x10, x11, [sp, #8 * 10]\n" -"\tldp x12, x13, [sp, #8 * 12]\n" -"\tldp x14, x15, [sp, #8 * 14]\n" -"\tldp x16, x17, [sp, #8 * 16]\n" -"\tldr x18, [sp, #8 * 18]\n" -"\tldp x29, x30, [sp, #8 * 20]\n" -"\n" -"\t/* Restore registers elr_el1 & spsr_el1, using x0 & x1 as scratch. */\n" -"\tldp x0, x1, [sp, #8 * 22]\n" -"\tmsr elr_el1, x0\n" -"\tmsr spsr_el1, x1\n" -"\n" -"\t/* Restore x0 & x1, and release stack space. */\n" -"\tldp x0, x1, [sp], #8 * 24\n" -".endm\n" -"\n" -"/**\n" -" * This is a generic handler for exceptions taken at the current EL while " -"using\n" -" * SP0. It behaves similarly to the SPx case by first switching to SPx, " -"doing\n" -" * the work, then switching back to SP0 before returning.\n" -" *\n" -" * Switching to SPx and calling the Rust handler takes 16 instructions. To\n" -" * restore and return we need an additional 16 instructions, so we can " -"implement\n" -" * the whole handler within the allotted 32 instructions.\n" -" */\n" -".macro current_exception_sp0 handler:req\n" -"\tmsr spsel, #1\n" -"\tsave_volatile_to_stack\n" -"\tbl \\handler\n" -"\trestore_volatile_from_stack\n" -"\tmsr spsel, #0\n" -"\teret\n" -".endm\n" -"\n" -"/**\n" -" * This is a generic handler for exceptions taken at the current EL while " -"using\n" -" * SPx. It saves volatile registers, calls the Rust handler, restores " -"volatile\n" -" * registers, then returns.\n" -" *\n" -" * This also works for exceptions taken from EL0, if we don't care about\n" -" * non-volatile registers.\n" -" *\n" -" * Saving state and jumping to the Rust handler takes 15 instructions, and\n" -" * restoring and returning also takes 15 instructions, so we can fit the " -"whole\n" -" * handler in 30 instructions, under the limit of 32.\n" -" */\n" -".macro current_exception_spx handler:req\n" -"\tsave_volatile_to_stack\n" -"\tbl \\handler\n" -"\trestore_volatile_from_stack\n" -"\teret\n" -".endm\n" -"\n" -".section .text.vector_table_el1, \"ax\"\n" -".global vector_table_el1\n" -".balign 0x800\n" -"vector_table_el1:\n" -"sync_cur_sp0:\n" -"\tcurrent_exception_sp0 sync_exception_current\n" -"\n" -".balign 0x80\n" -"irq_cur_sp0:\n" -"\tcurrent_exception_sp0 irq_current\n" -"\n" -".balign 0x80\n" -"fiq_cur_sp0:\n" -"\tcurrent_exception_sp0 fiq_current\n" -"\n" -".balign 0x80\n" -"serr_cur_sp0:\n" -"\tcurrent_exception_sp0 serr_current\n" -"\n" -".balign 0x80\n" -"sync_cur_spx:\n" -"\tcurrent_exception_spx sync_exception_current\n" -"\n" -".balign 0x80\n" -"irq_cur_spx:\n" -"\tcurrent_exception_spx irq_current\n" -"\n" -".balign 0x80\n" -"fiq_cur_spx:\n" -"\tcurrent_exception_spx fiq_current\n" -"\n" -".balign 0x80\n" -"serr_cur_spx:\n" -"\tcurrent_exception_spx serr_current\n" -"\n" -".balign 0x80\n" -"sync_lower_64:\n" -"\tcurrent_exception_spx sync_lower\n" -"\n" -".balign 0x80\n" -"irq_lower_64:\n" -"\tcurrent_exception_spx irq_lower\n" -"\n" -".balign 0x80\n" -"fiq_lower_64:\n" -"\tcurrent_exception_spx fiq_lower\n" -"\n" -".balign 0x80\n" -"serr_lower_64:\n" -"\tcurrent_exception_spx serr_lower\n" -"\n" -".balign 0x80\n" -"sync_lower_32:\n" -"\tcurrent_exception_spx sync_lower\n" -"\n" -".balign 0x80\n" -"irq_lower_32:\n" -"\tcurrent_exception_spx irq_lower\n" -"\n" -".balign 0x80\n" -"fiq_lower_32:\n" -"\tcurrent_exception_spx fiq_lower\n" -"\n" -".balign 0x80\n" -"serr_lower_32:\n" -"\tcurrent_exception_spx serr_lower\n" -"```" -msgstr "" - #: src/exercises/bare-metal/rtc.md msgid "_idmap.S_ (you shouldn't need to change this):" msgstr "" -#: src/exercises/bare-metal/rtc.md -msgid "" -"```armasm\n" -"/*\n" -" * Copyright 2023 Google LLC\n" -" *\n" -" * Licensed under the Apache License, Version 2.0 (the \"License\");\n" -" * you may not use this file except in compliance with the License.\n" -" * You may obtain a copy of the License at\n" -" *\n" -" * https://www.apache.org/licenses/LICENSE-2.0\n" -" *\n" -" * Unless required by applicable law or agreed to in writing, software\n" -" * distributed under the License is distributed on an \"AS IS\" BASIS,\n" -" * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n" -" * See the License for the specific language governing permissions and\n" -" * limitations under the License.\n" -" */\n" -"\n" -".set .L_TT_TYPE_BLOCK, 0x1\n" -".set .L_TT_TYPE_PAGE, 0x3\n" -".set .L_TT_TYPE_TABLE, 0x3\n" -"\n" -"/* Access flag. */\n" -".set .L_TT_AF, 0x1 << 10\n" -"/* Not global. */\n" -".set .L_TT_NG, 0x1 << 11\n" -".set .L_TT_XN, 0x3 << 53\n" -"\n" -".set .L_TT_MT_DEV, 0x0 << 2\t\t\t// MAIR #0 (DEV_nGnRE)\n" -".set .L_TT_MT_MEM, (0x1 << 2) | (0x3 << 8)\t// MAIR #1 (MEM_WBWA), inner " -"shareable\n" -"\n" -".set .L_BLOCK_DEV, .L_TT_TYPE_BLOCK | .L_TT_MT_DEV | .L_TT_AF | .L_TT_XN\n" -".set .L_BLOCK_MEM, .L_TT_TYPE_BLOCK | .L_TT_MT_MEM | .L_TT_AF | .L_TT_NG\n" -"\n" -".section \".rodata.idmap\", \"a\", %progbits\n" -".global idmap\n" -".align 12\n" -"idmap:\n" -"\t/* level 1 */\n" -"\t.quad\t\t.L_BLOCK_DEV | 0x0\t\t // 1 GiB of device mappings\n" -"\t.quad\t\t.L_BLOCK_MEM | 0x40000000\t// 1 GiB of DRAM\n" -"\t.fill\t\t254, 8, 0x0\t\t\t// 254 GiB of unmapped VA space\n" -"\t.quad\t\t.L_BLOCK_DEV | 0x4000000000 // 1 GiB of device mappings\n" -"\t.fill\t\t255, 8, 0x0\t\t\t// 255 GiB of remaining VA space\n" -"```" -msgstr "" - #: src/exercises/bare-metal/rtc.md msgid "_image.ld_ (you shouldn't need to change this):" msgstr "" -#: src/exercises/bare-metal/rtc.md -msgid "" -"```ld\n" -"/*\n" -" * Copyright 2023 Google LLC\n" -" *\n" -" * Licensed under the Apache License, Version 2.0 (the \"License\");\n" -" * you may not use this file except in compliance with the License.\n" -" * You may obtain a copy of the License at\n" -" *\n" -" * https://www.apache.org/licenses/LICENSE-2.0\n" -" *\n" -" * Unless required by applicable law or agreed to in writing, software\n" -" * distributed under the License is distributed on an \"AS IS\" BASIS,\n" -" * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n" -" * See the License for the specific language governing permissions and\n" -" * limitations under the License.\n" -" */\n" -"\n" -"/*\n" -" * Code will start running at this symbol which is placed at the start of " -"the\n" -" * image.\n" -" */\n" -"ENTRY(entry)\n" -"\n" -"MEMORY\n" -"{\n" -"\timage : ORIGIN = 0x40080000, LENGTH = 2M\n" -"}\n" -"\n" -"SECTIONS\n" -"{\n" -"\t/*\n" -"\t * Collect together the code.\n" -"\t */\n" -"\t.init : ALIGN(4096) {\n" -"\t\ttext_begin = .;\n" -"\t\t*(.init.entry)\n" -"\t\t*(.init.*)\n" -"\t} >image\n" -"\t.text : {\n" -"\t\t*(.text.*)\n" -"\t} >image\n" -"\ttext_end = .;\n" -"\n" -"\t/*\n" -"\t * Collect together read-only data.\n" -"\t */\n" -"\t.rodata : ALIGN(4096) {\n" -"\t\trodata_begin = .;\n" -"\t\t*(.rodata.*)\n" -"\t} >image\n" -"\t.got : {\n" -"\t\t*(.got)\n" -"\t} >image\n" -"\trodata_end = .;\n" -"\n" -"\t/*\n" -"\t * Collect together the read-write data including .bss at the end which\n" -"\t * will be zero'd by the entry code.\n" -"\t */\n" -"\t.data : ALIGN(4096) {\n" -"\t\tdata_begin = .;\n" -"\t\t*(.data.*)\n" -"\t\t/*\n" -"\t\t * The entry point code assumes that .data is a multiple of 32\n" -"\t\t * bytes long.\n" -"\t\t */\n" -"\t\t. = ALIGN(32);\n" -"\t\tdata_end = .;\n" -"\t} >image\n" -"\n" -"\t/* Everything beyond this point will not be included in the binary. */\n" -"\tbin_end = .;\n" -"\n" -"\t/* The entry point code assumes that .bss is 16-byte aligned. */\n" -"\t.bss : ALIGN(16) {\n" -"\t\tbss_begin = .;\n" -"\t\t*(.bss.*)\n" -"\t\t*(COMMON)\n" -"\t\t. = ALIGN(16);\n" -"\t\tbss_end = .;\n" -"\t} >image\n" -"\n" -"\t.stack (NOLOAD) : ALIGN(4096) {\n" -"\t\tboot_stack_begin = .;\n" -"\t\t. += 40 * 4096;\n" -"\t\t. = ALIGN(4096);\n" -"\t\tboot_stack_end = .;\n" -"\t} >image\n" -"\n" -"\t. = ALIGN(4K);\n" -"\tPROVIDE(dma_region = .);\n" -"\n" -"\t/*\n" -"\t * Remove unused sections from the image.\n" -"\t */\n" -"\t/DISCARD/ : {\n" -"\t\t/* The image loads itself so doesn't need these sections. */\n" -"\t\t*(.gnu.hash)\n" -"\t\t*(.hash)\n" -"\t\t*(.interp)\n" -"\t\t*(.eh_frame_hdr)\n" -"\t\t*(.eh_frame)\n" -"\t\t*(.note.gnu.build-id)\n" -"\t}\n" -"}\n" -"```" -msgstr "" - #: src/exercises/bare-metal/rtc.md msgid "_Makefile_ (you shouldn't need to change this):" msgstr "" -#: src/exercises/bare-metal/rtc.md -msgid "# Copyright 2023 Google LLC" -msgstr "" - -#: src/exercises/bare-metal/rtc.md -msgid "$(shell uname -s)" -msgstr "" - -#: src/exercises/bare-metal/rtc.md -msgid "aarch64-linux-gnu" -msgstr "" - -#: src/exercises/bare-metal/rtc.md -msgid "stdio -display none -kernel $< -s" -msgstr "" - -#: src/exercises/bare-metal/rtc.md -msgid "cargo clean" -msgstr "" - #: src/exercises/bare-metal/rtc.md msgid "Run the code in QEMU with `make qemu`." msgstr "" @@ -17241,6 +17183,10 @@ msgstr "" msgid "_main.rs_:" msgstr "" +#: src/exercises/bare-metal/solutions-afternoon.md +msgid "/// Base addresses of the GICv3.\n" +msgstr "" + #: src/exercises/bare-metal/solutions-afternoon.md msgid "/// Base address of the PL031 RTC.\n" msgstr "" @@ -17249,6 +17195,17 @@ msgstr "" msgid "/// The IRQ used by the PL031 RTC.\n" msgstr "" +#: src/exercises/bare-metal/solutions-afternoon.md +msgid "\"main({:#x}, {:#x}, {:#x}, {:#x})\"" +msgstr "" + +#: src/exercises/bare-metal/solutions-afternoon.md +msgid "" +"// Safe because `GICD_BASE_ADDRESS` and `GICR_BASE_ADDRESS` are the base\n" +" // addresses of a GICv3 distributor and redistributor respectively, and\n" +" // nothing else accesses those address ranges.\n" +msgstr "" + #: src/exercises/bare-metal/solutions-afternoon.md msgid "" "// Safe because `PL031_BASE_ADDRESS` is the base address of a PL031 device,\n" @@ -17394,6 +17351,23 @@ msgid "" "you can rely on the compiler to ensure correctness at runtime." msgstr "" +#: src/concurrency.md +msgid "" +"Rust lets us access OS concurrency toolkit: threads, sync. primitives, etc." +msgstr "" + +#: src/concurrency.md +msgid "" +"The type system gives us safety for concurrency without any special features." +msgstr "" + +#: src/concurrency.md +msgid "" +"The same tools that help with \"concurrent\" access in a single thread (e." +"g., a called function that might mutate an argument or save references to it " +"to read later) save us from multi-threading issues." +msgstr "" + #: src/concurrency/threads.md msgid "Rust threads work similarly to threads in other languages:" msgstr "" @@ -17418,27 +17392,128 @@ msgstr "" msgid "Panics can carry a payload, which can be unpacked with `downcast_ref`." msgstr "" +#: src/concurrency/threads.md +msgid "Rust thread APIs look not too different from e.g. C++ ones." +msgstr "" + +#: src/concurrency/threads.md +msgid "Run the example." +msgstr "" + #: src/concurrency/threads.md msgid "" -"Notice that the thread is stopped before it reaches 10 --- the main thread " -"is not waiting." +"5ms timing is loose enough that main and spawned threads stay mostly in " +"lockstep." +msgstr "" + +#: src/concurrency/threads.md +msgid "Notice that the program ends before the spawned thread reaches 10!" +msgstr "" + +#: src/concurrency/threads.md +msgid "" +"This is because main ends the program and spawned threads do not make it " +"persist." +msgstr "" + +#: src/concurrency/threads.md +msgid "Compare to pthreads/C++ std::thread/boost::thread if desired." +msgstr "" + +#: src/concurrency/threads.md +msgid "How do we wait around for the spawned thread to complete?" +msgstr "" + +#: src/concurrency/threads.md +msgid "" +"[`thread::spawn`](https://doc.rust-lang.org/std/thread/fn.spawn.html) " +"returns a `JoinHandle`. Look at the docs." +msgstr "" + +#: src/concurrency/threads.md +msgid "" +"`JoinHandle` has a [`.join()`](https://doc.rust-lang.org/std/thread/struct." +"JoinHandle.html#method.join) method that blocks." msgstr "" #: src/concurrency/threads.md msgid "" "Use `let handle = thread::spawn(...)` and later `handle.join()` to wait for " -"the thread to finish." +"the thread to finish and have the program count all the way to 10." msgstr "" #: src/concurrency/threads.md -msgid "Trigger a panic in the thread, notice how this doesn't affect `main`." +msgid "Now what if we want to return a value?" +msgstr "" + +#: src/concurrency/threads.md +msgid "Look at docs again:" +msgstr "" + +#: src/concurrency/threads.md +msgid "" +"[`thread::spawn`](https://doc.rust-lang.org/std/thread/fn.spawn.html)'s " +"closure returns `T`" +msgstr "" + +#: src/concurrency/threads.md +msgid "" +"`JoinHandle` [`.join()`](https://doc.rust-lang.org/std/thread/struct." +"JoinHandle.html#method.join) returns `thread::Result`" msgstr "" #: src/concurrency/threads.md msgid "" "Use the `Result` return value from `handle.join()` to get access to the " -"panic payload. This is a good time to talk about [`Any`](https://doc.rust-" -"lang.org/std/any/index.html)." +"returned value." +msgstr "" + +#: src/concurrency/threads.md +msgid "Ok, what about the other case?" +msgstr "" + +#: src/concurrency/threads.md +msgid "Trigger a panic in the thread. Note that this doesn't panic `main`." +msgstr "" + +#: src/concurrency/threads.md +msgid "" +"Access the panic payload. This is a good time to talk about [`Any`](https://" +"doc.rust-lang.org/std/any/index.html)." +msgstr "" + +#: src/concurrency/threads.md +msgid "Now we can return values from threads! What about taking inputs?" +msgstr "" + +#: src/concurrency/threads.md +msgid "Capture something by reference in the thread closure." +msgstr "" + +#: src/concurrency/threads.md +msgid "An error message indicates we must move it." +msgstr "" + +#: src/concurrency/threads.md +msgid "Move it in, see we can compute and then return a derived value." +msgstr "" + +#: src/concurrency/threads.md +msgid "If we want to borrow?" +msgstr "" + +#: src/concurrency/threads.md +msgid "" +"Main kills child threads when it returns, but another function would just " +"return and leave them running." +msgstr "" + +#: src/concurrency/threads.md +msgid "That would be stack use-after-return, which violates memory safety!" +msgstr "" + +#: src/concurrency/threads.md +msgid "How do we avoid this? see next slide." msgstr "" #: src/concurrency/scoped-threads.md @@ -17527,7 +17602,7 @@ msgstr "" #: src/concurrency/channels/bounded.md msgid "" "A bounded channel with a size of zero is called a \"rendezvous channel\". " -"Every send will block the current thread until another thread calls `read`." +"Every send will block the current thread until another thread calls `recv`." msgstr "" #: src/concurrency/send-sync.md @@ -17643,6 +17718,10 @@ msgstr "" msgid "`Mutex`: Explicitly thread-safe via internal locking." msgstr "" +#: src/concurrency/send-sync/examples.md +msgid "`mpsc::Sender`: As of 1.72.0." +msgstr "" + #: src/concurrency/send-sync/examples.md msgid "`AtomicBool`, `AtomicU8`, ...: Uses special atomic instructions." msgstr "" @@ -17663,10 +17742,6 @@ msgid "" "Typically because of interior mutability:" msgstr "" -#: src/concurrency/send-sync/examples.md -msgid "`mpsc::Sender`" -msgstr "" - #: src/concurrency/send-sync/examples.md msgid "`mpsc::Receiver`" msgstr "" @@ -17840,7 +17915,7 @@ msgid "Let us see `Arc` and `Mutex` in action:" msgstr "" #: src/concurrency/shared_state/example.md -msgid "// use std::sync::{Arc, Mutex};\n" +msgid "// use std::sync::{Arc, Mutex};" msgstr "" #: src/concurrency/shared_state/example.md @@ -17914,10 +17989,17 @@ msgstr "" #: src/exercises/concurrency/dining-philosophers.md #: src/exercises/concurrency/dining-philosophers-async.md -msgid "" -"// left_fork: ...\n" -" // right_fork: ...\n" -" // thoughts: ...\n" +msgid "// left_fork: ..." +msgstr "" + +#: src/exercises/concurrency/dining-philosophers.md +#: src/exercises/concurrency/dining-philosophers-async.md +msgid "// right_fork: ..." +msgstr "" + +#: src/exercises/concurrency/dining-philosophers.md +#: src/exercises/concurrency/dining-philosophers-async.md +msgid "// thoughts: ..." msgstr "" #: src/exercises/concurrency/dining-philosophers.md @@ -17928,9 +18010,7 @@ msgid "\"Eureka! {} has a new idea!\"" msgstr "" #: src/exercises/concurrency/dining-philosophers.md -#: src/exercises/concurrency/dining-philosophers-async.md -#: src/exercises/concurrency/solutions-afternoon.md -msgid "// Pick up forks...\n" +msgid "// Pick up forks..." msgstr "" #: src/exercises/concurrency/dining-philosophers.md @@ -17977,24 +18057,21 @@ msgstr "" #: src/exercises/concurrency/dining-philosophers.md #: src/exercises/concurrency/dining-philosophers-async.md -#: src/exercises/concurrency/solutions-afternoon.md -msgid "// Create forks\n" +msgid "// Create forks" msgstr "" #: src/exercises/concurrency/dining-philosophers.md #: src/exercises/concurrency/dining-philosophers-async.md -#: src/exercises/concurrency/solutions-afternoon.md -msgid "// Create philosophers\n" +msgid "// Create philosophers" msgstr "" #: src/exercises/concurrency/dining-philosophers.md -msgid "// Make each of them think and eat 100 times\n" +msgid "// Make each of them think and eat 100 times" msgstr "" #: src/exercises/concurrency/dining-philosophers.md #: src/exercises/concurrency/dining-philosophers-async.md -#: src/exercises/concurrency/solutions-afternoon.md -msgid "// Output their thoughts\n" +msgid "// Output their thoughts" msgstr "" #: src/exercises/concurrency/dining-philosophers.md @@ -18022,7 +18099,13 @@ msgstr "" #: src/exercises/concurrency/link-checker.md msgid "" "For this, you will need an HTTP client such as [`reqwest`](https://docs.rs/" -"reqwest/). Create a new Cargo project and `reqwest` it as a dependency with:" +"reqwest/). You will also need a way to find links, we can use [`scraper`]" +"(https://docs.rs/scraper/). Finally, we'll need some way of handling errors, " +"we will use [`thiserror`](https://docs.rs/thiserror/)." +msgstr "" + +#: src/exercises/concurrency/link-checker.md +msgid "Create a new Cargo project and `reqwest` it as a dependency with:" msgstr "" #: src/exercises/concurrency/link-checker.md @@ -18031,18 +18114,6 @@ msgid "" "`Cargo.toml` file by hand. Add the dependencies listed below." msgstr "" -#: src/exercises/concurrency/link-checker.md -msgid "" -"You will also need a way to find links. We can use [`scraper`](https://docs." -"rs/scraper/) for that:" -msgstr "" - -#: src/exercises/concurrency/link-checker.md -msgid "" -"Finally, we'll need some way of handling errors. We use [`thiserror`]" -"(https://docs.rs/thiserror/) for that:" -msgstr "" - #: src/exercises/concurrency/link-checker.md msgid "" "The `cargo add` calls will update the `Cargo.toml` file to look like this:" @@ -18637,10 +18708,6 @@ msgstr "" msgid "\"Failed to send cat.\"" msgstr "" -#: src/async/control-flow/select.md -msgid "\"Rex\"" -msgstr "" - #: src/async/control-flow/select.md msgid "\"Failed to send dog.\"" msgstr "" @@ -18796,17 +18863,19 @@ msgid "" msgstr "" #: src/async/pitfalls/pin.md -msgid "" -"// A work item. In this case, just sleep for the given time and respond\n" -"// with a message on the `respond_on` channel.\n" +msgid "// A work item. In this case, just sleep for the given time and respond" msgstr "" #: src/async/pitfalls/pin.md -msgid "// A worker which listens for work on a queue and performs it.\n" +msgid "// with a message on the `respond_on` channel." msgstr "" #: src/async/pitfalls/pin.md -msgid "// Pretend to work.\n" +msgid "// A worker which listens for work on a queue and performs it." +msgstr "" + +#: src/async/pitfalls/pin.md +msgid "// Pretend to work." msgstr "" #: src/async/pitfalls/pin.md @@ -18814,11 +18883,11 @@ msgid "\"failed to send response\"" msgstr "" #: src/async/pitfalls/pin.md -msgid "// TODO: report number of iterations every 100ms\n" +msgid "// TODO: report number of iterations every 100ms" msgstr "" #: src/async/pitfalls/pin.md -msgid "// A requester which requests work and waits for it to complete.\n" +msgid "// A requester which requests work and waits for it to complete." msgstr "" #: src/async/pitfalls/pin.md @@ -18908,16 +18977,35 @@ msgstr "" #: src/async/pitfalls/async-traits.md msgid "" -"Async methods in traits are not yet supported in the stable channel ([An " -"experimental feature exists in nightly and should be stabilized in the mid " -"term.](https://blog.rust-lang.org/inside-rust/2022/11/17/async-fn-in-trait-" -"nightly.html))" +"Async methods in traits are were stabilized only recently, in the 1.75 " +"release. This required support for using return-position `impl Trait` (RPIT) " +"in traits, as the desugaring for `async fn` includes `-> impl Future`." msgstr "" #: src/async/pitfalls/async-traits.md msgid "" -"The crate [async_trait](https://docs.rs/async-trait/latest/async_trait/) " -"provides a workaround through a macro:" +"However, even with the native support today there are some pitfalls around " +"`async fn` and RPIT in traits:" +msgstr "" + +#: src/async/pitfalls/async-traits.md +msgid "" +"Return-position impl Trait captures all in-scope lifetimes (so some patterns " +"of borrowing cannot be expressed)" +msgstr "" + +#: src/async/pitfalls/async-traits.md +msgid "" +"Traits whose methods use return-position `impl trait` or `async` are not " +"`dyn` compatible." +msgstr "" + +#: src/async/pitfalls/async-traits.md +msgid "" +"If we do need `dyn` support, the crate [async_trait](https://docs.rs/async-" +"trait/latest/async_trait/) provides a workaround through a macro, with some " +"caveats:" msgstr "" #: src/async/pitfalls/async-traits.md @@ -18998,7 +19086,7 @@ msgid "" msgstr "" #: src/async/pitfalls/cancellation.md -msgid "// prefix buf and bytes with self.\n" +msgid "// prefix buf and bytes with self." msgstr "" #: src/async/pitfalls/cancellation.md @@ -19058,8 +19146,11 @@ msgid "" msgstr "" #: src/exercises/concurrency/dining-philosophers-async.md -#: src/exercises/concurrency/solutions-afternoon.md -msgid "// Make them think and eat\n" +msgid "// Keep trying until we have both forks" +msgstr "" + +#: src/exercises/concurrency/dining-philosophers-async.md +msgid "// Make them think and eat" msgstr "" #: src/exercises/concurrency/dining-philosophers-async.md @@ -19127,9 +19218,9 @@ msgid "" "\n" "[dependencies]\n" "futures-util = { version = \"0.3.30\", features = [\"sink\"] }\n" -"http = \"1.0.0\"\n" -"tokio = { version = \"1.28.1\", features = [\"full\"] }\n" -"tokio-websockets = { version = \"0.5.1\", features = [\"client\", " +"http = \"1.1.0\"\n" +"tokio = { version = \"1.37.0\", features = [\"full\"] }\n" +"tokio-websockets = { version = \"0.7.0\", features = [\"client\", " "\"fastrand\", \"server\", \"sha1_smol\"] }\n" "```" msgstr "" @@ -19200,7 +19291,7 @@ msgid "_src/bin/server.rs_:" msgstr "" #: src/exercises/concurrency/chat-app.md -msgid "// TODO: For a hint, see the description of the task below.\n" +msgid "// TODO: For a hint, see the description of the task below." msgstr "" #: src/exercises/concurrency/chat-app.md @@ -19282,10 +19373,24 @@ msgstr "" msgid "([back to exercise](dining-philosophers-async.md))" msgstr "" +#: src/exercises/concurrency/solutions-afternoon.md +msgid "// Keep trying until we have both forks\n" +msgstr "" + +#: src/exercises/concurrency/solutions-afternoon.md +msgid "// Pick up forks...\n" +msgstr "" + #: src/exercises/concurrency/solutions-afternoon.md msgid "" -"// Add a delay before picking the second fork to allow the execution\n" -" // to transfer to another task\n" +"// If we didn't get the left fork, drop the right fork if we\n" +" // have it and let other tasks make progress.\n" +msgstr "" + +#: src/exercises/concurrency/solutions-afternoon.md +msgid "" +"// If we didn't get the right fork, drop the left fork and let\n" +" // other tasks make progress.\n" msgstr "" #: src/exercises/concurrency/solutions-afternoon.md @@ -19293,16 +19398,25 @@ msgid "// The locks are dropped here\n" msgstr "" #: src/exercises/concurrency/solutions-afternoon.md -msgid "" -"// To avoid a deadlock, we have to break the symmetry\n" -" // somewhere. This will swap the forks without deinitializing\n" -" // either of them.\n" +msgid "// Create forks\n" +msgstr "" + +#: src/exercises/concurrency/solutions-afternoon.md +msgid "// Create philosophers\n" msgstr "" #: src/exercises/concurrency/solutions-afternoon.md msgid "// tx is dropped here, so we don't need to explicitly drop it later\n" msgstr "" +#: src/exercises/concurrency/solutions-afternoon.md +msgid "// Make them think and eat\n" +msgstr "" + +#: src/exercises/concurrency/solutions-afternoon.md +msgid "// Output their thoughts\n" +msgstr "" + #: src/exercises/concurrency/solutions-afternoon.md msgid "\"Here is a thought: {thought}\"" msgstr "" @@ -19656,7 +19770,7 @@ msgstr "" #: src/glossary.md msgid "" "Rust Fundamentals: \n" -"Days 1 to 3 of this course." +"Days 1 to 4 of this course." msgstr "" #: src/glossary.md @@ -19987,6 +20101,95 @@ msgid "" "directory for details, including the license terms." msgstr "" +#, fuzzy +#~ msgid "String References" +#~ msgstr "Висячие ссылки" + +#, fuzzy +#~ msgid "`String` - a modifiable, owned string." +#~ msgstr "`String` --- изменяемый строковый буфер." + +#~ msgid "Much of the Rust syntax will be familiar to you from C, C++ or Java:" +#~ msgstr "Большая часть синтаксиса Rust будет знакома вам по C, C++ или Java:" + +#, fuzzy +#~ msgid "Blocks are delimited by curly braces." +#~ msgstr "Блоки и области видимости разделены фигурными скобками." + +#~ msgid "" +#~ "Line comments are started with `//`, block comments are delimited by `/" +#~ "* ... */`." +#~ msgstr "" +#~ "Строковые комментарии начинаются с `//`, блочные комментарии заключены в " +#~ "`/* …*/`." + +#~ msgid "Keywords like `if` and `while` work the same." +#~ msgstr "Ключевые слова, такие как `if` и `while`, работают так же." + +#~ msgid "Variable assignment is done with `=`, comparison is done with `==`." +#~ msgstr "" +#~ "Присваивание переменной выполняется с помощью `=`, сравнение выполняется " +#~ "с помощью `==`." + +#~ msgid "`[T; N]`" +#~ msgstr "`[T; N]`" + +#~ msgid "`[20, 30, 40]`, `[0; 3]`" +#~ msgstr "`[20, 30, 40]`, `[0; 3]`" + +#~ msgid "`()`, `(T,)`, `(T1, T2)`, ..." +#~ msgstr "`()`, `(T,)`, `(T1, T2)`, ..." + +#~ msgid "`()`, `('x',)`, `('x', 1.2)`, ..." +#~ msgstr "`()`, `('x',)`, `('x', 1.2)`, ..." + +#~ msgid "Array assignment and access:" +#~ msgstr "Объявление массива и доступ к нему:" + +#~ msgid "Tuple assignment and access:" +#~ msgstr "Объявление кортежа и доступ к нему:" + +#~ msgid "Arrays:" +#~ msgstr "Массивы:" + +#~ msgid "Tuples:" +#~ msgstr "Кортежи:" + +#, fuzzy +#~ 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 "" +#~ "Пустой кортеж `()` также известен как ”единичный тип”. Это одновременно и " +#~ "тип, и единственное допустимое значение этого типа --- и тип, и его " +#~ "значение выражаются как `()`. Он используется, например, для указания " +#~ "того, что функция или выражение не имеет возвращаемого значения, как мы " +#~ "увидим на следующем слайде." + +#, fuzzy +#~ msgid "" +#~ "You can think of it as `void` that can be familiar to you from other " +#~ "programming languages." +#~ msgstr "" +#~ "Вы можете думать о нем как о `void`, который может быть знаком вам по " +#~ "другим языкам программирования." + +#, fuzzy +#~ msgid "Lives for the entire duration of the program" +#~ msgstr "Функция `main` является точкой входа в программу." + +#~ msgid "Rust terminology:" +#~ msgstr "Терминология Rust:" + +#~ msgid "`&str` an immutable reference to a string slice." +#~ msgstr "`&str` --- неизменяемая ссылка на срез строки." + +#~ msgid "`String` a mutable string buffer." +#~ msgstr "`String` --- изменяемый строковый буфер." + #~ msgid "Why Rust?" #~ msgstr "Почему Rust?" @@ -20551,9 +20754,6 @@ msgstr "" #~ msgid "`String` vs `str`" #~ msgstr "String и str" -#~ msgid "We can now understand the two string types in Rust:" -#~ msgstr "Теперь давайте разберемся с двумя типами строк в Rust:" - #~ msgid "" #~ "You can borrow `&str` slices from `String` via `&` and optionally range " #~ "selection." @@ -21237,10 +21437,6 @@ msgstr "" #~ "Скопируйте приведенный ниже код в и " #~ "реализуйте функции:" -#, fuzzy -#~ msgid "Pattern matching" -#~ msgstr "Перечисления и сопоставление с образцом." - #~ msgid "Day 1: Basic Rust, ownership and the borrow checker." #~ msgstr "День 1: Базовый Rust, владение и анализатор заимствований."