From 52434a3438a2ca9773eb7b7c819938452a21e8c7 Mon Sep 17 00:00:00 2001 From: TimLai666 <43640816+TimLai666@users.noreply.github.com> Date: Mon, 10 Jun 2024 18:31:04 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BF=BB=E8=AD=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- exercises/08_enums/README.md | 14 +++++++------- exercises/08_enums/enums1.rs | 4 ++-- exercises/08_enums/enums2.rs | 5 ++--- exercises/08_enums/enums3.rs | 11 +++++------ 4 files changed, 16 insertions(+), 18 deletions(-) diff --git a/exercises/08_enums/README.md b/exercises/08_enums/README.md index 30d4d91d..c67df5d0 100644 --- a/exercises/08_enums/README.md +++ b/exercises/08_enums/README.md @@ -1,10 +1,10 @@ -# Enums +# 枚舉 -Rust allows you to define types called "enums" which enumerate possible values. -Enums are a feature in many languages, but their capabilities differ in each language. Rust’s enums are most similar to algebraic data types in functional languages, such as F#, OCaml, and Haskell. -Useful in combination with enums is Rust's "pattern matching" facility, which makes it easy to run different code for different values of an enumeration. +Rust 允許您定義稱為 "枚舉" 的類型,這些類型列舉了可能的值。 +枚舉是許多語言中的一個特性,但其能力在每種語言中都有所不同。Rust 的枚舉最類似於函數式語言中的代數數據類型,例如 F#、OCaml 和 Haskell。 +與枚舉結合使用的有用特性是 Rust 的 "模式匹配" 功能,這使得對枚舉的不同值運行不同代碼變得容易。 -## Further information +## 更多資訊 -- [Enums](https://doc.rust-lang.org/book/ch06-00-enums.html) -- [Pattern syntax](https://doc.rust-lang.org/book/ch18-03-pattern-syntax.html) +- [枚舉](https://doc.rust-lang.org/book/ch06-00-enums.html) +- [模式語法](https://doc.rust-lang.org/book/ch18-03-pattern-syntax.html) diff --git a/exercises/08_enums/enums1.rs b/exercises/08_enums/enums1.rs index 25525b25..4d64b1c1 100644 --- a/exercises/08_enums/enums1.rs +++ b/exercises/08_enums/enums1.rs @@ -1,12 +1,12 @@ // enums1.rs // -// No hints this time! ;) +// 這次沒有提示! ;) // I AM NOT DONE #[derive(Debug)] enum Message { - // TODO: define a few types of messages as used below + // TODO: 根據下面的用法定義幾種消息類型 } fn main() { diff --git a/exercises/08_enums/enums2.rs b/exercises/08_enums/enums2.rs index df93fe0f..6f35deb8 100644 --- a/exercises/08_enums/enums2.rs +++ b/exercises/08_enums/enums2.rs @@ -1,13 +1,12 @@ // enums2.rs // -// Execute `rustlings hint enums2` or use the `hint` watch subcommand for a -// hint. +// 執行 `rustlings hint enums2` 或使用 `hint` watch 子命令來獲取提示。 // I AM NOT DONE #[derive(Debug)] enum Message { - // TODO: define the different variants used below + // TODO: 定義下面使用的不同變體 } impl Message { diff --git a/exercises/08_enums/enums3.rs b/exercises/08_enums/enums3.rs index 92d18c46..faabdc0c 100644 --- a/exercises/08_enums/enums3.rs +++ b/exercises/08_enums/enums3.rs @@ -1,14 +1,13 @@ // enums3.rs // -// Address all the TODOs to make the tests pass! +// 完成所有 TODO 使測試通過! // -// Execute `rustlings hint enums3` or use the `hint` watch subcommand for a -// hint. +// 執行 `rustlings hint enums3` 或使用 `hint` watch 子命令來獲取提示。 // I AM NOT DONE enum Message { - // TODO: implement the message variant types based on their usage below + // TODO: 根據下面的用法實現消息變體類型 } struct Point { @@ -41,8 +40,8 @@ impl State { } fn process(&mut self, message: Message) { - // TODO: create a match expression to process the different message variants - // Remember: When passing a tuple as a function argument, you'll need extra parentheses: + // TODO: 創建一個 match 表達式來處理不同的消息變體 + // 記住:當作為函數參數傳遞元組時,您需要額外的括號: // fn function((t, u, p, l, e)) } }