mirror of
https://github.com/google/comprehensive-rust.git
synced 2025-04-27 09:32:16 +02:00
zh-CN: translate src/pattern-matching/destructuring-arrays.md (#834)
This commit is contained in:
parent
753e53ad17
commit
933abb6596
30
po/zh-CN.po
30
po/zh-CN.po
@ -296,7 +296,7 @@ msgstr ""
|
|||||||
|
|
||||||
#: src/SUMMARY.md:88
|
#: src/SUMMARY.md:88
|
||||||
msgid "Destructuring Arrays"
|
msgid "Destructuring Arrays"
|
||||||
msgstr ""
|
msgstr "解构数组"
|
||||||
|
|
||||||
#: src/SUMMARY.md:89
|
#: src/SUMMARY.md:89
|
||||||
msgid "Match Guards"
|
msgid "Match Guards"
|
||||||
@ -5953,12 +5953,13 @@ msgstr ""
|
|||||||
|
|
||||||
#: src/pattern-matching/destructuring-arrays.md:1
|
#: src/pattern-matching/destructuring-arrays.md:1
|
||||||
msgid "# Destructuring Arrays"
|
msgid "# Destructuring Arrays"
|
||||||
msgstr ""
|
msgstr "# 解构数组"
|
||||||
|
|
||||||
#: src/pattern-matching/destructuring-arrays.md:3
|
#: src/pattern-matching/destructuring-arrays.md:3
|
||||||
msgid ""
|
msgid ""
|
||||||
"You can destructure arrays, tuples, and slices by matching on their elements:"
|
"You can destructure arrays, tuples, and slices by matching on their elements:"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
"你可以通过元素匹配来解构数组、元组和切片:"
|
||||||
|
|
||||||
#: src/pattern-matching/destructuring-arrays.md:5
|
#: src/pattern-matching/destructuring-arrays.md:5
|
||||||
msgid ""
|
msgid ""
|
||||||
@ -6006,6 +6007,31 @@ msgid ""
|
|||||||
"elements.\n"
|
"elements.\n"
|
||||||
"* Show matching against the tail with patterns `[.., b]` and `[a@..,b]`"
|
"* Show matching against the tail with patterns `[.., b]` and `[a@..,b]`"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
"* 对未知长度的切片进行解构也可以使用固定长度的模式。\n"
|
||||||
|
"\n"
|
||||||
|
"\n"
|
||||||
|
" ```rust,editable\n"
|
||||||
|
" fn main() {\n"
|
||||||
|
" inspect(&[0, -2, 3]);\n"
|
||||||
|
" inspect(&[0, -2, 3, 4]);\n"
|
||||||
|
" }\n"
|
||||||
|
"\n"
|
||||||
|
" #[rustfmt::skip]\n"
|
||||||
|
" fn inspect(slice: &[i32]) {\n"
|
||||||
|
" println!(\"Tell me about {slice:?}\");\n"
|
||||||
|
" match slice {\n"
|
||||||
|
" &[0, y, z] => println!(\"First is 0, y = {y}, and z = {z}\"),\n"
|
||||||
|
" &[1, ..] => println!(\"First is 1 and the rest were "
|
||||||
|
"ignored\"),\n"
|
||||||
|
" _ => println!(\"All elements were ignored\"),\n"
|
||||||
|
" }\n"
|
||||||
|
" }\n"
|
||||||
|
" ```\n"
|
||||||
|
" \n"
|
||||||
|
"* 使用 `_` 创建一个新的模式来代表一个元素。\n"
|
||||||
|
"* 向数组中添加更多的值。\n"
|
||||||
|
"* 指出 `..` 是如何扩展以适应不同数量的元素的。 \n"
|
||||||
|
"* 展示使用模式 `[.., b]` 和 `[a@..,b]` 来匹配切片的尾部。"
|
||||||
|
|
||||||
#: src/pattern-matching/match-guards.md:1
|
#: src/pattern-matching/match-guards.md:1
|
||||||
msgid "# Match Guards"
|
msgid "# Match Guards"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user