From c5ed0dee56c3e35e6eeddc45b6fd7cd46af1c76a Mon Sep 17 00:00:00 2001 From: Henri Fontana Date: Thu, 7 Mar 2024 09:14:41 -0800 Subject: [PATCH 1/5] zh-TW: cr2 Day 2 translations --- po/zh-TW.po | 523 +++++++++++++++++++++++++++++++--------------------- 1 file changed, 314 insertions(+), 209 deletions(-) diff --git a/po/zh-TW.po b/po/zh-TW.po index 85244e9e4ba..dbb9bef87ad 100644 --- a/po/zh-TW.po +++ b/po/zh-TW.po @@ -4797,66 +4797,66 @@ msgstr "模式配對:解構列舉、結構和陣列。" #: src/welcome-day-2.md msgid "Methods: associating functions with types." -msgstr "" +msgstr "方法:將函式與型別建立關聯。" #: src/welcome-day-2.md msgid "Traits: behaviors shared by multiple types." -msgstr "" +msgstr "特徵:由多種型別共用的行為。" #: src/welcome-day-2.md msgid "Generics: parameterizing types on other types." -msgstr "" +msgstr "泛型:在其他型別上將型別參數化。" #: src/welcome-day-2.md msgid "" "Standard library types and traits: a tour of Rust's rich standard library." -msgstr "" +msgstr "標準程式庫的型別和特徵:一覽 Rust 豐富的標準程式庫。" #: src/welcome-day-2.md msgid "[Welcome](./welcome-day-2.md) (3 minutes)" -msgstr "" +msgstr "[歡迎](./welcome-day-2.md) (3 分鐘)" #: src/welcome-day-2.md #, fuzzy msgid "[Pattern Matching](./pattern-matching.md) (1 hour)" -msgstr "" -"如要進一步瞭解 Rust 中的模式,請參閱「[模式比對](../pattern-matching.md)」。" +msgstr "[解構](./pattern-matching/destructuring.md) (10 分鐘)" #: src/welcome-day-2.md msgid "[Methods and Traits](./methods-and-traits.md) (45 minutes)" -msgstr "" +msgstr "[方法和特徵](./methods-and-traits.md) (45 分鐘)" #: src/welcome-day-2.md msgid "[Generics](./generics.md) (40 minutes)" -msgstr "" +msgstr "[泛型](./generics.md) (40 分鐘)" #: src/welcome-day-2.md msgid "" "Including 10 minute breaks, this session should take about 2 hours and 50 " "minutes" -msgstr "" +msgstr "講解這個主題大約需要 2 小時 50 分鐘" #: src/pattern-matching.md +#, fuzzy msgid "[Matching Values](./pattern-matching/match.md) (10 minutes)" -msgstr "" +msgstr "[解構](./pattern-matching/destructuring.md) (10 分鐘)" #: src/pattern-matching.md msgid "[Destructuring](./pattern-matching/destructuring.md) (10 minutes)" -msgstr "" +msgstr "[解構](./pattern-matching/destructuring.md) (10 分鐘)" #: src/pattern-matching.md msgid "[Let Control Flow](./pattern-matching/let-control-flow.md) (10 minutes)" -msgstr "" +msgstr "[Let 控制流程](./pattern-matching/let-control-flow.md) (10 分鐘)" #: src/pattern-matching.md msgid "" "[Exercise: Expression Evaluation](./pattern-matching/exercise.md) (30 " "minutes)" -msgstr "" +msgstr "[練習:運算式求值](./pattern-matching/exercise.md) (30 分鐘)" #: src/pattern-matching.md src/memory-management.md msgid "This segment should take about 1 hour" -msgstr "" +msgstr "講解這個主題大約需要 1 小時" #: src/pattern-matching/match.md #, fuzzy @@ -4873,11 +4873,11 @@ msgstr "模式可以是簡單的值,類似 C 和 C++ 中的 `switch`:" #: src/pattern-matching/match.md msgid "'x'" -msgstr "" +msgstr "'x'" #: src/pattern-matching/match.md msgid "'q'" -msgstr "" +msgstr "'q'" #: src/pattern-matching/match.md msgid "\"Quitting\"" @@ -4885,20 +4885,22 @@ msgstr "" #: src/pattern-matching/match.md src/std-traits/solution.md #: src/error-handling/exercise.md src/error-handling/solution.md +#, fuzzy msgid "'a'" -msgstr "" +msgstr "'a'" #: src/pattern-matching/match.md +#, fuzzy msgid "'s'" -msgstr "" +msgstr "'s'" #: src/pattern-matching/match.md msgid "'w'" -msgstr "" +msgstr "'w'" #: src/pattern-matching/match.md msgid "'d'" -msgstr "" +msgstr "'d'" #: src/pattern-matching/match.md msgid "\"Moving around\"" @@ -4907,12 +4909,12 @@ msgstr "" #: src/pattern-matching/match.md src/error-handling/exercise.md #: src/error-handling/solution.md msgid "'0'" -msgstr "" +msgstr "'0'" #: src/pattern-matching/match.md src/error-handling/exercise.md #: src/error-handling/solution.md msgid "'9'" -msgstr "" +msgstr "'9'" #: src/pattern-matching/match.md msgid "\"Number input\"" @@ -5003,7 +5005,7 @@ msgstr "只要運算式隸屬於具備 `|` 的模式之中,就會套用守衛 #: src/pattern-matching/destructuring.md msgid "Like tuples, structs and enums can also be destructured by matching:" -msgstr "" +msgstr "就像元組,結構體和列舉也可透過配對來解構:" #: src/pattern-matching/destructuring.md msgid "Structs" @@ -5011,15 +5013,15 @@ msgstr "結構體" #: src/pattern-matching/destructuring.md msgid "\"x.0 = 1, b = {b}, y = {y}\"" -msgstr "" +msgstr "\"x.0 = 1, b = {b}, y = {y}\"" #: src/pattern-matching/destructuring.md msgid "\"y = 2, x = {i:?}\"" -msgstr "" +msgstr "\"y = 2, x = {i:?}\"" #: src/pattern-matching/destructuring.md msgid "\"y = {y}, other fields were ignored\"" -msgstr "" +msgstr "\"y = {y}, other fields were ignored\"" #: src/pattern-matching/destructuring.md msgid "" @@ -5032,15 +5034,15 @@ msgstr "" #: src/pattern-matching/destructuring.md msgid "\"cannot divide {n} into two equal parts\"" -msgstr "" +msgstr "\"cannot divide {n} into two equal parts\"" #: src/pattern-matching/destructuring.md msgid "\"{n} divided in two is {half}\"" -msgstr "" +msgstr "\"{n} divided in two is {half}\"" #: src/pattern-matching/destructuring.md msgid "\"sorry, an error happened: {msg}\"" -msgstr "" +msgstr "\"sorry, an error happened: {msg}\"" #: src/pattern-matching/destructuring.md msgid "" @@ -5110,6 +5112,12 @@ msgid "" "io/rfcs/2005-match-ergonomics.html) appeared in Rust 2018. If you want to " "support older Rust, replace `msg` with `ref msg` in the pattern." msgstr "" +"將 `divide_in_two` 的結果儲存在 `result` 變數中,並在迴圈中 `match` 結果。由" +"於配對符合時會耗用 `msg`,因此這麼做並不會執行編譯。如要修正此問題,請配對 " +"`&result`,而非 `result`。這會讓 `msg` 成為參照,因此就不會遭到耗用。這個" +"[「人因工程學的配對」](https://rust-lang.github.io/rfcs/2005-match-" +"ergonomics.html)功能已於 Rust 2018 推出。如要支援舊版 Rust,請在模式中將 " +"`msg` 替換成 `ref msg`。" #: src/pattern-matching/let-control-flow.md msgid "" @@ -5122,9 +5130,8 @@ msgid "`if let` expressions" msgstr "`if let` 運算式" #: src/pattern-matching/let-control-flow.md -#, fuzzy msgid "`while let` expressions" -msgstr "while let 運算式" +msgstr "`while let` 運算式" #: src/pattern-matching/let-control-flow.md msgid "`match` expressions" @@ -5141,12 +5148,11 @@ msgstr "" #: src/pattern-matching/let-control-flow.md msgid "\"slept for {:?}\"" -msgstr "" +msgstr "\"slept for {:?}\"" #: src/pattern-matching/let-control-flow.md -#, fuzzy msgid "`let else` expressions" -msgstr "`if let` 運算式" +msgstr "`let else` 運算式" #: src/pattern-matching/let-control-flow.md msgid "" @@ -5155,28 +5161,31 @@ msgid "" "let_else.html). The \"else\" case must diverge (`return`, `break`, or panic " "- anything but falling off the end of the block)." msgstr "" +"如果是要配對模式並從函式傳回的常見情況,請使用 [`let else`](https://doc.rust-" +"lang.org/rust-by-example/flow_control/let_else.html)。如果是「其他」情況,則" +"必須發散 (`return`、`break` 或恐慌,也就是落在區塊結尾之外的任何情況)。" #: src/pattern-matching/let-control-flow.md msgid "\"got None\"" -msgstr "" +msgstr "\"got None\"" #: src/pattern-matching/let-control-flow.md msgid "\"got empty string\"" -msgstr "" +msgstr "\"got empty string\"" #: src/pattern-matching/let-control-flow.md msgid "\"not a hex digit\"" -msgstr "" +msgstr "\"not a hex digit\"" #: src/pattern-matching/let-control-flow.md src/pattern-matching/solution.md msgid "\"result: {:?}\"" -msgstr "" +msgstr "\"result: {:?}\"" #: src/pattern-matching/let-control-flow.md src/generics/trait-bounds.md #: src/smart-pointers/solution.md src/testing/solution.md #: src/android/testing.md src/android/testing/googletest.md msgid "\"foo\"" -msgstr "" +msgstr "\"foo\"" #: src/pattern-matching/let-control-flow.md msgid "" @@ -5202,7 +5211,7 @@ msgstr "" #: src/pattern-matching/let-control-flow.md msgid "if-let" -msgstr "" +msgstr "if-let" #: src/pattern-matching/let-control-flow.md #, fuzzy @@ -5222,7 +5231,7 @@ msgstr "與 `match` 不同,`if let` 不會為模式比對支援成立條件子 #: src/pattern-matching/let-control-flow.md msgid "let-else" -msgstr "" +msgstr "let-else" #: src/pattern-matching/let-control-flow.md msgid "" @@ -5230,15 +5239,16 @@ msgid "" "flattening this nested code. Rewrite the awkward version for students, so " "they can see the transformation." msgstr "" +"如上所示,`if-let` 可能會越加越多。`let-else` 結構支援壓平合併這個巢狀程式" +"碼。請為學生重新編寫這個冗長的版本,讓他們見識改寫的效果。" #: src/pattern-matching/let-control-flow.md msgid "The rewritten version is:" -msgstr "" +msgstr "重新編寫的版本如下:" #: src/pattern-matching/let-control-flow.md -#, fuzzy msgid "while-let" -msgstr "`while let` 迴圈" +msgstr "while-let" #: src/pattern-matching/let-control-flow.md msgid "" @@ -5258,7 +5268,7 @@ msgstr "" #: src/pattern-matching/exercise.md msgid "Let's write a simple recursive evaluator for arithmetic expressions." -msgstr "" +msgstr "我們現在要為算術運算式編寫簡單的遞迴評估器。" #: src/pattern-matching/exercise.md msgid "" @@ -5267,6 +5277,9 @@ msgid "" "tests. To evaluate a boxed expression, use the deref operator (`*`) to " "\"unbox\" it: `eval(*boxed_expr)`." msgstr "" +"這裡的 `Box` 型別是智慧指標,我們會在本課程的後續部分詳細說明。運算式可透過 " +"`Box::new`「裝箱」,如測試中所示。如要求裝箱運算式的值,請使用 deref 運算子 " +"(`*`) 來「開箱」:`eval(*boxed_expr)`。" #: src/pattern-matching/exercise.md msgid "" @@ -5276,6 +5289,9 @@ msgid "" "(`Ok(Value)`) or an error (`Err(String)`). We will cover this type in detail " "later." msgstr "" +"部分運算式無法求值,且會傳回錯誤。標準 [`Result`](https://doc." +"rust-lang.org/std/result/enum.Result.html) 型別是一種列舉,用於表示成功值 " +"(`Ok(Value) )`) 或錯誤 (`Err(String)`)。我們稍後會詳細說明這種型別。" #: src/pattern-matching/exercise.md msgid "" @@ -5284,53 +5300,58 @@ msgid "" "`todo!()` and get the tests to pass one-by-one. You can also skip a test " "temporarily with `#[ignore]`:" msgstr "" +"請複製程式碼並貼到 Rust Playground,然後開始實作 `eval`。最終成品應會通過測" +"試。使用 `todo!()` 讓測試逐一通過可能有所幫助,但您也可以使用 `#[ignore]` 暫" +"時略過測試:" #: src/pattern-matching/exercise.md msgid "" "If you finish early, try writing a test that results in division by zero or " "integer overflow. How could you handle this with `Result` instead of a panic?" msgstr "" +"如果您提前完成操作,不妨試著編寫一個以零為除數或會整數溢位的測試。該如何利用 " +"`Result` (而非恐慌) 處理這種情況?" #: src/pattern-matching/exercise.md src/pattern-matching/solution.md msgid "/// An operation to perform on two subexpressions.\n" -msgstr "" +msgstr "/// An operation to perform on two subexpressions.\n" #: src/pattern-matching/exercise.md src/pattern-matching/solution.md msgid "/// An expression, in tree form.\n" -msgstr "" +msgstr "/// An expression, in tree form.\n" #: src/pattern-matching/exercise.md src/pattern-matching/solution.md msgid "/// An operation on two subexpressions.\n" -msgstr "" +msgstr "/// An operation on two subexpressions.\n" #: src/pattern-matching/exercise.md src/pattern-matching/solution.md msgid "/// A literal value\n" -msgstr "" +msgstr "/// A literal value\n" #: src/pattern-matching/exercise.md src/pattern-matching/solution.md msgid "\"division by zero\"" -msgstr "" +msgstr "\"division by zero\"" #: src/pattern-matching/solution.md msgid "\"expr: {:?}\"" -msgstr "" +msgstr "\"expr: {:?}\"" #: src/methods-and-traits.md msgid "[Methods](./methods-and-traits/methods.md) (10 minutes)" -msgstr "" +msgstr "[方法](./methods-and-traits/methods.md) (10 分鐘)" #: src/methods-and-traits.md msgid "[Traits](./methods-and-traits/traits.md) (10 minutes)" -msgstr "" +msgstr "[特徵](./methods-and-traits/traits.md) (10 分鐘)" #: src/methods-and-traits.md msgid "[Deriving](./methods-and-traits/deriving.md) (3 minutes)" -msgstr "" +msgstr "[衍生](./methods-and-traits/deriving.md) (3 分鐘)" #: src/methods-and-traits.md msgid "" "[Exercise: Generic Logger](./methods-and-traits/exercise.md) (20 minutes)" -msgstr "" +msgstr "[練習:泛型 Logger](./methods-and-traits/exercise.md) (20 分鐘)" #: src/methods-and-traits/methods.md msgid "" @@ -5341,39 +5362,39 @@ msgstr "" #: src/methods-and-traits/methods.md msgid "// No receiver, a static method\n" -msgstr "" +msgstr "// No receiver, a static method\n" #: src/methods-and-traits/methods.md msgid "// Exclusive borrowed read-write access to self\n" -msgstr "" +msgstr "// Exclusive borrowed read-write access to self\n" #: src/methods-and-traits/methods.md msgid "// Shared and read-only borrowed access to self\n" -msgstr "" +msgstr "// Shared and read-only borrowed access to self\n" #: src/methods-and-traits/methods.md msgid "\"Recorded {} laps for {}:\"" -msgstr "" +msgstr "\"Recorded {} laps for {}:\"" #: src/methods-and-traits/methods.md msgid "\"Lap {idx}: {lap} sec\"" -msgstr "" +msgstr "\"Lap {idx}: {lap} sec\"" #: src/methods-and-traits/methods.md msgid "// Exclusive ownership of self\n" -msgstr "" +msgstr "// Exclusive ownership of self\n" #: src/methods-and-traits/methods.md msgid "\"Race {} is finished, total lap time: {}\"" -msgstr "" +msgstr "\"Race {} is finished, total lap time: {}\"" #: src/methods-and-traits/methods.md msgid "\"Monaco Grand Prix\"" -msgstr "" +msgstr "\"Monaco Grand Prix\"" #: src/methods-and-traits/methods.md msgid "// race.add_lap(42);\n" -msgstr "" +msgstr "// race.add_lap(42);\n" #: src/methods-and-traits/methods.md #, fuzzy @@ -5503,7 +5524,7 @@ msgstr "" msgid "" "A trait defines a number of methods that types must have in order to " "implement the trait." -msgstr "" +msgstr "特徵用於定義型別必須具有哪幾個方法,才能實作該特徵。" #: src/methods-and-traits/traits.md msgid "" @@ -5518,23 +5539,24 @@ msgstr "實作不安全的特徵" #: src/methods-and-traits/traits/implementing.md msgid "\"Oh you're a cutie! What's your name? {}\"" -msgstr "" +msgstr "\"Oh you're a cutie! What's your name? {}\"" #: src/methods-and-traits/traits/implementing.md #: src/smart-pointers/trait-objects.md msgid "\"Woof, my name is {}!\"" -msgstr "" +msgstr "\"Woof, my name is {}!\"" #: src/methods-and-traits/traits/implementing.md #: src/smart-pointers/trait-objects.md msgid "\"Fido\"" -msgstr "" +msgstr "\"Fido\"" #: src/methods-and-traits/traits/implementing.md +#, fuzzy msgid "" "To implement `Trait` for `Type`, you use an `impl Trait for Type { .. }` " "block." -msgstr "" +msgstr "特徵會在 `impl for { .. }` 區塊中實作。" #: src/methods-and-traits/traits/implementing.md msgid "" @@ -5572,27 +5594,27 @@ msgstr "" msgid "" "Supported traits can be automatically implemented for your custom types, as " "follows:" -msgstr "" +msgstr "系統會自動為您的自訂型別實作支援的特徵,如下所示:" #: src/methods-and-traits/deriving.md msgid "// Default trait adds `default` constructor.\n" -msgstr "" +msgstr "// Default trait adds `default` constructor.\n" #: src/methods-and-traits/deriving.md msgid "// Clone trait adds `clone` method.\n" -msgstr "" +msgstr "// Clone trait adds `clone` method.\n" #: src/methods-and-traits/deriving.md msgid "\"EldurScrollz\"" -msgstr "" +msgstr "\"EldurScrollz\"" #: src/methods-and-traits/deriving.md msgid "// Debug trait adds support for printing with `{:?}`.\n" -msgstr "" +msgstr "// Debug trait adds support for printing with `{:?}`.\n" #: src/methods-and-traits/deriving.md msgid "\"{:?} vs. {:?}\"" -msgstr "" +msgstr "\"{:?} vs. {:?}\"" #: src/methods-and-traits/deriving.md msgid "" @@ -5600,6 +5622,8 @@ msgid "" "macros to add useful functionality. For example, `serde` can derive " "serialization support for a struct using `#[derive(Serialize)]`." msgstr "" +"衍生會透過巨集實作,許多 Crate 都提供實用的衍生巨集,以便新增實用功能。例如," +"`serde` 可以使用 `#[derive(Serialize)]`,為結構體衍生序列化支援。" #: src/methods-and-traits/exercise.md msgid "" @@ -5608,6 +5632,9 @@ msgid "" "In testing, this might put messages in the test logfile, while in a " "production build it would send messages to a log server." msgstr "" +"我們來設計一個簡單的記錄公用程式,使用 `Logger` 特徵搭配 `log` 方法。如果程式" +"碼可能會記錄相關進度,就可以採用 `&impl Logger`。在測試過程中,這可能會將訊息" +"置於測試記錄檔中;而在實際版本中,則會將訊息傳送至記錄伺服器。" #: src/methods-and-traits/exercise.md msgid "" @@ -5615,6 +5642,8 @@ msgid "" "verbosity. Your task is to write a `VerbosityFilter` type that will ignore " "messages above a maximum verbosity." msgstr "" +"不過,下方的 `StderrLogger` 會記錄詳細程度不限的所有訊息。您的任務是編寫 " +"`VerbosityFilter` 型別,忽略超出詳細程度上限的訊息。" #: src/methods-and-traits/exercise.md msgid "" @@ -5622,50 +5651,52 @@ msgid "" "implementing that same trait, adding behavior in the process. What other " "kinds of wrappers might be useful in a logging utility?" msgstr "" +"以下是常見模式:結構體包裝一個特徵實作項目,並實作該相同特徵,在程序中加入行" +"為。想一想,還有哪些其他類型的包裝函式可能在記錄公用程式中派上用場?" #: src/methods-and-traits/exercise.md src/methods-and-traits/solution.md msgid "/// Log a message at the given verbosity level.\n" -msgstr "" +msgstr "/// Log a message at the given verbosity level.\n" #: src/methods-and-traits/exercise.md src/methods-and-traits/solution.md msgid "\"verbosity={verbosity}: {message}\"" -msgstr "" +msgstr "\"verbosity={verbosity}: {message}\"" #: src/methods-and-traits/exercise.md src/methods-and-traits/solution.md msgid "\"FYI\"" -msgstr "" +msgstr "\"FYI\"" #: src/methods-and-traits/exercise.md src/methods-and-traits/solution.md msgid "\"Uhoh\"" -msgstr "" +msgstr "\"Uhoh\"" #: src/methods-and-traits/exercise.md msgid "// TODO: Define and implement `VerbosityFilter`.\n" -msgstr "" +msgstr "// TODO: Define and implement `VerbosityFilter`.\n" #: src/methods-and-traits/solution.md msgid "/// Only log messages up to the given verbosity level.\n" -msgstr "" +msgstr "/// Only log messages up to the given verbosity level.\n" #: src/generics.md msgid "[Generic Functions](./generics/generic-functions.md) (5 minutes)" -msgstr "" +msgstr "[泛型函式](./generics/generic-functions.md) (5 分鐘)" #: src/generics.md msgid "[Generic Data Types](./generics/generic-data.md) (10 minutes)" -msgstr "" +msgstr "[泛型資料型別](./generics/generic-data.md) (10 分鐘)" #: src/generics.md msgid "[Trait Bounds](./generics/trait-bounds.md) (10 minutes)" -msgstr "" +msgstr "[特徵界線](./generics/trait-bounds.md) (10 分鐘)" #: src/generics.md msgid "[impl Trait](./generics/impl-trait.md) (5 minutes)" -msgstr "" +msgstr "[impl 特徵](./generics/impl-trait.md) (5 分鐘)" #: src/generics.md msgid "[Exercise: Generic min](./generics/exercise.md) (10 minutes)" -msgstr "" +msgstr "[練習:泛型 min](./generics/exercise.md) (10 分鐘)" #: src/generics/generic-functions.md #, fuzzy @@ -5678,29 +5709,29 @@ msgstr "" #: src/generics/generic-functions.md msgid "/// Pick `even` or `odd` depending on the value of `n`.\n" -msgstr "" +msgstr "/// Pick `even` or `odd` depending on the value of `n`.\n" #: src/generics/generic-functions.md msgid "\"picked a number: {:?}\"" -msgstr "" +msgstr "\"picked a number: {:?}\"" #: src/generics/generic-functions.md msgid "\"picked a tuple: {:?}\"" -msgstr "" +msgstr "\"picked a tuple: {:?}\"" #: src/generics/generic-functions.md msgid "\"dog\"" -msgstr "" +msgstr "\"dog\"" #: src/generics/generic-functions.md msgid "\"cat\"" -msgstr "" +msgstr "\"cat\"" #: src/generics/generic-functions.md msgid "" "Rust infers a type for T based on the types of the arguments and return " "value." -msgstr "" +msgstr "Rust 會根據引數型別和傳回的值來推斷 T 的型別。" #: src/generics/generic-functions.md msgid "" @@ -5710,6 +5741,10 @@ msgid "" "`n == 0`. Even if only the `pick` instantiation with integers is used, Rust " "still considers it invalid. C++ would let you do this." msgstr "" +"這與 C++ 範本類似,但 Rust 會立即對泛型函式進行部分編譯,因此函式必須適用於所" +"有符合限制條件的型別。舉例來說,如果 `n == 0`,請嘗試修改 `pick` 以傳回 " +"`even + odd`。即使只使用具有整數的 `pick` 建立例項,Rust 仍會將其視為無效。" +"但 C++ 就能讓您這麼做。" #: src/generics/generic-functions.md #, fuzzy @@ -5727,15 +5762,15 @@ msgstr "你可以使用泛型將具體的欄位型別抽象化:" #: src/generics/generic-data.md msgid "// fn set_x(&mut self, x: T)\n" -msgstr "" +msgstr "// fn set_x(&mut self, x: T)\n" #: src/generics/generic-data.md msgid "\"{integer:?} and {float:?}\"" -msgstr "" +msgstr "\"{integer:?} and {float:?}\"" #: src/generics/generic-data.md msgid "\"coords: {:?}\"" -msgstr "" +msgstr "\"coords: {:?}\"" #: src/generics/generic-data.md msgid "" @@ -5774,6 +5809,8 @@ msgid "" "code to allow points that have elements of different types, by using two " "type variables, e.g., `T` and `U`." msgstr "" +"請嘗試宣告新變數 `let p = Point { x: 5, y: 10.0 };`。您可以使用兩種型別變數來" +"更新程式碼,允許含有不同型別元素的點,例如:`T` 和 `U`。" #: src/generics/trait-bounds.md msgid "" @@ -5788,19 +5825,19 @@ msgstr "您可以使用 `T: Trait` 或 `impl Trait` 執行此操作:" #: src/generics/trait-bounds.md msgid "// struct NotClonable;\n" -msgstr "" +msgstr "// struct NotClonable;\n" #: src/generics/trait-bounds.md msgid "\"{pair:?}\"" -msgstr "" +msgstr "\"{pair:?}\"" #: src/generics/trait-bounds.md msgid "Try making a `NonClonable` and passing it to `duplicate`." -msgstr "" +msgstr "請嘗試建立 `NonClonable` 並將其傳送至 `duplicate`。" #: src/generics/trait-bounds.md msgid "When multiple traits are necessary, use `+` to join them." -msgstr "" +msgstr "如果需要多個特徵,請使用 `+` 彙整特徵。" #: src/generics/trait-bounds.md msgid "Show a `where` clause, students will encounter it when reading code." @@ -5827,6 +5864,8 @@ msgid "" "Note that Rust does not (yet) support specialization. For example, given the " "original `duplicate`, it is invalid to add a specialized `duplicate(a: u32)`." msgstr "" +"請注意,Rust 尚不支援特化。舉例來說,對於原始的 `duplicate`,您無法新增特化" +"的 `duplicate(a: u32)`。" #: src/generics/impl-trait.md msgid "" @@ -5839,18 +5878,20 @@ msgid "" "// Syntactic sugar for:\n" "// fn add_42_millions>(x: T) -> i32 {\n" msgstr "" +"// Syntactic sugar for:\n" +"// fn add_42_millions>(x: T) -> i32 {\n" #: src/generics/impl-trait.md msgid "\"{many}\"" -msgstr "" +msgstr "\"{many}\"" #: src/generics/impl-trait.md msgid "\"{many_more}\"" -msgstr "" +msgstr "\"{many_more}\"" #: src/generics/impl-trait.md msgid "\"debuggable: {debuggable:?}\"" -msgstr "" +msgstr "\"debuggable: {debuggable:?}\"" #: src/generics/impl-trait.md #, fuzzy @@ -5893,84 +5934,90 @@ msgid "" "What is the type of `debuggable`? Try `let debuggable: () = ..` to see what " "the error message shows." msgstr "" +"思考一下,`debuggable` 的型別為何?您可以嘗試使用 `let debuggable: () = ..` " +"查看錯誤訊息顯示的內容。" #: 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 "" +"在這個簡短練習中,您將使用 `LessThan` 特徵實作泛型 `min` 函式,藉此判定兩個值" +"中的最小值。" #: src/generics/exercise.md src/generics/solution.md msgid "/// Return true if self is less than other.\n" -msgstr "" +msgstr "/// Return true if self is less than other.\n" #: src/generics/exercise.md msgid "// TODO: implement the `min` function used in `main`.\n" -msgstr "" +msgstr "// TODO: implement the `min` function used in `main`.\n" #: src/generics/exercise.md src/generics/solution.md msgid "\"Shapiro\"" -msgstr "" +msgstr "\"Shapiro\"" #: src/generics/exercise.md src/generics/solution.md msgid "\"Baumann\"" -msgstr "" +msgstr "\"Baumann\"" #: src/welcome-day-2-afternoon.md msgid "[Standard Library Types](./std-types.md) (1 hour and 20 minutes)" -msgstr "" +msgstr "[標準程式庫型別](./std-types.md) (1 小時 20 分鐘)" #: src/welcome-day-2-afternoon.md msgid "[Standard Library Traits](./std-traits.md) (1 hour and 40 minutes)" -msgstr "" +msgstr "[標準程式庫特徵](./std-traits.md) (1 小時 40 分鐘)" #: src/welcome-day-2-afternoon.md msgid "" "Including 10 minute breaks, this session should take about 3 hours and 10 " "minutes" -msgstr "" +msgstr "講解這個主題大約需要 3 小時 10 分鐘" #: src/std-types.md msgid "[Standard Library](./std-types/std.md) (3 minutes)" -msgstr "" +msgstr "[標準程式庫](./std-types/std.md) (3 分鐘)" #: src/std-types.md msgid "[Documentation](./std-types/docs.md) (5 minutes)" -msgstr "" +msgstr "[說明文件](./std-types/docs.md) (5 分鐘)" #: src/std-types.md msgid "[Option](./std-types/option.md) (10 minutes)" -msgstr "" +msgstr "[選項](./std-types/option.md) (10 分鐘)" #: src/std-types.md msgid "[Result](./std-types/result.md) (10 minutes)" -msgstr "" +msgstr "[結果](./std-types/result.md) (10 分鐘)" #: src/std-types.md msgid "[String](./std-types/string.md) (10 minutes)" -msgstr "" +msgstr "[字串](./std-types/string.md) (10 分鐘)" #: src/std-types.md msgid "[Vec](./std-types/vec.md) (10 minutes)" -msgstr "" +msgstr "[Vec](./std-types/vec.md) (10 分鐘)" #: src/std-types.md msgid "[HashMap](./std-types/hashmap.md) (10 minutes)" -msgstr "" +msgstr "[HashMap](./std-types/hashmap.md) (10 分鐘)" #: src/std-types.md msgid "[Exercise: Counter](./std-types/exercise.md) (20 minutes)" -msgstr "" +msgstr "[練習:計數器](./std-types/exercise.md) (20 分鐘)" #: src/std-types.md msgid "This segment should take about 1 hour and 20 minutes" -msgstr "" +msgstr "講解這個主題大約需要 1 小時 20 分鐘" #: src/std-types.md msgid "" "For each of the slides in this section, spend some time reviewing the " "documentation pages, highlighting some of the more common methods." msgstr "" +"請針對這節的每張投影片,花點時間帶學員詳讀說明文件頁面,並向他們強調一些較常" +"見的方法。" #: src/std-types/std.md #, fuzzy @@ -6011,7 +6058,7 @@ msgstr "嵌入式 Rust 應用程式通常只使用 `core`,偶爾會使用 `all #: src/std-types/docs.md msgid "Rust comes with extensive documentation. For example:" -msgstr "" +msgstr "Rust 說明文件的主題涵蓋甚廣,包括:" #: src/std-types/docs.md #, fuzzy @@ -6027,6 +6074,8 @@ msgid "" "Primitive types like [`u8`](https://doc.rust-lang.org/stable/std/primitive." "u8.html)." msgstr "" +"基本型別,例如 [`u8`](https://doc.rust-lang.org/stable/std/primitive.u8." +"html)。" #: src/std-types/docs.md #, fuzzy @@ -6040,7 +6089,7 @@ msgstr "" #: src/std-types/docs.md msgid "In fact, you can document your own code:" -msgstr "" +msgstr "您其實可以將程式碼記錄下來:" #: src/std-types/docs.md msgid "" @@ -6049,6 +6098,10 @@ msgid "" "///\n" "/// If the second argument is zero, the result is false.\n" msgstr "" +"/// Determine whether the first argument is divisible by the second " +"argument.\n" +"///\n" +"/// If the second argument is zero, the result is false.\n" #: src/std-types/docs.md msgid "" @@ -6067,12 +6120,16 @@ msgid "" "To document an item from inside the item (such as inside a module), use `//!" "` or `/*! .. */`, called \"inner doc comments\":" msgstr "" +"如要從項目內部 (例如在模組內) 記錄項目,請使用 `//!` 或 `/*! .. */`,這也稱做" +"「內部文件註解」:" #: src/std-types/docs.md msgid "" "//! This module contains functionality relating to divisibility of " "integers.\n" msgstr "" +"//! This module contains functionality relating to divisibility of " +"integers.\n" #: src/std-types/docs.md #, fuzzy @@ -6094,26 +6151,29 @@ msgid "" "type `T` or nothing. For example, [`String::find`](https://doc.rust-lang.org/" "stable/std/string/struct.String.html#method.find) returns an `Option`." msgstr "" +"我們已看過 `Option` 的某些用法,包括儲存型別為 `T` 的值,或不儲存任何東" +"西。舉例來說,[`String::find`](https://doc.rust-lang.org/stable/std/string/" +"struct.String.html#method.find) 會傳回 `Option`。" #: src/std-types/option.md msgid "\"Löwe 老虎 Léopard Gepardi\"" -msgstr "" +msgstr "\"Löwe 老虎 Léopard Gepardi\"" #: src/std-types/option.md msgid "'é'" -msgstr "" +msgstr "'é'" #: src/std-types/option.md msgid "\"find returned {position:?}\"" -msgstr "" +msgstr "\"find returned {position:?}\"" #: src/std-types/option.md msgid "'Z'" -msgstr "" +msgstr "'Z'" #: src/std-types/option.md msgid "\"Character not found\"" -msgstr "" +msgstr "\"Character not found\"" #: src/std-types/option.md #, fuzzy @@ -6125,28 +6185,31 @@ msgid "" "`unwrap` will return the value in an `Option`, or panic. `expect` is similar " "but takes an error message." msgstr "" +"`unwrap` 會在 `Option` 或恐慌中傳回值。`expect` 也類似,但會收到錯誤訊息。" #: src/std-types/option.md msgid "" "You can panic on None, but you can't \"accidentally\" forget to check for " "None." -msgstr "" +msgstr "您可以讓程式在 None 發生恐慌,但不能「因錯而」忘記檢查 None。" #: src/std-types/option.md msgid "" "It's common to `unwrap`/`expect` all over the place when hacking something " "together, but production code typically handles `None` in a nicer fashion." msgstr "" +"如果是要設計某些臨時程式,通常會在各處 `unwrap`/`expect`,但實際運作的程式碼" +"一般會以較好的方式處理 `None`。" #: src/std-types/option.md msgid "" "The niche optimization means that `Option` often has the same size in " "memory as `T`." -msgstr "" +msgstr "所謂區位最佳化,代表 `Option` 的記憶體大小通常與 `T` 相同。" #: src/std-types/result.md msgid "Result" -msgstr "" +msgstr "結果" #: src/std-types/result.md msgid "" @@ -6155,22 +6218,25 @@ msgid "" "in the expression exercise, but generic: `Result` where `T` is used in " "the `Ok` variant and `E` appears in the `Err` variant." msgstr "" +"`Result` 和 `Option` 類似,但會指出作業成功或失敗,且各自都有不同的型別。雖然" +"和運算式練習中定義的 `Res` 很像,但這屬於泛型,也就是 `Result`,其中 " +"`T` 用於 `Ok` 變體,而 `E` 則會出現在 `Err` 變數中。" #: src/std-types/result.md msgid "\"diary.txt\"" -msgstr "" +msgstr "\"diary.txt\"" #: src/std-types/result.md msgid "\"Dear diary: {contents} ({bytes} bytes)\"" -msgstr "" +msgstr "\"Dear diary: {contents} ({bytes} bytes)\"" #: src/std-types/result.md msgid "\"Could not read file content\"" -msgstr "" +msgstr "\"Could not read file content\"" #: src/std-types/result.md msgid "\"The diary could not be opened: {err}\"" -msgstr "" +msgstr "\"The diary could not be opened: {err}\"" #: src/std-types/result.md msgid "" @@ -6215,27 +6281,27 @@ msgstr "" #: src/memory-management/review.md src/testing/unit-tests.md #: src/concurrency/scoped-threads.md msgid "\"Hello\"" -msgstr "" +msgstr "\"Hello\"" #: src/std-types/string.md msgid "\"s1: len = {}, capacity = {}\"" -msgstr "" +msgstr "\"s1: len = {}, capacity = {}\"" #: src/std-types/string.md msgid "'!'" -msgstr "" +msgstr "'!'" #: src/std-types/string.md msgid "\"s2: len = {}, capacity = {}\"" -msgstr "" +msgstr "\"s2: len = {}, capacity = {}\"" #: src/std-types/string.md msgid "\"🇨🇭\"" -msgstr "" +msgstr "\"🇨🇭\"" #: src/std-types/string.md msgid "\"s3: len = {}, number of chars = {}\"" -msgstr "" +msgstr "\"s3: len = {}, number of chars = {}\"" #: src/std-types/string.md msgid "" @@ -6292,7 +6358,7 @@ msgstr "" msgid "" "We haven't discussed the `Deref` trait yet, so at this point this mostly " "explains the structure of the sidebar in the documentation." -msgstr "" +msgstr "我們尚未討論 `Deref` 特徵,因此目前主要會講解說明文件中的側欄結構。" #: src/std-types/string.md msgid "" @@ -6351,27 +6417,27 @@ msgstr "" #: src/std-types/vec.md msgid "\"v1: len = {}, capacity = {}\"" -msgstr "" +msgstr "\"v1: len = {}, capacity = {}\"" #: src/std-types/vec.md msgid "\"v2: len = {}, capacity = {}\"" -msgstr "" +msgstr "\"v2: len = {}, capacity = {}\"" #: src/std-types/vec.md msgid "// Canonical macro to initialize a vector with elements.\n" -msgstr "" +msgstr "// Canonical macro to initialize a vector with elements.\n" #: src/std-types/vec.md msgid "// Retain only the even elements.\n" -msgstr "" +msgstr "// Retain only the even elements.\n" #: src/std-types/vec.md msgid "\"{v3:?}\"" -msgstr "" +msgstr "\"{v3:?}\"" #: src/std-types/vec.md msgid "// Remove consecutive duplicates.\n" -msgstr "" +msgstr "// Remove consecutive duplicates.\n" #: src/std-types/vec.md msgid "" @@ -6423,6 +6489,8 @@ msgid "" "Slices are covered on day 3. For now, students only need to know that a " "value of type `Vec` gives access to all of the documented slice methods, too." msgstr "" +"我們會在第 3 天談到切片。現階段,學生只需知道 `Vec` 型別的值也能存取所有記錄" +"下來的切片方法。" #: src/std-types/hashmap.md msgid "Standard hash map with protection against HashDoS attacks:" @@ -6430,43 +6498,43 @@ msgstr "標準雜湊映射,可防範 HashDoS 攻擊:" #: src/std-types/hashmap.md msgid "\"Adventures of Huckleberry Finn\"" -msgstr "" +msgstr "\"Adventures of Huckleberry Finn\"" #: src/std-types/hashmap.md msgid "\"Grimms' Fairy Tales\"" -msgstr "" +msgstr "\"Grimms' Fairy Tales\"" #: src/std-types/hashmap.md msgid "\"Pride and Prejudice\"" -msgstr "" +msgstr "\"Pride and Prejudice\"" #: src/std-types/hashmap.md msgid "\"Les Misérables\"" -msgstr "" +msgstr "\"Les Misérables\"" #: src/std-types/hashmap.md msgid "\"We know about {} books, but not Les Misérables.\"" -msgstr "" +msgstr "\"We know about {} books, but not Les Misérables.\"" #: src/std-types/hashmap.md msgid "\"Alice's Adventure in Wonderland\"" -msgstr "" +msgstr "\"Alice's Adventure in Wonderland\"" #: src/std-types/hashmap.md msgid "\"{book}: {count} pages\"" -msgstr "" +msgstr "\"{book}: {count} pages\"" #: src/std-types/hashmap.md msgid "\"{book} is unknown.\"" -msgstr "" +msgstr "\"{book} is unknown.\"" #: src/std-types/hashmap.md msgid "// Use the .entry() method to insert a value if nothing is found.\n" -msgstr "" +msgstr "// Use the .entry() method to insert a value if nothing is found.\n" #: src/std-types/hashmap.md msgid "\"{page_counts:#?}\"" -msgstr "" +msgstr "\"{page_counts:#?}\"" #: src/std-types/hashmap.md msgid "" @@ -6484,11 +6552,11 @@ msgstr "" #: src/std-types/hashmap.md msgid "\"Harry Potter and the Sorcerer's Stone\"" -msgstr "" +msgstr "\"Harry Potter and the Sorcerer's Stone\"" #: src/std-types/hashmap.md msgid "\"The Hunger Games\"" -msgstr "" +msgstr "\"The Hunger Games\"" #: src/std-types/hashmap.md msgid "Unlike `vec!`, there is unfortunately no standard `hashmap!` macro." @@ -6547,6 +6615,9 @@ msgid "" "stable/std/collections/struct.HashMap.html) to keep track of which values " "have been seen and how many times each one has appeared." msgstr "" +"在本練習中,您要使用非常簡單的資料結構並將其設為泛型。此結構會使用 [`std::" +"collections::HashMap`](https://doc.rust-lang.org/stable/std/collections/" +"struct.HashMap.html) 追蹤出現過的值和出現次數。" #: src/std-types/exercise.md msgid "" @@ -6554,6 +6625,8 @@ msgid "" "values. Make the struct and its methods generic over the type of value being " "tracked, that way `Counter` can track any type of value." msgstr "" +"`Counter` 的初始版本經過硬式編碼,僅適用於 `u32` 值。請設法讓結構體和相應的方" +"法成為泛型,而非所追蹤值的型別,這樣 `Counter` 就可以追蹤任何型別的值。" #: src/std-types/exercise.md msgid "" @@ -6561,101 +6634,109 @@ msgid "" "stable/std/collections/struct.HashMap.html#method.entry) method to halve the " "number of hash lookups required to implement the `count` method." msgstr "" +"如果您提前完成操作,不妨試著使用 [`entry`](https://doc.rust-lang.org/stable/" +"std/collections/struct.HashMap.html#method.entry) 方法將實作 `count` 方法所需" +"的雜湊查詢數量減半。" #: src/std-types/exercise.md src/std-types/solution.md msgid "" "/// Counter counts the number of times each value of type T has been seen.\n" msgstr "" +"/// Counter counts the number of times each value of type T has been seen.\n" #: src/std-types/exercise.md src/std-types/solution.md msgid "/// Create a new Counter.\n" -msgstr "" +msgstr "/// Create a new Counter.\n" #: src/std-types/exercise.md src/std-types/solution.md msgid "/// Count an occurrence of the given value.\n" -msgstr "" +msgstr "/// Count an occurrence of the given value.\n" #: src/std-types/exercise.md src/std-types/solution.md msgid "/// Return the number of times the given value has been seen.\n" -msgstr "" +msgstr "/// Return the number of times the given value has been seen.\n" #: src/std-types/exercise.md src/std-types/solution.md msgid "\"saw {} values equal to {}\"" -msgstr "" +msgstr "\"saw {} values equal to {}\"" #: src/std-types/exercise.md src/std-types/solution.md msgid "\"apple\"" -msgstr "" +msgstr "\"apple\"" #: src/std-types/exercise.md src/std-types/solution.md msgid "\"orange\"" -msgstr "" +msgstr "\"orange\"" #: src/std-types/exercise.md src/std-types/solution.md msgid "\"got {} apples\"" -msgstr "" +msgstr "\"got {} apples\"" #: src/std-traits.md msgid "[Comparisons](./std-traits/comparisons.md) (10 minutes)" -msgstr "" +msgstr "[比較](./std-traits/comparisons.md) (10 分鐘)" #: src/std-traits.md msgid "[Operators](./std-traits/operators.md) (10 minutes)" -msgstr "" +msgstr "[運算子](./std-traits/operators.md) (10 分鐘)" #: src/std-traits.md msgid "[From and Into](./std-traits/from-and-into.md) (10 minutes)" -msgstr "" +msgstr "[From 和 Into](./std-traits/from-and-into.md) (10 分鐘)" #: src/std-traits.md msgid "[Casting](./std-traits/casting.md) (5 minutes)" -msgstr "" +msgstr "[轉換](./std-traits/casting.md) (5 分鐘)" #: src/std-traits.md msgid "[Read and Write](./std-traits/read-and-write.md) (10 minutes)" -msgstr "" +msgstr "[Read 和 Write](./std-traits/read-and-write.md) (10 分鐘)" #: src/std-traits.md msgid "[Default, struct update syntax](./std-traits/default.md) (5 minutes)" -msgstr "" +msgstr "[Default (結構體更新語法)](./std-traits/default.md) (5 分鐘)" #: src/std-traits.md msgid "[Closures](./std-traits/closures.md) (20 minutes)" -msgstr "" +msgstr "[閉包](./std-traits/closures.md) (20 分鐘)" #: src/std-traits.md msgid "[Exercise: ROT13](./std-traits/exercise.md) (30 minutes)" -msgstr "" +msgstr "[練習:ROT13](./std-traits/exercise.md) (30 分鐘)" #: src/std-traits.md msgid "This segment should take about 1 hour and 40 minutes" -msgstr "" +msgstr "講解這個主題大約需要 1 小時 40 分鐘" #: src/std-traits.md msgid "" "As with the standard-library types, spend time reviewing the documentation " "for each trait." -msgstr "" +msgstr "和標準程式庫型別一樣,請花時間詳閱每種特徵的說明文件。" #: src/std-traits.md msgid "This section is long. Take a break midway through." -msgstr "" +msgstr "這節課時間很長,在中間休息片刻吧。" #: src/std-traits/comparisons.md msgid "" "These traits support comparisons between values. All traits can be derived " "for types containing fields that implement these traits." msgstr "" +"以下特徵可用於比較不同的值。如果欄位會實作這些特徵,您可以針對含有這類欄位的" +"型別衍生所有特徵。" #: src/std-traits/comparisons.md msgid "`PartialEq` and `Eq`" -msgstr "" +msgstr "`PartialEq` 和 `Eq`" #: src/std-traits/comparisons.md msgid "" "`PartialEq` is a partial equivalence relation, with required method `eq` and " "provided method `ne`. The `==` and `!=` operators will call these methods." msgstr "" +"`PartialEq` 代表部分對等關係,具有必要方法 `eq` 和提供的方法 `ne`。`==` 和 `!" +"=` 運算子會呼叫這些方法。" #: src/std-traits/comparisons.md msgid "" @@ -6663,33 +6744,36 @@ msgid "" "and implies `PartialEq`. Functions that require full equivalence will use " "`Eq` as a trait bound." msgstr "" +"`Eq` 代表完整對等關係 (自反、對稱和傳遞性),並且隱含 `PartialEq`。需要完整對" +"等關係的函式會使用 `Eq` 做為特徵界線。" #: src/std-traits/comparisons.md -#, fuzzy msgid "`PartialOrd` and `Ord`" -msgstr "`Read` 和 `Write`" +msgstr "`PartialOrd` 和 `Ord`" #: src/std-traits/comparisons.md msgid "" "`PartialOrd` defines a partial ordering, with a `partial_cmp` method. It is " "used to implement the `<`, `<=`, `>=`, and `>` operators." msgstr "" +"`PartialOrd` 會透過 `partial_cmp` 方法定義偏序,可用於實作 `<`、`<=`、`>=` " +"和 `>` 運算子。" #: src/std-traits/comparisons.md msgid "`Ord` is a total ordering, with `cmp` returning `Ordering`." -msgstr "" +msgstr "`Ord` 是全序,其中 `cmp` 會傳回 `Ordering`。" #: src/std-traits/comparisons.md msgid "" "`PartialEq` can be implemented between different types, but `Eq` cannot, " "because it is reflexive:" -msgstr "" +msgstr "`PartialEq` 可以在不同的型別之間實作,但具有自反性的 `Eq` 無法:" #: src/std-traits/comparisons.md msgid "" "In practice, it's common to derive these traits, but uncommon to implement " "them." -msgstr "" +msgstr "實務上一般會衍生這些特徵,但鮮少會實作這些特徵。" #: src/std-traits/operators.md msgid "" @@ -6701,7 +6785,7 @@ msgstr "" #: src/std-traits/operators.md msgid "\"{:?} + {:?} = {:?}\"" -msgstr "" +msgstr "\"{:?} + {:?} = {:?}\"" #: src/std-traits/operators.md src/memory-management/drop.md msgid "Discussion points:" @@ -6759,7 +6843,7 @@ msgstr "" #: src/std-traits/from-and-into.md msgid "\"{s}, {addr}, {one}, {bigger}\"" -msgstr "" +msgstr "\"{s}, {addr}, {one}, {bigger}\"" #: src/std-traits/from-and-into.md msgid "" @@ -6793,18 +6877,20 @@ msgid "" "Rust has no _implicit_ type conversions, but does support explicit casts " "with `as`. These generally follow C semantics where those are defined." msgstr "" +"Rust 沒有「隱含」型別的轉換,但支援使用 `as` 明確轉換。後者通常會遵循定義前者" +"時所用的 C 語意。" #: src/std-traits/casting.md msgid "\"as u16: {}\"" -msgstr "" +msgstr "\"as u16: {}\"" #: src/std-traits/casting.md msgid "\"as i16: {}\"" -msgstr "" +msgstr "\"as i16: {}\"" #: src/std-traits/casting.md msgid "\"as u8: {}\"" -msgstr "" +msgstr "\"as u8: {}\"" #: src/std-traits/casting.md msgid "" @@ -6812,6 +6898,8 @@ msgid "" "platforms. This might not match your intuition for changing sign or casting " "to a smaller type -- check the docs, and comment for clarity." msgstr "" +"在 Rust 中,`as` 的結果「一律」會經過定義,且在不同平台間保持一致。這可能不符" +"合您變更符號或轉換到較小型別時的直觀做法,請檢查文件並加註說明內容。" #: src/std-traits/casting.md msgid "" @@ -6822,6 +6910,10 @@ msgid "" "selecting the bottom 32 bits of a `u64` with `as u32`, regardless of what " "was in the high bits)." msgstr "" +"使用 `as` 進行轉換,可說是採用相對鋒利的一種工具,使用上並不容易;而且要是日" +"後的維護作業改變了所用型別或型別中值的範圍,此工具就可能會成為導致細微錯誤的" +"來源。只有在意圖用於指明無條件截斷時,我們才建議轉換。舉例來說,如果無論高位" +"元中的內容為何,您都要透過 `as u32` 選取 `u64` 的底部 32 位元,就可以這麼做。" #: src/std-traits/casting.md msgid "" @@ -6830,10 +6922,13 @@ msgid "" "casts, `TryFrom` and `TryInto` are available when you want to handle casts " "that fit differently from those that don't." msgstr "" +"如果是 `u32` 到 `u64` 這類絕對無誤的轉換,適合先使用 `From` 或 `Into` (而非 " +"`as`) 確認轉換確實無誤。對於容易出錯的轉換,如果您想以不同的方式處理,可以使" +"用 `TryFrom` 和 `TryInto`。" #: src/std-traits/casting.md msgid "Consider taking a break after this slide." -msgstr "" +msgstr "建議在講解完這張投影片後休息片刻。" #: src/std-traits/casting.md msgid "" @@ -6841,10 +6936,12 @@ msgid "" "be lost is generally discouraged, or at least deserves an explanatory " "comment." msgstr "" +"`as` 類似於 C++ 的靜態轉換。一般不建議在資料可能遺失的情況下使用 `as`,如果要" +"用,也至少要提供說明註解。" #: src/std-traits/casting.md msgid "This is common in casting integers to `usize` for use as an index." -msgstr "" +msgstr "這在將整數轉換為 `usize` 以用做索引時很常見。" #: src/std-traits/read-and-write.md msgid "" @@ -6858,15 +6955,15 @@ msgstr "" #: src/std-traits/read-and-write.md msgid "b\"foo\\nbar\\nbaz\\n\"" -msgstr "" +msgstr "b\"foo\\nbar\\nbaz\\n\"" #: src/std-traits/read-and-write.md msgid "\"lines in slice: {}\"" -msgstr "" +msgstr "\"lines in slice: {}\"" #: src/std-traits/read-and-write.md msgid "\"lines in file: {}\"" -msgstr "" +msgstr "\"lines in file: {}\"" #: src/std-traits/read-and-write.md msgid "" @@ -6878,15 +6975,15 @@ msgstr "" #: src/std-traits/read-and-write.md msgid "\"\\n\"" -msgstr "" +msgstr "\"\\n\"" #: src/std-traits/read-and-write.md src/slices-and-lifetimes/str.md msgid "\"World\"" -msgstr "" +msgstr "\"World\"" #: src/std-traits/read-and-write.md msgid "\"Logged: {:?}\"" -msgstr "" +msgstr "\"Logged: {:?}\"" #: src/std-traits/default.md msgid "The `Default` Trait" @@ -6902,24 +6999,24 @@ msgstr "" #: src/std-traits/default.md msgid "\"John Smith\"" -msgstr "" +msgstr "\"John Smith\"" #: src/std-traits/default.md msgid "\"{default_struct:#?}\"" -msgstr "" +msgstr "\"{default_struct:#?}\"" #: src/std-traits/default.md msgid "\"Y is set!\"" -msgstr "" +msgstr "\"Y is set!\"" #: src/std-traits/default.md msgid "\"{almost_default_struct:#?}\"" -msgstr "" +msgstr "\"{almost_default_struct:#?}\"" #: src/std-traits/default.md src/slices-and-lifetimes/exercise.md #: src/slices-and-lifetimes/solution.md msgid "\"{:#?}\"" -msgstr "" +msgstr "\"{:#?}\"" #: src/std-traits/default.md msgid "" @@ -6987,15 +7084,15 @@ msgstr "呼叫不安全的函式" #: src/std-traits/closures.md msgid "\"add_3: {}\"" -msgstr "" +msgstr "\"add_3: {}\"" #: src/std-traits/closures.md msgid "\"accumulate: {}\"" -msgstr "" +msgstr "\"accumulate: {}\"" #: src/std-traits/closures.md msgid "\"multiply_sum: {}\"" -msgstr "" +msgstr "\"multiply_sum: {}\"" #: src/std-traits/closures.md msgid "" @@ -7038,12 +7135,16 @@ msgid "" "you can (i.e. you call it once), or `FnMut` else, and last `Fn`. This allows " "the most flexibility for the caller." msgstr "" +"定義可接受閉包的函式時,您應盡量採用 `FnOnce` (也就是只呼叫一次),其次是 " +"`FnMut`,最後則是 `Fn`。這種做法可讓呼叫端享有最大彈性。" #: src/std-traits/closures.md msgid "" "In contrast, when you have a closure, the most flexible you can have is `Fn` " "(it can be passed everywhere), then `FnMut`, and lastly `FnOnce`." msgstr "" +"相反地,當有閉包時,最有彈性的就是 `Fn` (可以在任何地方傳遞)、其次是 " +"`FnMut`,最後是 `FnOnce`。" #: src/std-traits/closures.md msgid "" @@ -7063,11 +7164,11 @@ msgstr "" #: src/std-traits/closures.md src/smart-pointers/trait-objects.md msgid "\"{} {}\"" -msgstr "" +msgstr "\"{} {}\"" #: src/std-traits/closures.md msgid "\"Hi\"" -msgstr "" +msgstr "\"Hi\"" #: src/std-traits/closures.md msgid "\"Greg\"" @@ -7080,28 +7181,32 @@ msgid "" "implement the missing bits. Only rotate ASCII alphabetic characters, to " "ensure the result is still valid UTF-8." msgstr "" +"在這個範例中,您將實作傳統的[「ROT13」加密方式](https://zh.wikipedia.org/" +"wiki/ROT13)。請將此程式碼複製到 Playground,並實作缺少的位元。記得僅能旋轉 " +"ASCII 字母字元,確保結果仍為有效的 UTF-8。" #: src/std-traits/exercise.md msgid "// Implement the `Read` trait for `RotDecoder`.\n" -msgstr "" +msgstr "// Implement the `Read` trait for `RotDecoder`.\n" #: src/std-traits/exercise.md src/std-traits/solution.md msgid "\"Gb trg gb gur bgure fvqr!\"" -msgstr "" +msgstr "\"Gb trg gb gur bgure fvqr!\"" #: src/std-traits/exercise.md src/std-traits/solution.md msgid "\"To get to the other side!\"" -msgstr "" +msgstr "\"To get to the other side!\"" #: src/std-traits/exercise.md msgid "" "What happens if you chain two `RotDecoder` instances together, each rotating " "by 13 characters?" msgstr "" +"如果將兩個 `RotDecoder` 例項鏈結在一起,每個都以 13 個字元旋轉,會怎麼樣?" #: src/std-traits/solution.md msgid "'A'" -msgstr "" +msgstr "'A'" #: src/welcome-day-3.md msgid "Welcome to Day 3" From 489dca2d9befe5421c0f403b48f20e55542b8287 Mon Sep 17 00:00:00 2001 From: Henri F Date: Tue, 12 Mar 2024 07:57:13 -0700 Subject: [PATCH 2/5] Apply suggestions from code review Co-authored-by: Ming-Ying Chung --- po/zh-TW.po | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/po/zh-TW.po b/po/zh-TW.po index dbb9bef87ad..c70ef0f3c63 100644 --- a/po/zh-TW.po +++ b/po/zh-TW.po @@ -4819,7 +4819,7 @@ msgstr "[歡迎](./welcome-day-2.md) (3 分鐘)" #: src/welcome-day-2.md #, fuzzy msgid "[Pattern Matching](./pattern-matching.md) (1 hour)" -msgstr "[解構](./pattern-matching/destructuring.md) (10 分鐘)" +msgstr "[模式配對](./pattern-matching.md) (10 分鐘)" #: src/welcome-day-2.md msgid "[Methods and Traits](./methods-and-traits.md) (45 minutes)" @@ -4838,7 +4838,7 @@ msgstr "講解這個主題大約需要 2 小時 50 分鐘" #: src/pattern-matching.md #, fuzzy msgid "[Matching Values](./pattern-matching/match.md) (10 minutes)" -msgstr "[解構](./pattern-matching/destructuring.md) (10 分鐘)" +msgstr "[配對](./pattern-matching/match.md) (10 分鐘)" #: src/pattern-matching.md msgid "[Destructuring](./pattern-matching/destructuring.md) (10 minutes)" @@ -5277,8 +5277,8 @@ msgid "" "tests. To evaluate a boxed expression, use the deref operator (`*`) to " "\"unbox\" it: `eval(*boxed_expr)`." msgstr "" -"這裡的 `Box` 型別是智慧指標,我們會在本課程的後續部分詳細說明。運算式可透過 " -"`Box::new`「裝箱」,如測試中所示。如要求裝箱運算式的值,請使用 deref 運算子 " +"這裡的 `Box` 型別是一種智慧指標,我們會在本課程的後續部分詳細說明。如測試中所示,運算式可被 " +"`Box::new`「裝箱」。如要求裝箱運算式的值,請使用 deref 運算子 " "(`*`) 來「開箱」:`eval(*boxed_expr)`。" #: src/pattern-matching/exercise.md @@ -6910,10 +6910,10 @@ msgid "" "selecting the bottom 32 bits of a `u64` with `as u32`, regardless of what " "was in the high bits)." msgstr "" -"使用 `as` 進行轉換,可說是採用相對鋒利的一種工具,使用上並不容易;而且要是日" -"後的維護作業改變了所用型別或型別中值的範圍,此工具就可能會成為導致細微錯誤的" -"來源。只有在意圖用於指明無條件截斷時,我們才建議轉換。舉例來說,如果無論高位" -"元中的內容為何,您都要透過 `as u32` 選取 `u64` 的底部 32 位元,就可以這麼做。" +"雖然使用 `as` 進行型別相當簡單,但是非常容易出錯;舉例來說," +"如果往後的維護作業改變了所用型別或型別中值的範圍,這常常就是某些細微錯誤的來源。" +"只有在意圖用於指明無條件截斷時,我們才建議使用型別轉換。舉例來說,如果無論高位" +"元中的內容為何,您都只需要 `u64` 的底部 32 位元,就可以使用 `as u32`。" #: src/std-traits/casting.md msgid "" @@ -6922,7 +6922,7 @@ msgid "" "casts, `TryFrom` and `TryInto` are available when you want to handle casts " "that fit differently from those that don't." msgstr "" -"如果是 `u32` 到 `u64` 這類絕對無誤的轉換,適合先使用 `From` 或 `Into` (而非 " +"如果是 `u32` 到 `u64` 這類絕對無誤的型別轉換,適合先使用 `From` 或 `Into` (而非 " "`as`) 確認轉換確實無誤。對於容易出錯的轉換,如果您想以不同的方式處理,可以使" "用 `TryFrom` 和 `TryInto`。" From e5fbbc0ebe85c4c4f2cf368c78ca016bf944a1a2 Mon Sep 17 00:00:00 2001 From: Henri Fontana Date: Tue, 12 Mar 2024 10:59:08 -0400 Subject: [PATCH 3/5] dprint fmt po file --- po/zh-TW.po | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/po/zh-TW.po b/po/zh-TW.po index c70ef0f3c63..0b030409c4c 100644 --- a/po/zh-TW.po +++ b/po/zh-TW.po @@ -5277,8 +5277,8 @@ msgid "" "tests. To evaluate a boxed expression, use the deref operator (`*`) to " "\"unbox\" it: `eval(*boxed_expr)`." msgstr "" -"這裡的 `Box` 型別是一種智慧指標,我們會在本課程的後續部分詳細說明。如測試中所示,運算式可被 " -"`Box::new`「裝箱」。如要求裝箱運算式的值,請使用 deref 運算子 " +"這裡的 `Box` 型別是一種智慧指標,我們會在本課程的後續部分詳細說明。如測試中所" +"示,運算式可被 `Box::new`「裝箱」。如要求裝箱運算式的值,請使用 deref 運算子 " "(`*`) 來「開箱」:`eval(*boxed_expr)`。" #: src/pattern-matching/exercise.md @@ -6910,10 +6910,10 @@ msgid "" "selecting the bottom 32 bits of a `u64` with `as u32`, regardless of what " "was in the high bits)." msgstr "" -"雖然使用 `as` 進行型別相當簡單,但是非常容易出錯;舉例來說," -"如果往後的維護作業改變了所用型別或型別中值的範圍,這常常就是某些細微錯誤的來源。" -"只有在意圖用於指明無條件截斷時,我們才建議使用型別轉換。舉例來說,如果無論高位" -"元中的內容為何,您都只需要 `u64` 的底部 32 位元,就可以使用 `as u32`。" +"雖然使用 `as` 進行型別相當簡單,但是非常容易出錯;舉例來說,如果往後的維護作" +"業改變了所用型別或型別中值的範圍,這常常就是某些細微錯誤的來源。只有在意圖用" +"於指明無條件截斷時,我們才建議使用型別轉換。舉例來說,如果無論高位元中的內容" +"為何,您都只需要 `u64` 的底部 32 位元,就可以使用 `as u32`。" #: src/std-traits/casting.md msgid "" @@ -6922,9 +6922,9 @@ msgid "" "casts, `TryFrom` and `TryInto` are available when you want to handle casts " "that fit differently from those that don't." msgstr "" -"如果是 `u32` 到 `u64` 這類絕對無誤的型別轉換,適合先使用 `From` 或 `Into` (而非 " -"`as`) 確認轉換確實無誤。對於容易出錯的轉換,如果您想以不同的方式處理,可以使" -"用 `TryFrom` 和 `TryInto`。" +"如果是 `u32` 到 `u64` 這類絕對無誤的型別轉換,適合先使用 `From` 或 `Into` (而" +"非 `as`) 確認轉換確實無誤。對於容易出錯的轉換,如果您想以不同的方式處理,可以" +"使用 `TryFrom` 和 `TryInto`。" #: src/std-traits/casting.md msgid "Consider taking a break after this slide." From bad8819dba57bfb82366ca4f36390a6b51e7b9c8 Mon Sep 17 00:00:00 2001 From: Henri F Date: Tue, 12 Mar 2024 08:00:07 -0700 Subject: [PATCH 4/5] Update po/zh-TW.po Co-authored-by: Ming-Ying Chung --- po/zh-TW.po | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/po/zh-TW.po b/po/zh-TW.po index 0b030409c4c..a3ce23b308b 100644 --- a/po/zh-TW.po +++ b/po/zh-TW.po @@ -5741,7 +5741,7 @@ msgid "" "`n == 0`. Even if only the `pick` instantiation with integers is used, Rust " "still considers it invalid. C++ would let you do this." msgstr "" -"這與 C++ 範本類似,但 Rust 會立即對泛型函式進行部分編譯,因此函式必須適用於所" +"這與 C++ 模板 (template) 類似,但 Rust 會立即對泛型函式進行部分編譯,因此函式必須適用於所" "有符合限制條件的型別。舉例來說,如果 `n == 0`,請嘗試修改 `pick` 以傳回 " "`even + odd`。即使只使用具有整數的 `pick` 建立例項,Rust 仍會將其視為無效。" "但 C++ 就能讓您這麼做。" From 69295710fb227e82ad717282811ab49a48c14cee Mon Sep 17 00:00:00 2001 From: Henri Fontana Date: Tue, 12 Mar 2024 11:01:53 -0400 Subject: [PATCH 5/5] dprint again --- po/zh-TW.po | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/po/zh-TW.po b/po/zh-TW.po index a3ce23b308b..8c88396b2c6 100644 --- a/po/zh-TW.po +++ b/po/zh-TW.po @@ -5741,10 +5741,10 @@ msgid "" "`n == 0`. Even if only the `pick` instantiation with integers is used, Rust " "still considers it invalid. C++ would let you do this." msgstr "" -"這與 C++ 模板 (template) 類似,但 Rust 會立即對泛型函式進行部分編譯,因此函式必須適用於所" -"有符合限制條件的型別。舉例來說,如果 `n == 0`,請嘗試修改 `pick` 以傳回 " -"`even + odd`。即使只使用具有整數的 `pick` 建立例項,Rust 仍會將其視為無效。" -"但 C++ 就能讓您這麼做。" +"這與 C++ 模板 (template) 類似,但 Rust 會立即對泛型函式進行部分編譯,因此函式" +"必須適用於所有符合限制條件的型別。舉例來說,如果 `n == 0`,請嘗試修改 `pick` " +"以傳回 `even + odd`。即使只使用具有整數的 `pick` 建立例項,Rust 仍會將其視為" +"無效。但 C++ 就能讓您這麼做。" #: src/generics/generic-functions.md #, fuzzy