Rust 語言之旅
課堂
您好,
第一章 - 基礎概念
The Rust Playground (Rust 語言遊樂場)
變量 (Variables)
改變變數的值
基本類型 (Primitive types)
基本的數據類型轉換
常數 (Constant)
陣列 (Array)
函數 (Functions)
多個回傳值
沒有回傳類型
第一章 - 總結
第二章 - 基本流程控制
if/else if/else
loop
while
for
match
從迴圈回傳數值
從區塊表達式回傳數值
第二章 - 總結
第三章 - 基本資料結構 (data structures)
結構 (structures)
呼叫方法 (method)
記憶體 (memory)
在記憶體裡創建資料
數組型結構 (tuple-like)
單組型結構 (unit-like)
列舉 (enumerations)
列舉與資料
第三章 - 總結
第四章 - 泛型 (generic types)
什麼是泛型?
空值表示
選項 (option)
結果 (result)
失敗的主函式 (failable main)
優雅的錯誤處理
醜陋的選項 (option)/結果 (result) 處理
向量 (vectors)
第四章 - 總結
第五章 - 擁有權 (ownership) 與借資料 (borrowing data)
擁有權 (ownership)
範圍 (scope-based) 資源管理
徹下是有階級的
擁有權轉移
擁有權歸還
從參考 (references) 借擁有權
從參考借可變 (mutable) 的擁有權
解參考 (dereferencing)
傳遞借來的資料 (borrowed data)
參考的參考 (references of references)
明確的生命週期
多個生命週期
靜態生命週期 (static lifetimes)
資料型別的生命週期
第五章 - 總結
第六章 - 文字
字串常量 (string literals)
什麼是 utf-8
跳脫字元
多行字串常量
原始字串常量 (raw string literals)
從檔案來的字串常量
字串切片 (string slice)
字元 (chars)
字串 (string)
將文字當作函式參數
建立字串
字串格式化
字串轉換
第六章 - 總結
第七章 - 物件導向程式 (object oriented programming)
什麼是 OOP?
Rust 不是 OOP
封裝方法 (encapsulation with methods)
暴露指定的抽象化 (abstraction with selective exposure)
特徵多型 (polymorphism with traits)
特徵上的方法 (implemented methods on traits)
特徵繼承 (trait inheritance)
動態與靜態的發送 (dynamic vs static dispatch)
特徵物件 (trait objects)
處理末知大小的資料 (handling unsized data)
泛型函式 (generic functions)
泛型函式簡寫 (generic function shorthand)
Box
重訪泛型結構 (generic structs revisited)
第七章 - 總結
第八章 - 智慧指標
重新認識參考
原始指標 (raw pointers)
解參考 (dereferencing)
運算子 *
運算子 .
智慧指標
智慧的不安全程式碼
熟悉的老朋友
分配在堆上的記憶體
重新認識可能會失敗的 main
參考計數 (reference counting)
共享存取
跨執行緒共享
組合智慧指標
第八章 - 總結
第九章 - 專案組織與結構
模組
撰寫一個程式
撰寫一個函式庫
參考其他模組及 crate
參考多個項目
建立模組
模組階層結構
內嵌模組
內部模組參考
匯出
結構的可見性
Prelude
屬於你自己的 Prelude
第九章 - 總結
第十章 - 結語