diff --git a/exercise/exercises/if/README.md b/exercise/exercises/if/README.md index 528d9886..c2e93ecd 100644 --- a/exercise/exercises/if/README.md +++ b/exercise/exercises/if/README.md @@ -1,7 +1,7 @@ # If -`if`, the most basic type of control flow, is what you'll learn here. +你将在这学习最基本的控制流(control flow)——`if` -## Further information +## 更多信息 - [Control Flow - if expressions](https://doc.rust-lang.org/book/ch03-05-control-flow.html#if-expressions) diff --git a/exercise/exercises/if/if1.rs b/exercise/exercises/if/if1.rs index 90867545..bfb4f73a 100644 --- a/exercise/exercises/if/if1.rs +++ b/exercise/exercises/if/if1.rs @@ -3,14 +3,14 @@ // I AM NOT DONE pub fn bigger(a: i32, b: i32) -> i32 { - // Complete this function to return the bigger number! - // Do not use: - // - another function call - // - additional variables - // Execute `rustlings hint if1` for hints + // 完成这个返回更大数字的函数! + // 但不允许以下方式: + // - 调用其它函数 + // - 额外变量 + // 执行 `rustex hint if1` 获取提示 } -// Don't mind this for now :) +// 暂时不要在意它 :) #[cfg(test)] mod tests { use super::*; diff --git a/exercise/exercises/if/if2.rs b/exercise/exercises/if/if2.rs index 80effbdf..b3c62167 100644 --- a/exercise/exercises/if/if2.rs +++ b/exercise/exercises/if/if2.rs @@ -1,8 +1,8 @@ // if2.rs -// Step 1: Make me compile! -// Step 2: Get the bar_for_fuzz and default_to_baz tests passing! -// Execute the command `rustlings hint if2` if you want a hint :) +// 第一步:让我能够编译! +// 第二步:bar_for_fuzz 和 default_to_baz 可以通过测试! +// 执行 `rustex hint if2` 获取提示 :) // I AM NOT DONE @@ -14,7 +14,7 @@ pub fn fizz_if_foo(fizzish: &str) -> &str { } } -// No test changes needed! +// 测试不需要更改。 #[cfg(test)] mod tests { use super::*; diff --git a/exercise/info.toml b/exercise/info.toml index 38e271e8..54be7f2a 100644 --- a/exercise/info.toml +++ b/exercise/info.toml @@ -128,23 +128,23 @@ name = "if1" path = "exercises/if/if1.rs" mode = "test" hint = """ -It's possible to do this in one line if you would like! -Some similar examples from other languages: -- In C(++) this would be: `a > b ? a : b` -- In Python this would be: `a if a > b else b` -Remember in Rust that: -- the `if` condition does not need to be surrounded by parentheses -- `if`/`else` conditionals are expressions -- Each condition is followed by a `{}` block.""" +如果你愿意的话,也可以用一行来做这件事! +其他语言中的一些类似例子: +- 在 C(++) 中会是: `a > b ? a : b` +- 在 Python 中会是: `a if a > b else b` +请记住在 Rust 中: +- `if` 的条件不需要用圆括号括起来 +- `if`/`else` 的条件是表达式 +- 每个条件后面都有一个 `{}` 块。""" [[exercises]] name = "if2" path = "exercises/if/if2.rs" mode = "test" hint = """ -For that first compiler error, it's important in Rust that each conditional -block return the same type! To get the tests passing, you will need a couple -conditions checking different input values.""" +对于第一个编译错误,在于 Rust 中的重要一点: +每个条件块(conditional block)都必须返回相同的类型。 +为了通过测试,你需要几个条件用来判断不同的输入""" # TEST 1