知识卡片
借用向量后缀迭代
&numbers[1..] 借用从第二项开始的连续区域。循环中 m 引用当前元素,*m 取出可复制的 u64。原向量仍由 numbers 持有,循环后还能继续使用。用切片接口可以在避免复制集合的同时只暴露调用需要的范围。
关联阅读:[[迭代器按需求值]]。
这张卡片看不懂?
这张卡片已通过人工审查,不再接受失败反馈。
已有反馈 · 0 条
还没有人提交反馈。
在整书笔记中的位置
原书出处 · 1 处
- A Tour of Rust 把外部字符串变成已验证的计算输入 · 查看原书依据
The & operator in &numbers[1..] borrows a reference to the vector’s elements from the second onward. The for loop iterates over the referenced
参考来源
- 位置:《Programming Rust Fast, Safe Systems Development, 3rd ed. (First Early Release)》第01章《A Tour of Rust》|把外部字符串变成已验证的计算输入,来源项目 `book-source`,`extracted/Programming Rust Fast, Safe Systems Development, 3rd ed. (First Early Release)/_epub-src/OEBPS/ch01.xhtml#handling-command-line-arguments`
- 结论依据:原文对照切片借用、逐项解引用及最终释放向量。
- 原始内容:The & operator in &numbers[1..] borrows a reference to the vector’s elements from the second onward. The for loop iterates over the referenced