rust-unofficial / patterns

A catalogue of Rust design patterns, anti-patterns and idioms
https://rust-unofficial.github.io/patterns/
Mozilla Public License 2.0
8.11k stars 375 forks source link

Add examples for each pattern #17

Closed iluxonchik closed 3 years ago

iluxonchik commented 9 years ago

In my opinion, it would be usueful to include at least one concrete example of each pattern at the end of the file. It shouldn't be anything complicated, just something that gives the "feel" of the practical usage.

nrc commented 9 years ago

The patterns already include an example, do you want something more concrete like an actual real-life use rather than a toy example?

iluxonchik commented 9 years ago
The patterns already include an example

True, but it's just a template.

No, I mean a toy example, but with code that'll actually compile. Like, give a little intro text to give an intuition of where the pattern might be used. This will specially be helpful for someone who's just beginning with rust.

As an example, you can check how the Builder pattern is presented in Effective Java, 2nd Edition book. I will try to make some pull requests this week to show you what I mean.

simonsan commented 3 years ago

We are running CI with mdbook test over the whole example section of the book. I rechecked it, and each pattern and/or idiom has examples. Every future article submitted with a PR will have an example by convention. Closing this issue therefore.