知识卡片
配置结构表达参数关系
用 Config 的 query、file_path 将相关参数组织成一个对象。相比靠索引和元组顺序,具名字段能表达哪一个值决定查找文本,哪一个值决定文件路径。关联函数负责建立这个对象。
这张卡片看不懂?
这张卡片已通过人工审查,不再接受失败反馈。
已有反馈 · 0 条
还没有人提交反馈。
在整书笔记中的位置
原书出处 · 1 处
- I/O 项目:构建命令行程序 Refactoring to Improve Modularity and Error Handling · 查看原书依据
Another indicator that shows there’s room for improvement is the config part of parse_config, which implies that the two values we return are related and are both part of one configuration value.
参考来源
- 位置:《The Rust Programming Language(第2版)》第12章 I/O 项目:构建命令行程序(来源项目 a19c7933-4eda-4176-aebd-30fe7e1ad292,`extracted/The Rust Programming Language(第2版)/_epub-src/c12.xhtml`,块 0083)
- 结论依据:立即拆开的无名元组缺乏语义,对照具名结构说明好处。
- 原始内容:Another indicator that shows there’s room for improvement is the config part of parse_config, which implies that the two values we return are related and are both part of one configuration value.