Rust 1.42.0 發佈了!
增加了 Subslice patterns
fn foo(words: &[&str]) {
match words {
[] => println!("empty slice!"),
[one] => println!("one element: {:?}", one),
[one, two] => println!("two elements: {:?} {:?}", one, two),
_ => println!("I'm not sure how many elements!"),
}
}
新巨集 matches!
// Using a match expression:
match self.partial_cmp(other) {
Some(Less) => true,
_ => false,
}
// Using the `matches!` macro:
matches!(self.partial_cmp(other), Some(Less))
let foo = 'f';
assert!(matches!(foo, 'A'..='Z' | 'a'..='z'));
let bar = Some(4);
assert!(matches!(bar, Some(x) if x > 2));
其它功能詳見
Read more
Async Interview: Withoutboats
Withoutboats是Rust lang小組的成員。從2018年初開始,他們開始研究Rust的異步等待。
本文講解了異步語法應該要解決的太多問題
要保持異步和同步代碼為盡可能"類似"且好用。
Read more
Rust:改善 spotify-tui 透過使用 async
作者通過實作 async/await 與使用 tokio
改善了UI效能
Read more
Rust: 實際使用Wasm
文章一開始講解了wasm的優缺點 像是是32位開頭而不是64位 指標與介面類型之類的一些基本內容仍然是WIP狀態
下面介紹各種名詞
- wasm –“機器碼”。設計用於可移植,快速且易於執行的bytecode。
- wasi –“系統調用”。用於執行基本系統任務(主要是I/O)的API。
- 編譯器- rustc, clang, emscripten等
- wasmer – wasmer.io上的人製作的直譯器/JIT
- wasmtime –直譯器/JIT 不同的人做的
- wapm –與npm類似的軟件包管理器
- WASI – WebAssembly系統接口,一種POSIX-y API, 為非Web平台上的wasm程式提供系統介面。
- Cranelift –用Rust編寫的編譯器和JIT後端。在概念上類似LLVM。
詳細請看文章
Read more