aboutsummaryrefslogtreecommitdiff
path: root/rust/dot-dsl/README.md
diff options
context:
space:
mode:
Diffstat (limited to 'rust/dot-dsl/README.md')
-rw-r--r--rust/dot-dsl/README.md121
1 files changed, 121 insertions, 0 deletions
diff --git a/rust/dot-dsl/README.md b/rust/dot-dsl/README.md
new file mode 100644
index 0000000..29e0e7a
--- /dev/null
+++ b/rust/dot-dsl/README.md
@@ -0,0 +1,121 @@
1# DOT DSL
2
3A [Domain Specific Language (DSL)](https://en.wikipedia.org/wiki/Domain-specific_language) is a
4small language optimized for a specific domain. Since a DSL is
5targeted, it can greatly impact productivity/understanding by allowing the
6writer to declare *what* they want rather than *how*.
7
8One problem area where they are applied are complex customizations/configurations.
9
10For example the [DOT language](https://en.wikipedia.org/wiki/DOT_(graph_description_language)) allows
11you to write a textual description of a graph which is then transformed into a picture by one of
12the [Graphviz](http://graphviz.org/) tools (such as `dot`). A simple graph looks like this:
13
14 graph {
15 graph [bgcolor="yellow"]
16 a [color="red"]
17 b [color="blue"]
18 a -- b [color="green"]
19 }
20
21Putting this in a file `example.dot` and running `dot example.dot -T png
22-o example.png` creates an image `example.png` with red and blue circle
23connected by a green line on a yellow background.
24
25Write a Domain Specific Language similar to the Graphviz dot language.
26
27Our DSL is similar to the Graphviz dot language in that our DSL will be used
28to create graph data structures. However, unlike the DOT Language, our DSL will
29be an internal DSL for use only in our language.
30
31More information about the difference between internal and external DSLs can be
32found [here](https://martinfowler.com/bliki/DomainSpecificLanguage.html).
33
34## Builder pattern
35
36This exercise expects you to build several structs using `builder pattern`.
37In short, this pattern allows you to split the construction function of your struct, that contains a lot of arguments, into
38several separate functions. This approach gives you the means to make compact but highly-flexible struct construction and
39configuration.
40You can read more about it on the [following page](https://doc.rust-lang.org/1.0.0/style/ownership/builders.html).
41
42
43## Rust Installation
44
45Refer to the [exercism help page][help-page] for Rust installation and learning
46resources.
47
48## Writing the Code
49
50Execute the tests with:
51
52```bash
53$ cargo test
54```
55
56All but the first test have been ignored. After you get the first test to
57pass, open the tests source file which is located in the `tests` directory
58and remove the `#[ignore]` flag from the next test and get the tests to pass
59again. Each separate test is a function with `#[test]` flag above it.
60Continue, until you pass every test.
61
62If you wish to run all ignored tests without editing the tests source file, use:
63
64```bash
65$ cargo test -- --ignored
66```
67
68To run a specific test, for example `some_test`, you can use:
69
70```bash
71$ cargo test some_test
72```
73
74If the specific test is ignored use:
75
76```bash
77$ cargo test some_test -- --ignored
78```
79
80To learn more about Rust tests refer to the [online test documentation][rust-tests]
81
82Make sure to read the [Modules][modules] chapter if you
83haven't already, it will help you with organizing your files.
84
85## Further improvements
86
87After you have solved the exercise, please consider using the additional utilities, described in the [installation guide](https://exercism.io/tracks/rust/installation), to further refine your final solution.
88
89To format your solution, inside the solution directory use
90
91```bash
92cargo fmt
93```
94
95To see, if your solution contains some common ineffective use cases, inside the solution directory use
96
97```bash
98cargo clippy --all-targets
99```
100
101## Submitting the solution
102
103Generally you should submit all files in which you implemented your solution (`src/lib.rs` in most cases). If you are using any external crates, please consider submitting the `Cargo.toml` file. This will make the review process faster and clearer.
104
105## Feedback, Issues, Pull Requests
106
107The [exercism/rust](https://github.com/exercism/rust) repository on GitHub is the home for all of the Rust exercises. If you have feedback about an exercise, or want to help implement new exercises, head over there and create an issue. Members of the rust track team are happy to help!
108
109If you want to know more about Exercism, take a look at the [contribution guide](https://github.com/exercism/docs/blob/master/contributing-to-language-tracks/README.md).
110
111[help-page]: https://exercism.io/tracks/rust/learning
112[modules]: https://doc.rust-lang.org/book/ch07-02-defining-modules-to-control-scope-and-privacy.html
113[cargo]: https://doc.rust-lang.org/book/ch14-00-more-about-cargo.html
114[rust-tests]: https://doc.rust-lang.org/book/ch11-02-running-tests.html
115
116## Source
117
118Wikipedia [https://en.wikipedia.org/wiki/DOT_(graph_description_language)](https://en.wikipedia.org/wiki/DOT_(graph_description_language))
119
120## Submitting Incomplete Solutions
121It's possible to submit an incomplete solution so you can see how others have completed the exercise.