1
0
mirror of https://github.com/google/comprehensive-rust.git synced 2024-12-15 06:20:32 +02:00

zh-CN: Translate for src/exercises/day-2/health-statistics.md (#807)

This commit is contained in:
Yulin Shen 2023-06-14 08:56:21 +08:00 committed by GitHub
parent 00835e7fd4
commit c948186fc6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -304,7 +304,7 @@ msgstr ""
#: src/SUMMARY.md:91
msgid "Health Statistics"
msgstr ""
msgstr "健康统计"
#: src/SUMMARY.md:92
msgid "Points and Polygons"
@ -5995,7 +5995,7 @@ msgstr ""
#: src/exercises/day-2/health-statistics.md:1
msgid "# Health Statistics"
msgstr ""
msgstr "# 健康统计"
#: src/exercises/day-2/health-statistics.md:3
msgid ""
@ -6003,6 +6003,7 @@ msgid ""
"you\n"
"need to keep track of users' health statistics."
msgstr ""
"你正在实现一个健康监控系统。作为其中的一部分,你需要对用户的健康统计数据进行追踪。"
#: src/exercises/day-2/health-statistics.md:6
msgid ""
@ -6011,6 +6012,7 @@ msgid ""
"struct definition. Your goal is to implement the stubbed out methods on the\n"
"`User` `struct` defined in the `impl` block."
msgstr ""
"`User` 结构体的定义和 `impl` 块中一些函数的框架已经给出。你的目标是实现在 `impl` 块中定义的 `User` `struct` 的方法。"
#: src/exercises/day-2/health-statistics.md:10
msgid ""
@ -6018,6 +6020,7 @@ msgid ""
"missing\n"
"methods:"
msgstr ""
"将以下代码复制到 <https://play.rust-lang.org/>,并填充缺失的方法:"
#: src/exercises/day-2/health-statistics.md:13
msgid ""
@ -6077,6 +6080,61 @@ msgid ""
"}\n"
"```"
msgstr ""
"```rust,should_panic\n"
"// TODO: 实现完成后删除此行。\n"
"#![allow(unused_variables, dead_code)]\n"
"\n"
"struct User {\n"
" name: String,\n"
" age: u32,\n"
" weight: f32,\n"
"}\n"
"\n"
"impl User {\n"
" pub fn new(name: String, age: u32, weight: f32) -> Self {\n"
" unimplemented!()\n"
" }\n"
"\n"
" pub fn name(&self) -> &str {\n"
" unimplemented!()\n"
" }\n"
"\n"
" pub fn age(&self) -> u32 {\n"
" unimplemented!()\n"
" }\n"
"\n"
" pub fn weight(&self) -> f32 {\n"
" unimplemented!()\n"
" }\n"
"\n"
" pub fn set_age(&mut self, new_age: u32) {\n"
" unimplemented!()\n"
" }\n"
"\n"
" pub fn set_weight(&mut self, new_weight: f32) {\n"
" unimplemented!()\n"
" }\n"
"}\n"
"\n"
"fn main() {\n"
" let bob = User::new(String::from(\"Bob\"), 32, 155.2);\n"
" println!(\"I'm {} and my age is {}\", bob.name(), bob.age());\n"
"}\n"
"\n"
"#[test]\n"
"fn test_weight() {\n"
" let bob = User::new(String::from(\"Bob\"), 32, 155.2);\n"
" assert_eq!(bob.weight(), 155.2);\n"
"}\n"
"\n"
"#[test]\n"
"fn test_set_age() {\n"
" let mut bob = User::new(String::from(\"Bob\"), 32, 155.2);\n"
" assert_eq!(bob.age(), 32);\n"
" bob.set_age(33);\n"
" assert_eq!(bob.age(), 33);\n"
"}\n"
"```"
#: src/exercises/day-2/points-polygons.md:1
msgid "# Polygon Struct"