Skip to content

Commit c5d2f35

Browse files
committed
hello_exercism = "0.5.4"
1 parent 5d99b03 commit c5d2f35

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

73 files changed

+1427
-380
lines changed

docs/zh-first-volumn/src/SUMMARY.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,12 @@
2121
- [开发软件篋borrowing_exerci](./hello-borrowing/develop.md)
2222
- [使用软件篋borrowing_exerci](./hello-borrowing/apply.md)
2323
- [软件篋trait_exerci](./hello-trait/README.md)
24+
- [类型关键词struct](./hello-trait/examples-struct.md)
25+
- [实现关键词impl与方法代码实现](./hello-trait/examples-impl.md)
26+
- [函数代码实现](./hello-trait/examples-functions.md)
27+
- [衔接关键词trait与修饰关键词mut](./hello-trait/examples-trait.md)
2428
- [关于软件篋项目](./hello-trait/about.md)
2529
- [共享篋:开发命令](./hello-trait/commands-lib.md)
26-
- [共享篋:实例代码解释](./hello-trait/examples-codes.md)
2730
- [共享篋:程序结构解释](./hello-trait/lib-structure.md)
2831
- [共享篋:程序代码解释](./hello-trait/lib-codes.md)
2932
- [共享篋:目录tests的测试代码解释](./hello-trait/lib-tests.md)

docs/zh-first-volumn/src/foreword/README.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,13 @@
2323
- [Rust官方网站](https://www.rust-lang.org/)
2424
- [rustup官方网站](https://rustup.rs/)
2525
- [Cargo项目源代码](https://github.com/rust-lang/cargo)
26-
- [Crate.io官方网站](https://crates.io/)
26+
- [Crates s.io官方网站](https://crates.io/)
2727

2828
## 重要工具链接链接
2929
- [Tables Generator](https://www.tablesgenerator.com/)
30+
- [Liste der Unicode-Zeichen der Kategorie „Sonstiges Symbol“](https://www.compart.com/de/unicode/category/So)
31+
- [Sketchpad - Draw, Create, Share!](https://sketch.io/sketchpad/)
32+
- [Quality metadata badges](https://shields.io/)
33+
- [Continuous Integration and Deployment service for Windows and Linux | AppVeyor](https://www.appveyor.com/)
34+
- [Nu Shell](https://github.com/nushell/nushell)
35+
- [Markdown: Syntax](https://markdown.de/)

docs/zh-first-volumn/src/foreword/about.md

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,4 @@
102102
|| default | 叙述Rust语言默认情况 | 必须记住 | Ⓓ 所有模块和函数默认情况下都是私有的。 |
103103
|| regulation | 阐述Rust语言规则 | 必须记住 | ⓡ 所有字符串文字类型都是引用,且具有静态生命周期。 |
104104
|| consensus | 解释约定而非强制方法 | 最好记住 | Ⓒ 大多数单元测试都带有注解'#[cfg(test)]'的测试模块。 |
105-
|| idea | 必须记住 | 计算机技术和Rust语言基本概念 |
106-
107-
## 参考资料
108-
- [Liste der Unicode-Zeichen der Kategorie „Sonstiges Symbol“](https://www.compart.com/de/unicode/category/So)
109-
- [Sketchpad - Draw, Create, Share!](https://sketch.io/sketchpad/)
105+
|| idea | 必须记住 | 计算机技术和Rust语言基本概念 |
Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
11
# 第四章 软件篋borrowing_exerci
22

33

4+
## 参考资料
45
- [split-a-module-across-several-files](https://stackoverflow.com/questions/22596920/split-a-module-across-several-files)
56
- [ch07-05-separating-modules-into-different-files](https://doc.rust-lang.org/book/ch07-05-separating-modules-into-different-files.html)
6-
- [splitting-up-modules-in-rust](https://chronicbuildfailure.co/splitting-up-modules-in-rust-5ad7713201d5)
7+
- [splitting-up-modules-in-rust](https://chronicbuildfailure.co/splitting-up-modules-in-rust-5ad7713201d5)
8+
- [references-and-borrowing](https://doc.rust-lang.org/1.8.0/book/references-and-borrowing.html)
9+
- [rust-by-example/scope/borrow](https://doc.rust-lang.org/stable/rust-by-example/scope/borrow.html)
10+
- [rust-borrowing-and-ownership](http://squidarth.com/rc/rust/2018/05/31/rust-borrowing-and-ownership.html)
11+
- [understanding-rust-ownership-borrowing-lifetimes](https://medium.com/@bugaevc/understanding-rust-ownership-borrowing-lifetimes-ff9ee9f79a9c)
12+
- [you-can-t-turn-off-the-borrow-checker-in-rust](https://words.steveklabnik.com/you-can-t-turn-off-the-borrow-checker-in-rust)
13+
14+
Lines changed: 51 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,65 @@
1-
# 第二章
1+
# 第二章 软件篋trait_exerci
22

3-
## 学习内容
3+
### 学习内容
44
- 什么是Rust语言衔接关键词trait
55
- 为什么需要衔接关键词trait
66
- 怎么样实现Rust语言衔接关键词trait
77
- 实现关键词impl与衔接关键词trait是什么关系
8-
-
98

9+
### 篇目
1010

11-
## 篇目
11+
1. [关键词trait概念表述之一](#关键词trait概念表述之一)
12+
1. [关键词trait概念表述之二](#关键词trait概念表述之二)
13+
1. [关键词trait概念表述之三](#关键词trait概念表述之三)
14+
1. [解释关键词trait](#解释关键词trait)
15+
1. [题外话](#题外话)
16+
1. [怎么样使用Rust语言nightly版本](#怎么样使用rust语言nightly版本)
17+
1. [参考资料](#参考资料)
18+
1. [本章参考资料](#本章参考资料)
1219

13-
1. [方法与函数](#方法与函数)
14-
1. [关键词trait](#关键词trait)
15-
1. [修饰关键词mut](#修饰关键词mut)
16-
1. [关键词impl](#关键词impl)
17-
1. [关键词impl和for](#关键词impl和for)
18-
1. [](#)
19-
1. [](#)
20-
1. [](#)
20+
## 关键词trait概念表述之一
2121

22+
  [关键词trait][id_01]是Rust语言的一项功能,可以告诉Rust编译器一种类型必须提供的功能。
2223

23-
## 方法与函数
24+
## 关键词trait概念表述之二
2425

25-
## 衔接关键词trait
26-
- 默认是私有的,且可增加修饰关键词pub
27-
-
26+
  [关键词trait][id_02]是为任何未知类型定义方法的集合。
2827

29-
## 修饰关键词mut
28+
## 关键词trait概念表述之三
3029

31-
## 实现关键词impl
32-
- 默认是公开的,且可增加修饰关键词pub
33-
- 函数默认是私有的,且可增加修饰关键词pub
30+
  [关键词trait][id_03]告诉Rust编译器一种特定的类型具有且可与其他类型共享的功效性质。
3431

35-
## 关键词impl和for
36-
- 默认是公开的
37-
- 函数不可增加修饰关键词pub
32+
## 解释关键词trait
33+
34+
  关键词trait提供了一种类型或者几种类型之间的衔接方式。它应该包含下面内容:
35+
36+
- 存在一种类型或者几种类型
37+
- 使用关键词trait定义衔接名称
38+
- 使用关键词trait代码块定义方法和函数
39+
- 使用关键词"impl"和"for"组合,实现针对这一种类型或者这几种类型的方法和函数
40+
41+
## 题外话
42+
43+
### 怎么样使用Rust语言nightly版本
44+
```bash
45+
rustc --version
46+
rustup default nightly
47+
rustc --version
48+
rustup default stable
49+
rustup update
50+
rustup show
51+
```
52+
53+
### 参考资料
54+
- [Setting "rustup default nightly" and back to stable ends up](https://github.com/rust-lang/rustup.rs/issues/451)
55+
- [Toolchain 'nightly-x86_64-apple-darwin' missing](https://github.com/rust-lang/rust/issues/55571)
56+
57+
## 本章参考资料
58+
- [Impls & Traits](https://learning-rust.github.io/docs/b5.impls_and_traits.html)
59+
- [Traits from 'rust-by-example'](https://doc.rust-lang.org/stable/rust-by-example/trait.html)
60+
- [Traits from 'The Rust Programming Language'](https://doc.rust-lang.org/1.8.0/book/traits.html)
61+
- [Traits: Defining Shared Behavior](https://doc.rust-lang.org/beta/book/ch10-02-traits.html)
62+
63+
[id_01]:https://doc.rust-lang.org/1.8.0/book/traits.html
64+
[id_02]:https://doc.rust-lang.org/stable/rust-by-example/trait.html
65+
[id_03]:https://doc.rust-lang.org/beta/book/ch10-02-traits.html
Lines changed: 8 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,18 @@
1-
# 共享篋:开发命令
1+
## 共享篋:开发命令
22

3+
## 篇目
34

4-
# How to Understand the Rust Feature trait
5+
- [I. create the crate for library](#i-create-the-crate-for-library)
6+
- [II. create the crate for application](#ii-create-the-crate-for-application)
57

6-
## I. develop the crate
7-
### Step 1: create the default crate
8+
# I. create the crate for library
89
```bash
910
mkdir lib-hello && cd lib-hello
1011
cargo init --name trait_exerci --lib
11-
touch README.md
12-
vi README.md
1312
```
1413

15-
### Step 2: develop the crate source and test codes
16-
- Go to Crate Root Path
14+
# II. create the crate for application
1715
```bash
18-
vi Cargo.toml
19-
vi src/lib.rs
20-
cargo fmt
21-
cargo clippy
22-
mkdir tests
23-
touch tests/hello.rs
24-
vi tests/hello.rs
25-
touch tests/mod_hello.rs
26-
vi tests/mod_hello.rs
27-
cargo fmt
28-
cargo clippy
29-
cargo test
30-
```
31-
32-
### Step 3: develop the example codes
33-
- Go to Crate Root Path
34-
```bash
35-
mkdir examples
36-
touch examples/hello.rs
37-
vi examples/hello.rs
38-
cargo run --example hello
39-
```
40-
41-
4216
mkdir bin-hello && cd bin-hello
43-
cargo init --name hello-trait --lib
17+
cargo init --name hello-trait --bin
18+
```

docs/zh-first-volumn/src/hello-trait/examples-codes.md

Lines changed: 0 additions & 10 deletions
This file was deleted.
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# 函数代码实现
2+
3+
## 学习内容
4+
- 阐述
5+
- 理解
6+
7+
8+
## 篇目
9+
10+
1. [函数代码实现](#函数代码实现)
11+
1. [参考资料](#参考资料)
12+
13+
## 函数代码实现
14+
15+
{{#playpen ../../../../hello-trait/lib-hello/examples/method_function.rs editable}}
16+
17+
## 参考资料
18+
-
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# 实现关键词impl与方法代码实现
2+
3+
## 学习内容
4+
- 阐述
5+
- 理解
6+
7+
8+
## 篇目
9+
10+
1. [实现关键词impl与方法代码实现](#实现关键词impl与方法代码实现)
11+
1. [参考资料](#参考资料)
12+
13+
14+
## 实现关键词impl与方法代码实现
15+
16+
## 实现关键词impl
17+
- 默认是公开的,且可增加修饰关键词pub
18+
- 函数默认是私有的,且可增加修饰关键词pub
19+
20+
21+
{{#playpen ../../../../hello-trait/lib-hello/examples/method_instance.rs editable}}
22+
23+
24+
## 参考资料
25+
-
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# 类型关键词struct
2+
3+
4+
5+
## 篇目
6+
7+
1. [类型关键词struct是什么](#类型关键词struct是什么)
8+
1. [C语言形式的类型关键词struct代码](#C语言形式的类型关键词struct代码)
9+
1. [元组形式的类型关键词struct](#元组形式的类型关键词struct)
10+
1. [参考资料](#参考资料)
11+
12+
## 类型关键词struct是什么
13+
14+
类型关键词struct就是定义一种结构类型。
15+
16+
![image](../../images/hello-trait-11-struct.png)
17+
18+
19+
## 类型关键词struct的私有性
20+
21+
22+
## C语言形式的类型关键词struct代码
23+
24+
- 结构的定义方式
25+
- 结构的实例化方式
26+
27+
{{#playpen ../../../../hello-trait/lib-hello/examples/pub_field.rs editable}}
28+
29+
30+
## 元组形式的类型关键词struct
31+
32+
- 结构的定义方式
33+
- 结构的实例化方式
34+
35+
{{#playpen ../../../../hello-trait/lib-hello/examples/tuple_struct.rs editable}}
36+
37+
38+
## 参考资料
39+
- [structs from 'rust-by-example '](https://doc.rust-lang.org/stable/rust-by-example/custom_types/structs.html)
40+
-
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# 衔接关键词trait与修饰关键词mut
2+
3+
## 学习内容
4+
- 阐述
5+
- 理解
6+
7+
8+
## 篇目
9+
10+
1. [衔接关键词trait](#衔接关键词trait)
11+
1. [参考资料](#参考资料)
12+
13+
## 衔接关键词trait
14+
- 默认是私有的,且可增加修饰关键词pub
15+
-
16+
17+
## 修饰关键词mut
18+
19+
## 关键词impl和for
20+
- 默认是公开的
21+
- 函数不可增加修饰关键词pub
22+
23+
{{#playpen ../../../../hello-trait/lib-hello/examples/trait.rs editable}}
24+
25+
## 参考资料
26+
-
Loading
Binary file not shown.

0 commit comments

Comments
 (0)