上一页 1 ··· 50 51 52 53 54 55 56 57 58 ··· 498 下一页
摘要: Code from previous blog: use std::thread; use std::time::Duration; fn main() { thread::spawn(|| { for i in 1..10 { println!("hi number {} from the spa 阅读全文
posted @ 2024-03-08 20:49 Zhentiw 阅读(30) 评论(0) 推荐(0)
摘要: We use spawnto create a new thread: use std::thread; use std::time::Duration; fn main() { thread::spawn(|| { for i in 1..10 { println!("hi number {} f 阅读全文
posted @ 2024-03-08 20:34 Zhentiw 阅读(40) 评论(0) 推荐(0)
摘要: 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 阅读(26) 评论(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 阅读(43) 评论(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 阅读(35) 评论(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 阅读(39) 评论(0) 推荐(0)
摘要: #[derive(PartialEq, Debug)] enum CreationError { Negative, Zero, } #[derive(PartialEq, Debug)] struct PositiveNonzeroInteger(u64); impl PositiveNonzer 阅读全文
posted @ 2024-03-01 16:14 Zhentiw 阅读(30) 评论(0) 推荐(0)
摘要: use std::num::ParseIntError; fn main() -> Result<(), ParseIntError> { let mut token = 100; let pretend_user_input = "8"; let cost = total_cost(pretend 阅读全文
posted @ 2024-03-01 16:08 Zhentiw 阅读(21) 评论(0) 推荐(0)
摘要: pub fn generate_nametag_text(name: String) -> Result<String, String> { if name.is_empty() { // Empty names aren't allowed. Err(String::from("`name` wa 阅读全文
posted @ 2024-03-01 15:49 Zhentiw 阅读(45) 评论(0) 推荐(0)
摘要: function logThis() { console.log(this) } const obj = { logThis, logThis2() { logThis() }, logThis3() { obj.logThis() } } obj.logThis(); obj.logThis2() 阅读全文
posted @ 2024-02-29 22:11 Zhentiw 阅读(22) 评论(0) 推荐(0)
上一页 1 ··· 50 51 52 53 54 55 56 57 58 ··· 498 下一页