Update all-patterns.md

修复了match匹配解构理解上的错误
pull/599/head
Haolong Sun 3 years ago committed by GitHub
parent 8608294255
commit 56197e9374
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -161,8 +161,8 @@ fn main() {
``` ```
首先是 `match` 第一个分支,指定匹配 `y``0``Point` 首先是 `match` 第一个分支,指定匹配 `y``0``Point`
然后第二个分支在第一个分支之后,匹配 `y` 不为 `0``x` 为 `0``Point`; 然后第二个分支在第一个分支之后,指定匹配`x` 为 `0``Point`;
最后一个分支匹配 `x` 不为 `0``y` 也不为 `0``Point` 最后一个 分支匹配`x` 和 `y`,与结构体 `p` 中的 `x``y` 字段相匹配进行解构赋值x, y;
在这个例子中,值 `p` 因为其 `x` 包含 0 而匹配第二个分支,因此会打印出 `On the y axis at 7` 在这个例子中,值 `p` 因为其 `x` 包含 0 而匹配第二个分支,因此会打印出 `On the y axis at 7`

Loading…
Cancel
Save