diff options
| author | Aleksey Kladov <aleksey.kladov@gmail.com> | 2021-08-30 19:35:49 +0300 |
|---|---|---|
| committer | Aleksey Kladov <aleksey.kladov@gmail.com> | 2021-08-30 19:39:08 +0300 |
| commit | 9e0203bd69ffd236b9e129235b94807909823eac (patch) | |
| tree | 9a572e8ae3d9f0424f46bf8d61eda3aeed615909 /docs/dev | |
| parent | a59f344c4ff4f2bd3923a4499eb5868451698009 (diff) | |
| download | rust-9e0203bd69ffd236b9e129235b94807909823eac.tar.gz rust-9e0203bd69ffd236b9e129235b94807909823eac.zip | |
internal: make scheduling control flow more obvious
There should be only one place where we need to check if we want to start background activities.
Diffstat (limited to 'docs/dev')
| -rw-r--r-- | docs/dev/style.md | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/docs/dev/style.md b/docs/dev/style.md index 7954ae8ec6d..6131cdcbdce 100644 --- a/docs/dev/style.md +++ b/docs/dev/style.md @@ -257,6 +257,25 @@ if idx >= len { **Rationale:** it's useful to see the invariant relied upon by the rest of the function clearly spelled out. +## Control Flow + +As a special case of the previous rule, do not hide control flow inside functions, push it to the caller: + +```rust +// GOOD +if cond { + f() +} + +// BAD +fn f() { + if !cond { + return; + } + ... +} +``` + ## Assertions Assert liberally. |
