知识卡片
接口约束字符串解析
trait 描述类型可承诺提供的操作。FromStr 让整数等类型提供关联函数 from_str,调用 u64::from_str 时目标类型决定解析规则。用该 trait 提供的方法时通常要先引入 trait。命令行文本到数值有明确的转换边界。
这张卡片看不懂?
这张卡片已通过人工审查,不再接受失败反馈。
已有反馈 · 0 条
还没有人提交反馈。
在整书笔记中的位置
原书出处 · 1 处
- A Tour of Rust 把外部字符串变成已验证的计算输入 · 查看原书依据
The first use declaration brings the standard library trait FromStr into scope. A trait is a collection of methods that types can implement.
参考来源
- 位置:《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`
- 结论依据:原文说明 FromStr 与 u64 的实现关系及作用域要求。
- 原始内容:The first use declaration brings the standard library trait FromStr into scope. A trait is a collection of methods that types can implement.