筆記說明
Crust of Rust 系列是根據 Jon Gjengset 的直播所記錄下的學習筆記,他透過實作來加深您對 Rust 程式的理解,他不會一開始就實作出最終版本,而是漸進式的實作的帶著您實作,這樣做的好處是能幫助您建立程式設計師應有的思維並解決問題,他還會帶您閱讀官方文件來協助您打下更扎實的基礎。本系列適合已經有編寫或閱讀過 Rust 相關書籍的讀者,若有 C 語言開發相關的經驗,將更能夠理解 Rust 編譯器嘗試解決的問題究竟是什麼。
Crust of Rust
- Lifetime Annotations (2023.12)
- 多個的生命週期使用情境
- 避免字串造成的記憶體配置所帶來的效能衝擊
- 為不同的資料型別實作 trait
- Declarative Macros (2023.12)
- 巨集的基礎使用
- Hygiene 避免巨集內部變數影響到巨集外部變數
- 模式與樣板的重複用法
- 避免因為 Vec 大小一直改變而重新配置記憶體的解決辦法
- 尾隨逗號的處理方法 (包含遞迴呼叫巨集版本)
- 陣列元素的計數技巧 (包含遞迴呼叫巨集版本)
- Iterators (2024.01)
- Iterator, IntoIterator 介紹
- 實作 flatten 功能
- 透過讓 flatten 支援雙向走訪了解巢狀 bound 的使用
- 先 flatten 再走訪的缺點分析
- Smart Pointers and Interior Mutability (2024.01)
- 介紹 interior mutability
- 實作 Cell 型別理解如何限制程式只能單一執行緒執行。
- RefCell 型別的狀態轉換 (使用 Cell 限制程式單一執行緒執行)
- Rc 參考計數設值的細節 (使用 Cell 限制程式單一執行緒執行)
- NonNull 指標, PhantomData 型別用途以及 Drop Check 機制
- Cow 型態的使用時機
- Channels (2024.01)
- 實作 MPSC - Mutex, Condvar, Arc
- 處理 0 Sender/Receiver 的方法
- 批次接收資料最佳化
- Channel flavors - Synchronous, Asynchronous, Rendezvous 以及 Oneshot
- Future-aware channels
- Sorting Algorithms (2024.01)
- 實作 Bubble sort, Insertion sort, Selection sort 以及 Quick sort
- 為測試元素實作 PartialEq, PartialOrd, Ord
- Benchmark 比較次數以及執行時間
- Subtyping and Variance (2024.01)
- subtyping 的定義
- 透過實作 strtok 函式理解 covariance 以及 invaraince
- 透過簡單的函式理解 contravariance
- Variance, PhantomData 與 drop check 之間的關係
- The Drop Check (2024.01)
- 實作 Boks 理解 drop check 機制 (dropck_eyepatch, may_dangle)
- 如何讓自定義型別為 covaraint in T (NonNull)
- Atomics and Memory Ordering (2024.02)
- 實作 Mutex 理解 MESI protocol 以及 happens-before
compare_exchange
vs. compare_exchange_weak
- Ordering::SeqCst 說明
- volatile 的實際用途
- Dispatch and Fat Pointers (2024.02)
- 泛型參數的 Monomorphization
- Sized 與 not Sized 對程式帶來的影響
- Static Dispatch 以及 Dynamic Dispatch (包含 vtable 的介紹)
- Object safe 的必要條件
- 如何使 trait 物件為 Partial Object Safety
- trait 物件的限制以及解決方法
- async/await (
2024.02)
- Functions, Closures, and Their Traits (2024.02)
- Function item 與函式指標的差異
- capturing/ non-capturing closure 的差異
- static/ non-static closure 的差異
Fn
/ FnMut
/ FnOnce
trait 的差異
- Send, Sync, and their implementors (2024.02)
- 藉由簡易版的 Rc 來理解 Send
- Send 與 Sync 之間的差異
- Negative 實作的用途
- 檢視 Send 和 Sync 的一些 implementors
- Build Scripts and Foreign-Function Interfaces (FFI) (2024.02)
- 透過 libsodium/ libssh2-sys/libgit2-sys crate 了解建置腳本功能
- 測試 bindgen 以及 pkg-config 功能
- 實作 libsodium-sys 了解 Rust 如何使用 C 外部函式
- std::collections (2024.02)
- Sequences: Vec, VecDeque, LinkedList
- Sets: HashSet, BTreeSet
- Maps: HashMap, BTreeMap
- Misc: BinaryHeap
- 探討 Option, Result,
()
是否為 colleciton 類型
筆記編排
- 斜體字 (Italic)
代表新術語、URLs、email 地址、檔名,與副檔名。
- 定寬字 (
Constant width
)
代表程式,也在文章中代表程式元素,例如變數或函式名稱、資料庫、資料型別、環境變數、陳述式,與關鍵字。
- 定寬粗體字 (Constant width bold)
代表應由使用者親自輸入的命令或其他文字。
- 定寬斜體 (
Constant width italic
)
這種文字應換成使用者提供的值,或由程式程式脈絡決定的值。
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
該圖示代表提示或建議。
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
該圖示代表一般註釋。
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
該圖示代表警告或注意。