diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2020-06-15 09:33:45 +0100 |
---|---|---|
committer | GitHub <[email protected]> | 2020-06-15 09:33:45 +0100 |
commit | 672d160b013df82b1729fd3db130ff7b6f9b5b31 (patch) | |
tree | 84f991105ea0550450a965ca4585486c935eeedb /docs | |
parent | 6609e71b16567e1a342f5c2461701d93d1273c93 (diff) | |
parent | 5413a2f962aed7c602902ea7f4802b0e721c1551 (diff) |
Merge #4888
4888: Var naming r=matklad a=matklad
bors r+
🤖
Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'docs')
-rw-r--r-- | docs/dev/README.md | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/docs/dev/README.md b/docs/dev/README.md index 1ce8666e3..2e4a45998 100644 --- a/docs/dev/README.md +++ b/docs/dev/README.md | |||
@@ -236,6 +236,13 @@ struct Foo { | |||
236 | } | 236 | } |
237 | ``` | 237 | ``` |
238 | 238 | ||
239 | ## Variable Naming | ||
240 | |||
241 | We generally use boring and long names for local variables ([yay code completion](https://github.com/rust-analyzer/rust-analyzer/pull/4162#discussion_r417130973)). | ||
242 | The default name is lowercased named of the type: `global_state: GlobalState`. | ||
243 | Avoid ad-hoc acronyms and contractions, but use the ones that exist consistently (`db`, `ctx`, `acc`). | ||
244 | The default name for "result of the function" local variable is `res`. | ||
245 | |||
239 | ## Preconditions | 246 | ## Preconditions |
240 | 247 | ||
241 | Function preconditions should generally be expressed in types and provided by the caller (rather than checked by callee): | 248 | Function preconditions should generally be expressed in types and provided by the caller (rather than checked by callee): |