aboutsummaryrefslogtreecommitdiff
path: root/docs/dev
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2020-06-06 18:32:45 +0100
committerAleksey Kladov <[email protected]>2020-06-06 18:32:45 +0100
commitae1acbd09c8e98e4e23f01f633ad551dabd5c578 (patch)
tree46b1a8776a48b239db9e08c4130cd4ff54360372 /docs/dev
parenta609336d7287b3ddddbde30b1f0fb606bf149baf (diff)
Document import style
Diffstat (limited to 'docs/dev')
-rw-r--r--docs/dev/README.md21
1 files changed, 21 insertions, 0 deletions
diff --git a/docs/dev/README.md b/docs/dev/README.md
index 194a40e15..6f74d4223 100644
--- a/docs/dev/README.md
+++ b/docs/dev/README.md
@@ -184,6 +184,27 @@ use crate::{}
184use super::{} // but prefer `use crate::` 184use super::{} // but prefer `use crate::`
185``` 185```
186 186
187## Import Style
188
189Items from `hir` and `ast` should be used qualified:
190
191```rust
192// Good
193use ra_syntax::ast;
194
195fn frobnicate(func: hir::Function, strukt: ast::StructDef) {}
196
197// Not as good
198use hir::Function;
199use ra_syntax::ast::StructDef;
200
201fn frobnicate(func: Function, strukt: StructDef) {}
202```
203
204Avoid local `use MyEnum::*` imports.
205
206Prefer `use crate::foo::bar` to `use super::bar`.
207
187## Order of Items 208## Order of Items
188 209
189Optimize for the reader who sees the file for the first time, and wants to get the general idea about what's going on. 210Optimize for the reader who sees the file for the first time, and wants to get the general idea about what's going on.