From 933abb659675c0a5454cff38af062b9eca14f825 Mon Sep 17 00:00:00 2001 From: wnghl Date: Tue, 27 Jun 2023 17:49:34 +0800 Subject: [PATCH] zh-CN: translate src/pattern-matching/destructuring-arrays.md (#834) --- po/zh-CN.po | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/po/zh-CN.po b/po/zh-CN.po index d114ddb9..a51bbd14 100644 --- a/po/zh-CN.po +++ b/po/zh-CN.po @@ -296,7 +296,7 @@ msgstr "" #: src/SUMMARY.md:88 msgid "Destructuring Arrays" -msgstr "" +msgstr "解构数组" #: src/SUMMARY.md:89 msgid "Match Guards" @@ -5953,12 +5953,13 @@ msgstr "" #: src/pattern-matching/destructuring-arrays.md:1 msgid "# Destructuring Arrays" -msgstr "" +msgstr "# 解构数组" #: src/pattern-matching/destructuring-arrays.md:3 msgid "" "You can destructure arrays, tuples, and slices by matching on their elements:" msgstr "" +"你可以通过元素匹配来解构数组、元组和切片:" #: src/pattern-matching/destructuring-arrays.md:5 msgid "" @@ -6006,6 +6007,31 @@ msgid "" "elements.\n" "* Show matching against the tail with patterns `[.., b]` and `[a@..,b]`" 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 msgid "# Match Guards"