You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: CONTRIBUTING.md
+7-5Lines changed: 7 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,11 +1,10 @@
1
1
# Contributing
2
2
3
-
## Discssion board
3
+
## Discussion board
4
4
5
5
If you have a question or an idea regarding certain content but you want to have feedback of fellow community members
6
6
and you think it may not be appropriate to file an issue open a discussion in our [discussion board](https://github.com/rust-unofficial/patterns/discussions).
7
7
8
-
9
8
## Writing a new article
10
9
11
10
Before writing a new article please check our [issues](https://github.com/rust-unofficial/patterns/issues) and
@@ -29,9 +28,7 @@ with the [Wayback Machine](https://web.archive.org/) and use the link to that sn
29
28
30
29
Don't forget to add your new article to the `SUMMARY.md` to let it be rendered to the book.
31
30
32
-
Please make `Draft Pull requests` early so we can follow your progress and can give early feedback (see the following section).
33
-
34
-
31
+
Please make `Draft Pull requests` early so we can follow your progress and can give early feedback (see the following section).
35
32
36
33
## Creating a Pull Request
37
34
@@ -42,6 +39,11 @@ Early reviews of the community are not meant as an offense but to give feedback.
42
39
43
40
A good principle: "Work together, share ideas, teach others."
44
41
42
+
### Test the book locally before submitting
43
+
44
+
Before submitting the PR launch the commands `mdbook build` to make sure that the book builds and `mdbook test` to make sure that
45
+
code examples are correct.
46
+
45
47
### Important Note
46
48
47
49
Please **don't force push** your branch to keep commit history and make it easier of us to see changes between reviews.
Copy file name to clipboardExpand all lines: README.md
+2-27Lines changed: 2 additions & 27 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,46 +4,24 @@ An open source book about design patterns and idioms in the Rust programming
4
4
language that you can read [here](https://rust-unofficial.github.io/patterns/).
5
5
6
6
7
-
## Contents
8
-
9
-
[Introduction](intro.md)
10
-
7
+
## TODOs
11
8
12
9
### Idioms
13
10
14
-
*[Constructor](idioms/ctor.md)
15
-
*[Concatenating strings with `format!`](idioms/concat-format.md)
16
-
*[Privacy for extensibility](idioms/priv-extend.md)
17
11
* TODO stability for extensibility
18
12
* TODO trait to separate visibility of methods from visibility of data (https://github.com/sfackler/rust-postgres/blob/v0.9.6/src/lib.rs#L1400)
19
-
*[Collections are smart pointers](idioms/deref.md)
20
13
* TODO leak amplification ("Vec::drain sets the Vec's len to 0 prematurely so that mem::forgetting Drain "only" mem::forgets more stuff. instead of exposing uninitialized memory or having to update the len on every iteration")
21
-
*[Finalisation in destructors](idioms/dtor-finally.md)
22
14
* TODO interior mutability - UnsafeCell, Cell, RefCell
23
-
*[Iterating over an `Option`](idioms/option-iter.md)
24
-
*[`Default` trait](idioms/default.md)
25
-
*[Pass variables to closure](idioms/pass-var-to-closure.md)
26
-
*[`mem::replace(_)` to avoid needless clones](idioms/mem-replace.md)
* TODO FFI usage (By being mindful of how to provide Rust libraries, and make use of existing libraries across the FFI, you can get more out of benefits Rust can bring)
* TODO closures and lifetimes (coupling to lifetime)
40
22
* TODO platform-specific sub-modules (https://github.com/rust-lang/rfcs/blob/master/text/0517-io-os-reform.md#platform-specific-opt-in)
41
23
* TODO Module organisation (by looking at examples such as Rusts `libstd`, and how it integrated into the Rusts source code, lessons can be learned about ergonomic project management and API design. Closely assosciated with platform-specific sub-modules)
42
-
*[Entry API](patterns/entry.md) (TODO Currently just a boilerplate)
43
-
*[Visitor](patterns/visitor.md)
44
-
*[Fold](patterns/fold.md)
45
-
*[Prefer small crates](patterns/small-crates.md)
46
-
*[Contain unsafety in small modules](patterns/unsafe-mods.md)
24
+
*[Entry API](patterns/entry.md) (Currently just a boilerplate)
47
25
* TODO extension traits
48
26
* TODO destructor bombs (ensure linear typing dynamically, e.g., https://github.com/Munksgaard/session-types/commit/0f25ccb7c3bc9f65fa8eaf538233e8fe344a189a)
49
27
* TODO convertible to Foo trait for more generic generics (e.g., http://static.rust-lang.org/doc/master/std/fs/struct.File.html#method.open)
@@ -52,19 +30,16 @@ language that you can read [here](https://rust-unofficial.github.io/patterns/).
52
30
* TODO composition of structs to please the borrow checker
53
31
* TODO `Error` traits and `Result` forwarding
54
32
* TODO graphs
55
-
*[Compose structs together for better borrowing](patterns/compose-structs.md)
56
33
57
34
58
35
### Anti-patterns
59
36
60
37
*[catch_unwind for exceptions](anti_patterns/catch_panic.md)
61
38
* TODO Clone to satisfy the borrow checker
62
-
*[Deref polymorphism](anti_patterns/deref.md)
63
39
* TODO Matching all fields of a struct (back compat)
64
40
* TODO wildcard matches
65
41
* TODO taking an enum rather than having multiple functions
66
42
* TODO `unwrap()`ing every `Result` instead of forwarding it
Copy file name to clipboardExpand all lines: functional/index.md
+22-22Lines changed: 22 additions & 22 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -15,17 +15,17 @@ println!("{}", sum);
15
15
With imperative programs, we have to play compiler to see what is happening. Here, we start with a `sum` of `0`. Next, we iterate through the range from 1 to 10. Each time through the loop, we add the corresponding value in the range. Then we print it out.
16
16
17
17
|`i`|`sum`|
18
-
|---|-----|
19
-
|1 |1|
20
-
|2 |3|
21
-
|3 |6|
22
-
|4 |10|
23
-
|5 |15|
24
-
|6 |21|
25
-
|7 |28|
26
-
|8 |36|
27
-
|9 |45|
28
-
| 10 | 55|
18
+
|:---:|:-----:|
19
+
| 1|1|
20
+
| 2|3|
21
+
| 3|6|
22
+
| 4|10|
23
+
| 5|15|
24
+
| 6|21|
25
+
| 7|28|
26
+
| 8|36|
27
+
| 9|45|
28
+
|10 |55|
29
29
30
30
This is how most of us start out programming. We learn that a program is a set of steps.
31
31
@@ -40,14 +40,14 @@ Whoa! This is really different! What's going on here? Remember that with declara
40
40
Here, we are composing functions of addition (this closure: `|a, b| a + b)`) with a range from 1 to 10. The `0` is the starting point, so `a` is `0` at first. `b` is the first element of the range, `1`. `0 + 1 = 1` is the result. So now we `fold` again, with `a = 1`, `b = 2` and so `1 + 2 = 3` is the next result. This process continues until we get to the last element in the range, `10`.
0 commit comments