From 7327677c8d37ffcbc78f3cdd08fe76cf771b71db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AD=99=E9=A3=9ESunface?= Date: Sun, 20 Feb 2022 19:48:17 +0800 Subject: [PATCH] Update contents/pitfalls/use-vec-in-for.md --- contents/pitfalls/use-vec-in-for.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contents/pitfalls/use-vec-in-for.md b/contents/pitfalls/use-vec-in-for.md index 500bef9d..d1f823c9 100644 --- a/contents/pitfalls/use-vec-in-for.md +++ b/contents/pitfalls/use-vec-in-for.md @@ -20,7 +20,7 @@ for i in 0..v.len() { [1, 2, 3, 0, 1, 2] ``` -输出很清晰的表明,只新插入了三个元素:`0..3`,刚好是`v`的初始长度。 +输出很清晰的表明,只新插入了三个元素:`0..=2`,刚好是`v`的初始长度。 这是因为:**在for循环中,`v.len`只会在循环伊始之时进行求值,之后就一直使用该值**。