知识卡片
映射配对改变迭代元素形状
map逐项转换值,cloned或copied把引用变成相应拥有值;enumerate增加从零开始的序号,zip把两条流配成对并在较短者结束时停止。枚举的序号对应当前迭代流,经过filter后不一定还是原集合索引;复制能力也不能代替所有权成本分析。
这张卡片看不懂?
这张卡片已通过人工审查,不再接受失败反馈。
已有反馈 · 0 条
还没有人提交反馈。
在整书笔记中的位置
原书出处 · 1 处
- Chapter 1. Types Iterator Transforms · 查看原书依据
enumerate() Converts an iterator over items to be an iterator over (usize, Item) pairs, providing an index to the items in the iterator. zip(it) Joins an iterator with a second iterator, to produce a combined iterator that emits pairs of items, one from each of the original iterators, until the shorter of the two iterators is finished. Yet other transformati
参考来源
- 位置:《Effective Rust 35 Specific Ways to Improve Your Rust Code (David Drysdale)》第1章《Iterator Transforms》(spine5;extracted/Effective Rust 35 Specific Ways to Improve Your Rust Code (David Drysdale)/_epub-src/OEBPS/ch01.html;u049-ch01-075)。
- 结论依据:原文在“enumerate()”附近的定义、例子或代码支撑本卡核心说明:map逐项转换值,cloned或copied把引用变成相应拥有值;enumerate增加从零开始的序号,zip把两条流配成对并在较短者结束时停止。边界按已读前提解释;示例未执行。
- 原始内容:enumerate() Converts an iterator over items to be an iterator over (usize, Item) pairs, providing an index to the items in the iterator. zip(it) Joins an iterator with a second iterator, to produce a combined iterator that emits pairs of items, one from each of the original iterators, until the shorter of the two iterators is finished. Yet other transformati