Rust 程序设计语言 简体中文版 1.85.0
Nightly builds, run with -Z macro- backtrace for more info) help: consider cloning the value if the performance cost is acceptable | 3 | let s2 = s1.clone(); | ++++++++ For more information 行验证。回忆一下第二章的猜猜看游戏,我们的代码要求用户猜测一个 1 到 100 之间的数字, 在将其与秘密数字做比较之前我们从未验证用户的猜测是位于这两个数字之间的,我们只验证 它是否为正。在这种情况下,其影响并不是很严重:“Too high” 或 “Too low” 的输出仍然是正 确的。但是这是一个很好的引导用户得出有效猜测的辅助,例如当用户猜测一个超出范围的数 字或者输入字母时采取不同的行为。 一种实现方式是将猜测解析成 i32 `String`, which does not implement the `Copy` trait | help: consider cloning the value if the performance cost is acceptable | 18 | sort_operations.push(value.clone()); |0 码力 | 562 页 | 3.23 MB | 9 天前3
共 1 条
- 1