知识卡片
迭代器按需求值
迭代器每次提供一个元素,并能表示序列终止。env::args().skip(1) 构成一个新迭代器,循环只处理命令名后面的参数。相同模型也适合逐行读文件或逐项访问集合,组合适配器本身无需先构造一个包含所有结果的新向量。
这张卡片看不懂?
这张卡片已通过人工审查,不再接受失败反馈。
已有反馈 · 0 条
还没有人提交反馈。
在整书笔记中的位置
原书出处 · 1 处
- A Tour of Rust 把外部字符串变成已验证的计算输入 · 查看原书依据
The std::env module’s args function returns an iterator, a value that produces each argument on demand, and indicates when we’re done. Iterators are
参考来源
- 位置:《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`
- 结论依据:原文先定义按需产生参数,再说明 skip 如何省略首项。
- 原始内容:The std::env module’s args function returns an iterator, a value that produces each argument on demand, and indicates when we’re done. Iterators are