Rust 程序设计语言 简体中文版 1.85.0
an object-oriented language. My goal was to ensure that all use of references should be absolutely safe, with checking performed automatically by the compiler. But I couldn’t resist the temptation to put one_result() { let query = "duct"; let contents = "\ Rust: safe, fast, productive. Pick three."; assert_eq!(vec!["safe, fast, productive."], search(query, contents)); } } 示例 12-15:创建一个我们期望的 vector 的 265/562Rust 程序设计语言 简体中文版 search 函数定义,如示例 12-16 所示。然后这个测试应该能够编译并因为空 vector 并不匹配 一个包含一行 "safe, fast, productive." 的 vector 而失败。 文件名:src/lib.rs pub fn search<'a>(query: &str, contents: &'a str)0 码力 | 562 页 | 3.23 MB | 10 天前3
共 1 条
- 1