Rust 程序设计语言 简体中文版 1.85.0
Please type a number!: ParseIntError { kind: InvalidDigit } note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace 输入 quit 将会退出程序,同时你会注意到其他任何非数字输入也一样。这至少可以说是不理 想的,我们想要当猜测正确的数字时游戏停止。 rs:19:19: index out of bounds: the len is 5 but the index is 10 note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace 程序在索引操作中使用一个无效的值时导致 运行时 错误。程序带着错误信息退出,并且没有 执行最后的 println! 语句。当尝试用索引访问一个元素时,Rust char boundary; it is inside 'З' (bytes 0..2) of `Здравствуйте` note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace 在使用 range 来创建字符串 slice 时要格外小心,因为这么做可能会使你的程序崩溃。 遍历字符串的方法 操作字0 码力 | 562 页 | 3.23 MB | 9 天前3
共 1 条
- 1