上一页 1 ··· 48 49 50 51 52 53 54 55 56 ··· 112 下一页
摘要: 环境 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 阅读(298) 评论(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 阅读(242) 评论(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 阅读(115) 评论(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 阅读(353) 评论(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 阅读(236) 评论(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 阅读(312) 评论(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 阅读(60) 评论(0) 推荐(0)
摘要: 环境 Rust 1.56.1 VSCode 1.61.2 概念 参考:https://doc.rust-lang.org/rust-by-example/macros/variadics.html 示例 main.rs macro_rules! calculate { (eval $e:expr) 阅读全文
posted @ 2021-12-24 14:57 jiangbo4444 阅读(486) 评论(0) 推荐(0)
摘要: 环境 Rust 1.56.1 VSCode 1.61.2 概念 参考:https://doc.rust-lang.org/rust-by-example/macros/dsl.html 示例 DSL 表示 Domain Specific Language,领域特定语言。 main.rs macro_ 阅读全文
posted @ 2021-12-24 14:55 jiangbo4444 阅读(162) 评论(0) 推荐(0)
摘要: 环境 Rust 1.56.1 VSCode 1.61.2 概念 参考:https://doc.rust-lang.org/rust-by-example/macros/dry.html 示例 DRY 表示 Don't Repeat Yourself,不要重复你自己,意思是尽量不要写重复的代码。 ma 阅读全文
posted @ 2021-12-24 14:53 jiangbo4444 阅读(149) 评论(0) 推荐(0)
上一页 1 ··· 48 49 50 51 52 53 54 55 56 ··· 112 下一页