rustlings
推薦一個學習rust非常好的repo:
Small exercises to get you used to reading and writing Rust code! - 學習rust語法的一些非常好的小練習
This project contains small exercises to get you used to reading and writing Rust code. This includes reading and responding to compiler messages!
這裏放一下我的解答的地址:
https://github.com/yunwei37/os-summer-of-code-daily
第一天的這些部分都比較簡單:
- quiz 1-4:一般是對應於上一章節剛完成的內容
- variables:變量
- if:if表達式
- function:函數
- primitive_types:主要類型
- structs:結構體
- strings:字符串
- enums:枚舉
- tests:測試
- modules:模塊
- macros:宏定義
- move_semantics:將值賦給另一個變量時移動它
第二天:
- errors:錯誤處理,Ok and Err
- option:匹配 Option
- clippy:一個rust的靜態代碼分析工具(之前已經碰到好多遍了
- standard_library_types:這邊講標準庫裏面各種類型的使用,可能是最複雜的一部分;包含Arc、Box、迭代器等;
- traits:定義與使用;
- generics:泛型
- threads:線程(這裏我是用mutex包裝了一下
- conversions:rust的類型轉換
這些練習可以深刻讓人感受到如何和編譯器編譯器作艱苦卓絕的鬥爭