摘要: https://doc.rust-lang.org/std/keyword.ref.html struct Point { x: i32, y: i32, } fn main() { let y: Option<Point> = Some(Point { x: 100, y: 200 }); mat 阅读全文
posted @ 2024-03-04 21:57 Zhentiw 阅读(4) 评论(0) 推荐(0) 编辑
摘要: https://doc.rust-lang.org/rust-by-example/flow_control/if_let.htmlhttps://doc.rust-lang.org/rust-by-example/flow_control/while_let.html If let: #[test 阅读全文
posted @ 2024-03-04 21:53 Zhentiw 阅读(12) 评论(0) 推荐(0) 编辑
摘要: // Using catch-all error types like `Box<dyn error::Error>` isn't recommended // for library code, where callers might want to make decisions based on 阅读全文
posted @ 2024-03-04 21:28 Zhentiw 阅读(9) 评论(0) 推荐(0) 编辑
摘要: use std::error; use std::fmt; use std::num::ParseIntError; fn main() -> Result<(), Box<dyn error::Error>> { let pretend_user_input = "42"; let x: i64 阅读全文
posted @ 2024-03-04 21:15 Zhentiw 阅读(10) 评论(0) 推荐(0) 编辑