> ## Content Index
> Fetch the complete content index at: https://yinguobing.com/blog/llms.txt
> Use this file to discover other available public pages before exploring further.

# 纪念第一个Rust项目
- URL: https://yinguobing.com/blog/first-step-to-rust/
- Published: 2022-04-10T14:37:44.000Z
- Updated: 2026-06-12T12:03:57.000Z
- Description: 万里长征迈出了蹒跚一步
- Author: 尹国冰
- Tags: Rust

我的Rust学习路径大概分为三个阶段。

### 第一阶段：The Rust Programming Language 

通过细读官方读本，尝试从整体了解Rust这门语言的基本概念、开发逻辑，以及与其它语言相比的独到之处。这本书无疑是学习Rust的权威读本。不过在书读完之后，我建议观看YouTube上Rust频道提供的大量视频。这些视频从不同角度提供了Rust学习指南，例如有些视频是针对Rust特性的专题；有一些提供了入门的心态指导。这些更加口语化、更加贴近开发者的视频教程某种程度上与官方读本互为补充，建议不要错过。

[The Rust Programming Language - The Rust Programming Language![](https://doc.rust-lang.org/book/favicon.png)The Rust Programming Language](https://doc.rust-lang.org/book/?ref=yinguobing.com#the-rust-programming-language)

### 第二阶段：动手做实验

Rust官方提供了两个动手做模块：[Rustlings Course](https://github.com/rust-lang/rustlings/?ref=yinguobing.com) 与 [Rust by Example](https://doc.rust-lang.org/stable/rust-by-example/?ref=yinguobing.com) 。这两者都包含了大量的示例代码，区别在于：Rustlings中提供的实验代码都是不完整的，你需要在计算机上搭建开发环境，之后以“闯关”的模式补充缺失的代码，直到全部完成。而Rust by Example提供的代码几乎都是完整的，并且可以在浏览器中直接运行。

[GitHub - rust-lang/rustlings: Small exercises to get you used to reading and writing Rust code!:crab: Small exercises to get you used to reading and writing Rust code! - GitHub - rust-lang/rustlings: Small exercises to get you used to reading and writing Rust code!![](https://github.com/fluidicon.png)GitHubrust-lang![](https://opengraph.githubassets.com/694ce481e96db30a8e17d9aaf76229c128309dc1443c6b3efd922e39992ca292/rust-lang/rustlings)](https://github.com/rust-lang/rustlings/?ref=yinguobing.com)

Rustlings

[Introduction - Rust By ExampleRust by Example (RBE) is a collection of runnable examples that illustrate various Rust concepts and standard libraries.![](https://doc.rust-lang.org/stable/rust-by-example/favicon.png)Rust By Example](https://doc.rust-lang.org/stable/rust-by-example/?ref=yinguobing.com)

Rust by Example

这两个模块通过实际动手做强化了对之前书本中概念的理解，关键在于找到使用Rust编程的“感觉”。

### 第三阶段：动手做项目

这一步是迟早要迈出去的。通过目的性明确的实战项目，进一步巩固基础概念，养成肌肉记忆。同时实战项目目的明确，通常会与你在生活或者工作中遇到的实际问题相关联。在实战项目中取得进展，会给你带来实际有效的正面反馈。如同种下一粒种子，等它慢慢长大。

我的第一个Rust项目正是源于工作中的需求。在深度学习数据清洗时经常会需要统计某个文件夹下的文件数目以及类别。这个功能非常简单，也正好拿来作为第一个入门项目练手。我把它放在了GitHub上：

[GitHub - yinguobing/count\_files: A simple command line tool to count all files in a directory.A simple command line tool to count all files in a directory. - GitHub - yinguobing/count\_files: A simple command line tool to count all files in a directory.![](https://github.com/fluidicon.png)GitHubyinguobing![](https://opengraph.githubassets.com/83a1a2f33dda50b28372341cfe7ec393380c6945d90505257fb36c42a43c9b4f/yinguobing/count_files)](https://github.com/yinguobing/count%5Ffiles?ref=yinguobing.com)

目前它只能按照文件的后缀名来区别文件类型。最终以表格的形式输出结果。

```bash
yinguobing$ ./count_files ~/data/
Counting files in /Users/Robin/data/
+-----------+-------+
| File type | Count |
+===================+
| jpg       |    29 |
|-----------+-------|
| jpeg      |     7 |
|-----------+-------|
| txt       |     6 |
|-----------+-------|
| gz        |     4 |
|-----------+-------|
| png       |     2 |
|-----------+-------|
| webp      |     1 |
+-----------+-------+
```

输出结果示例

当前的实现无论是代码的写法，还是项目依赖的选择，都有很大的改进余地。不积跬步无以至千里，这里纪念一下万里长征迈出的蹒跚一步。