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

2020年12月25日

摘要: https://wiki.jikexueyuan.com/project/rust-primer/rcarc/rcarc.html Rc 和 Arc Rust 建立在所有权之上的这一套机制,它要求一个资源同一时刻有且只能有一个拥有所有权的绑定或 &mut 引用,这在大部分的情况下保证了内存的安全。但 阅读全文
posted @ 2020-12-25 16:17 tycoon3 阅读(1744) 评论(0) 推荐(0)
摘要: https://zhuanlan.zhihu.com/p/109242831 fn main() { let path = "/tmp/dat"; println!("{}", read_file(path)); } fn read_file(path: &str) -> String { std: 阅读全文
posted @ 2020-12-25 16:04 tycoon3 阅读(1059) 评论(0) 推荐(0)
摘要: [root@bogon option]# rm -rf target/ [root@bogon option]# cargo build Compiling own v0.1.0 (/data2/rust/option) Finished dev [unoptimized + debuginfo] 阅读全文
posted @ 2020-12-25 15:47 tycoon3 阅读(306) 评论(0) 推荐(0)
摘要: Rust 中的属性,可以分为以下四大类。 Macro attributes - 宏属性 Derive macro helper attributes - 派生宏辅助属性 Tool attributes - 工具属性 Built-in attributes - 内建属性 Macro Attribute 阅读全文
posted @ 2020-12-25 15:32 tycoon3 阅读(922) 评论(0) 推荐(0)
摘要: [root@bogon rust]# mkdir learn_marco2 [root@bogon rust]# cd learn_marco2/ [root@bogon learn_marco2]# cargo new hello_macro --lib Created library `hell 阅读全文
posted @ 2020-12-25 14:45 tycoon3 阅读(199) 评论(0) 推荐(0)
摘要: 1、Trait是什么? 一个Trait描述了一种抽象接口(找不到很合适的词),这个抽象接口可以被类型继承。Trait只能由三部分组成(可能只包含部分): functions(方法) types(类型) constants(常量) 所有的Trait都定义了一个隐含类型Self,其指向实现该Trait的 阅读全文
posted @ 2020-12-25 14:13 tycoon3 阅读(652) 评论(0) 推荐(0)
摘要: 应用:简单HTTP服务器 https://learnku.com/docs/async-book/2018/http_server_example/4789 //例子二 use futures::{ self, executor}; async fn learn_song() { println!( 阅读全文
posted @ 2020-12-25 12:02 tycoon3 阅读(1498) 评论(0) 推荐(0)
摘要: cargo check [root@bogon async]# cargo check Checking own v0.1.0 (/data2/rust/async) error[E0670]: `async fn` is not permitted in the 2015 edition --> 阅读全文
posted @ 2020-12-25 11:53 tycoon3 阅读(936) 评论(0) 推荐(0)
摘要: src/main.rs #[derive(Debug)] struct MyType { name: String } impl MyType { fn do_something(self, age: u32) { //等价于 fn do_something(self: Self, age: u32 阅读全文
posted @ 2020-12-25 11:21 tycoon3 阅读(248) 评论(0) 推荐(0)
摘要: Firecracker Firecracker is a new light KVM-based hypervisor written in Rust and announced during last AWS re:Invent in 2018. But unlike QEMU, Firecrac 阅读全文
posted @ 2020-12-25 10:14 tycoon3 阅读(340) 评论(0) 推荐(0)
上一页 1 ··· 60 61 62 63 64 65 66 67 68 ··· 164 下一页

导航