随笔分类 -  rust

tokio 基础知识学习
摘要:1. 创建 tokio Runtime 直接创建: //默认的工作线程数量将和CPU核数(虚拟核,即CPU线程数)相同 let rt = tokio::runtime::Runtime::new().unwrap(); //单线程 tokio::runtime::Builder::new_curre 阅读全文

posted @ 2023-10-24 23:24 Lemo_wd 阅读(454) 评论(0) 推荐(0) 编辑

rust 基础 —— Option 的 as_ref 与 as_deref
摘要:代码: fn hello(name: &String) { println!("Name is {}", name); } fn greet(name: &str) { println!("Name is {}", name); } fn main() { let option_name: Opti 阅读全文

posted @ 2022-11-10 09:53 Lemo_wd 阅读(618) 评论(0) 推荐(0) 编辑

rust 基础 —— 创建链表
摘要:使用枚举类 use crate::List::{Cons, Nil}; enum List { // Cons:元组结构体,包含链表的一个元素和一个指向下一节点的指针 Cons(u32, Box<List>), // Nil:末结点,表明链表结束 Nil, } // 可以为 enum 定义方法 im 阅读全文

posted @ 2022-11-04 14:52 Lemo_wd 阅读(419) 评论(0) 推荐(0) 编辑

rust 基础 —— iterator 迭代器
摘要:一、自定义迭代器 实现 Iterator trait 即可 pub struct Counter { pub count: usize, } impl Iterator for Counter { type Item = usize; fn next(&mut self) -> Option<Sel 阅读全文

posted @ 2021-07-16 22:38 Lemo_wd 阅读(97) 评论(0) 推荐(0) 编辑

< 2025年2月 >
26 27 28 29 30 31 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 1
2 3 4 5 6 7 8

导航

统计

点击右上角即可分享
微信分享提示