We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 4dcb6d7 commit 4140dd8Copy full SHA for 4140dd8
notes/src/day2/lc209.md
@@ -83,4 +83,21 @@ impl Solution {
83
}
84
85
86
-```
+```
87
+
88
+在闭包中使用pattern matching来去除变量前边的引用的时候,有时候不要去除多了
89
90
+```js
91
+ pub fn min_sub_array_len(nums: Vec<i32>) {
92
+ nums.iter().scan(1i32, |&mut st, &x| {
93
+ st += x;
94
+ Some(st)
95
+ });
96
+ }
97
98
99
100
+类似这个时候,st绑定到的就永远都是输入的那个1 到闭包函数内了,起不到修改闭包外的1的效果。
101
102
+所以这个引用就不要自动匹配掉了,就手动解引用吧
103
0 commit comments