上一页 1 ··· 54 55 56 57 58 59 60 61 62 ··· 119 下一页
摘要: 环境 Rust 1.56.1 VSCode 1.61.2 概念 参考:https://doc.rust-lang.org/rust-by-example/error/result/enter_question_mark.html 示例 如果想得到值而不产生恐慌,有一种简单的方式,那就是使用问号。 m 阅读全文
posted @ 2021-12-24 15:10 jiangbo4444 阅读(236) 评论(0) 推荐(0)
摘要: 环境 Rust 1.56.1 VSCode 1.61.2 概念 参考:https://doc.rust-lang.org/rust-by-example/error/result/early_returns.html 示例 main.rs use std::num::ParseIntError; f 阅读全文
posted @ 2021-12-24 15:09 jiangbo4444 阅读(166) 评论(0) 推荐(0)
摘要: 环境 Rust 1.56.1 VSCode 1.61.2 概念 参考:https://doc.rust-lang.org/rust-by-example/error/result/result_alias.html 示例 main.rs use std::num::ParseIntError; // 阅读全文
posted @ 2021-12-24 15:08 jiangbo4444 阅读(109) 评论(0) 推荐(0)
摘要: 环境 Rust 1.56.1 VSCode 1.61.2 概念 参考:https://doc.rust-lang.org/rust-by-example/error/result/result_map.html 示例 Result 的 map 方法可以对值进行转换。 繁琐版本 use std::nu 阅读全文
posted @ 2021-12-24 15:07 jiangbo4444 阅读(322) 评论(0) 推荐(0)
摘要: 环境 Rust 1.56.1 VSCode 1.61.2 概念 参考:https://doc.rust-lang.org/rust-by-example/error/result.html 示例 Result 和 Option 有点类似,不过它代表可能失败,而不是可能不存在。 恐慌 fn multi 阅读全文
posted @ 2021-12-24 15:06 jiangbo4444 阅读(245) 评论(0) 推荐(0)
摘要: 环境 Rust 1.56.1 VSCode 1.61.2 概念 参考:https://doc.rust-lang.org/rust-by-example/error/option_unwrap/and_then.html 示例 main.rs #![allow(dead_code)] #[deriv 阅读全文
posted @ 2021-12-24 15:04 jiangbo4444 阅读(124) 评论(0) 推荐(0)
摘要: 环境 Rust 1.56.1 VSCode 1.61.2 概念 参考:https://doc.rust-lang.org/rust-by-example/error/option_unwrap/map.html 示例 Option 有个 map 方法,可以进行值的映射,或者说转换。 main.rs 阅读全文
posted @ 2021-12-24 15:03 jiangbo4444 阅读(369) 评论(0) 推荐(0)
摘要: 环境 Rust 1.56.1 VSCode 1.61.2 概念 参考:https://doc.rust-lang.org/rust-by-example/error/option_unwrap/question_mark.html 示例 使用问号进行展开,具有更好的可读性。 main.rs stru 阅读全文
posted @ 2021-12-24 15:02 jiangbo4444 阅读(243) 评论(0) 推荐(0)
摘要: 环境 Rust 1.56.1 VSCode 1.61.2 概念 参考:https://doc.rust-lang.org/rust-by-example/error/option_unwrap.html 示例 除了使用恐慌,还可以使用可选(Option)来处理一些意外情况。 main.rs fn g 阅读全文
posted @ 2021-12-24 15:01 jiangbo4444 阅读(317) 评论(0) 推荐(0)
摘要: 环境 Rust 1.56.1 VSCode 1.61.2 概念 参考:https://doc.rust-lang.org/rust-by-example/error/panic.html 示例 恐慌(panic)和其它语言中的异常和错误类似,一般针对不可处理的错误。如果没有经过处理,就会直接退出程序 阅读全文
posted @ 2021-12-24 14:59 jiangbo4444 阅读(64) 评论(0) 推荐(0)
上一页 1 ··· 54 55 56 57 58 59 60 61 62 ··· 119 下一页