Rust 程序设计语言 简体中文版 1.85.0
Rust 的运行速度、安全性、单二进制文件输出和跨平台支持使其成为创建命令行程序的理想 语言,所以我们的项目将创建一个我们自己版本的经典命令行搜索工具:grep。grep 是 “Globally search a Regular Expression and Print.” 的首字母缩写。grep 最简单的使用场景 是在特定文件中搜索指定字符串。为此,grep 获取一个文件路径和一个字符串作为参数,接 我们将测试驱动实现实际在文件内容中搜索查询字符串并返回匹配的行示例的功能。我们将在 一个叫做 search 的函数中增加这些功能。 编写失败测试 去掉 src/lib.rs 和 src/main.rs 中用于检查程序行为的 println! 语句,因为不再真正需要它们 了。接着我们会像第十一章那样增加一个 test 模块和一个测试函数。测试函数指定了 search 函数期望拥有的行为:它会获取一个需要查询的字符串和用来查询的文本,并只会返回包含请 productive."], search(query, contents)); } } 示例 12-15:创建一个我们期望的 search 函数的失败测试 这里选择使用 "duct" 作为这个测试中需要搜索的字符串。用来搜索的文本有三行,其中只有 一行包含 "duct"。(注意双引号之后的反斜杠,这告诉 Rust 不要在字符串字面值内容的开头 加入换行符)我们断言 search 函数的返回值只包含期望的那一行。0 码力 | 562 页 | 3.23 MB | 9 天前3Tornado 6.5 Documentation
TwitterMixin.twitter_request now accepts both URLs and partial paths (complete URLs are useful for the search API which follows different patterns). • Exception handling in tornado.gen has been improved. It patches, bug reports, and feedback that went into this release! -Ben • genindex • modindex • search 6.9. Release notes 253Tornado Documentation, Release 6.5.1 254 Chapter 6. DocumentationCHAPTER0 码力 | 272 页 | 1.12 MB | 2 月前3Tornado 6.5 Documentation
What’s new in Tornado 1.1 What’s new in Tornado 1.0.1 What’s new in Tornado 1.0 Index Module Index Search PageDiscussion and support You can discuss Tornado on the Tornado developer mailing list [https://groups TwitterMixin.twitter_request now accepts both URLs and partial paths (complete URLs are useful for the search API which follows different patterns). Exception handling in tornado.gen has been improved. It is0 码力 | 437 页 | 405.14 KB | 2 月前3
共 3 条
- 1