From 56197e937488d7fea41d31859ec5d97448b8a8ed Mon Sep 17 00:00:00 2001 From: Haolong Sun <55129666+acfuns@users.noreply.github.com> Date: Tue, 22 Mar 2022 19:45:16 +0800 Subject: [PATCH] Update all-patterns.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 修复了match匹配解构理解上的错误 --- src/basic/match-pattern/all-patterns.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/basic/match-pattern/all-patterns.md b/src/basic/match-pattern/all-patterns.md index 64c5a080..9da76578 100644 --- a/src/basic/match-pattern/all-patterns.md +++ b/src/basic/match-pattern/all-patterns.md @@ -161,8 +161,8 @@ fn main() { ``` 首先是 `match` 第一个分支,指定匹配 `y` 为 `0` 的 `Point`; -然后第二个分支在第一个分支之后,匹配 `y` 不为 `0`,`x` 为 `0` 的 `Point`; -最后一个分支匹配 `x` 不为 `0`,`y` 也不为 `0` 的 `Point`。 +然后第二个分支在第一个分支之后,指定匹配`x` 为 `0` 的 `Point`; +最后一个 分支匹配`x` 和 `y`,与结构体 `p` 中的 `x` 和 `y` 字段相匹配,进行解构赋值x, y; 在这个例子中,值 `p` 因为其 `x` 包含 0 而匹配第二个分支,因此会打印出 `On the y axis at 7`。