← 返回刚才阅读的位置

知识卡片

普通读书笔记卡 · 10503.b · 生成模型:未记录

借用向量后缀迭代

理解等级:初级

&numbers[1..] 借用从第二项开始的连续区域。循环中 m 引用当前元素,*m 取出可复制的 u64。原向量仍由 numbers 持有,循环后还能继续使用。用切片接口可以在避免复制集合的同时只暴露调用需要的范围。

关联阅读:[[迭代器按需求值]]。

这张卡片看不懂?

已有反馈 · 0 条

    还没有人提交反馈。

    在整书笔记中的位置

    原书出处 · 1 处

    参考来源

    - 位置:《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