patterns/idioms
Riley Shea 4017a73d62
Fix default idiom example (#134)
Before this change, the example code doesn't run on the current rust stable release(1.49).
This is because `Path` inherently has a u8 that requires the sized trait which requires either statics or replacing Path with PathBuf.

After this change, the example code will run "as-is" without warnings or errors.
2021-01-03 08:44:31 +01:00
..
concat-format.md Fix a slight typo 2018-12-14 15:27:48 -05:00
ctor.md Add doc tests to CI (#124) 2021-01-02 12:40:52 +01:00
default.md Fix default idiom example (#134) 2021-01-03 08:44:31 +01:00
deref.md Add doc tests to CI (#124) 2021-01-02 12:40:52 +01:00
dtor-finally.md Add doc tests to CI (#124) 2021-01-02 12:40:52 +01:00
mem-replace.md Added comment to explain second example 2017-01-01 05:26:33 +01:00
on-stack-dyn-dispatch.md Fix on-stack dispatch example (#137) 2021-01-03 08:39:53 +01:00
option-iter.md option-iter: Fix typo in extend example 2017-11-28 11:11:23 +02:00
pass-var-to-closure.md Add doc tests to CI (#124) 2021-01-02 12:40:52 +01:00
priv-extend.md Add doc tests to CI (#124) 2021-01-02 12:40:52 +01:00
README.md Add introductions (#117) 2021-01-02 12:15:33 +01:00
rustdoc-init.md Add doc tests to CI (#124) 2021-01-02 12:40:52 +01:00
temporary-mutability.md Add doc tests to CI (#124) 2021-01-02 12:40:52 +01:00

Idioms

Idioms are commonly used styles and patterns largely agreed upon by a community. They are guidelines. Writing idiomatic code allows other developers to understand what is happening because they are familiar with the form that it has.

The computer understands the machine code that is generated by the compiler. The language is therefore mostly beneficial to the developer. So, since we have this abstraction layer, why not put it to good use and make it simple?

Remember the KISS principle: "Keep It Simple, Stupid". It claims that "most systems work best if they are kept simple rather than made complicated; therefore, simplicity should be a key goal in design, and unnecessary complexity should be avoided".

Code is there for humans, not computers, to understand.