上一页 1 ··· 59 60 61 62 63 64 65 66 67 ··· 164 下一页

2020年12月25日

摘要: 函数指针 我们讨论过了如何向函数传递闭包;也可以向函数传递常规函数!这在我们希望传递已经定义的函数而不是重新定义闭包作为参数时很有用。通过函数指针允许我们使用函数作为另一个函数的参数。函数的类型是 fn (使用小写的 “f” )以免与 Fn 闭包 trait 相混淆。fn 被称为 函数指针(func 阅读全文
posted @ 2020-12-25 20:22 tycoon3 阅读(134) 评论(0) 推荐(0)
摘要: 闭包会捕获其环境 闭包中可以使用x变量。 fn main() { let x = 4; let equal_to_x = |z| z == x; println!("{:?}", x); let y = 4; assert!(equal_to_x(y)); } 而在函数中,则无法使用x变量。 fn 阅读全文
posted @ 2020-12-25 19:55 tycoon3 阅读(217) 评论(0) 推荐(0)
摘要: https://zhuanlan.zhihu.com/p/184907190 https://colobu.com/2020/03/05/A-half-hour-to-learn-Rust/ Introduction Moves and copies are fundamental concepts 阅读全文
posted @ 2020-12-25 19:41 tycoon3 阅读(191) 评论(0) 推荐(0)
摘要: 闭包是什么? 先来看看维基百科上的描述: 在计算机科学中,闭包(英语:Closure),又称词法闭包(Lexical Closure)或函数闭包(function closures),是引用了自由变量的函数。这个被引用的自由变量将和这个函数一同存在,即使已经离开了创造它的环境也不例外。所以,有另一种 阅读全文
posted @ 2020-12-25 17:57 tycoon3 阅读(7127) 评论(0) 推荐(3)
摘要: struct Morpheus { blue_pill: f32, red_pill: i64, } fn main() { let f = Morpheus { blue_pill: 0.0, red_pill: 0 }; let copy = f.clone(); // and now we c 阅读全文
posted @ 2020-12-25 17:41 tycoon3 阅读(207) 评论(1) 推荐(0)
摘要: https://docs.rs/socket-io/0.1.1/src/socket_io/.cargo/registry/src/github.com-1ecc6299db9ec823/socket-io-0.1.1/src/socket.rs.html 阅读全文
posted @ 2020-12-25 17:38 tycoon3 阅读(448) 评论(0) 推荐(0)
摘要: I decided that I wanted to learn a new programming language in 2019. After a bit of research, I settled upon Rust due to its speed, novel ideas about 阅读全文
posted @ 2020-12-25 17:25 tycoon3 阅读(411) 评论(0) 推荐(1)
摘要: 吴斌的博客 » 【firecracker】系统启动与epoll事件循环 在分析完firecracker虚拟机中各个子系统的运行时原理和初始化流程后,最后我们整体分析一下firecracker的系统启动过程,并重点分析IO线程(fc_vmm)所采用的epoll事件循环框架。 回顾首文中介绍的firec 阅读全文
posted @ 2020-12-25 17:11 tycoon3 阅读(132) 评论(0) 推荐(0)
摘要: Vec 定义了一个动态增长的数组,与java ArrayList类似。基本也定义了增删改查操作: pub fn push(&mut self, value: T) pub fn remove(&mut self, index: usize) pub fn get<I>(&self, index: I 阅读全文
posted @ 2020-12-25 16:46 tycoon3 阅读(528) 评论(0) 推荐(0)
摘要: https://kaisery.github.io/trpl-zh-cn/ch16-01-threads.html use std::thread; use std::time::Duration; fn main() { thread::spawn(|| { for i in 1..10 { pr 阅读全文
posted @ 2020-12-25 16:28 tycoon3 阅读(197) 评论(0) 推荐(0)
上一页 1 ··· 59 60 61 62 63 64 65 66 67 ··· 164 下一页

导航