diff options
| author | Aleksey Kladov <aleksey.kladov@gmail.com> | 2020-06-06 19:32:45 +0200 |
|---|---|---|
| committer | Aleksey Kladov <aleksey.kladov@gmail.com> | 2020-06-06 19:32:45 +0200 |
| commit | ae1acbd09c8e98e4e23f01f633ad551dabd5c578 (patch) | |
| tree | 46b1a8776a48b239db9e08c4130cd4ff54360372 /docs/dev | |
| parent | a609336d7287b3ddddbde30b1f0fb606bf149baf (diff) | |
| download | rust-ae1acbd09c8e98e4e23f01f633ad551dabd5c578.tar.gz rust-ae1acbd09c8e98e4e23f01f633ad551dabd5c578.zip | |
Document import style
Diffstat (limited to 'docs/dev')
| -rw-r--r-- | docs/dev/README.md | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/docs/dev/README.md b/docs/dev/README.md index 194a40e15c4..6f74d42236d 100644 --- a/docs/dev/README.md +++ b/docs/dev/README.md @@ -184,6 +184,27 @@ use crate::{} use super::{} // but prefer `use crate::` ``` +## Import Style + +Items from `hir` and `ast` should be used qualified: + +```rust +// Good +use ra_syntax::ast; + +fn frobnicate(func: hir::Function, strukt: ast::StructDef) {} + +// Not as good +use hir::Function; +use ra_syntax::ast::StructDef; + +fn frobnicate(func: Function, strukt: StructDef) {} +``` + +Avoid local `use MyEnum::*` imports. + +Prefer `use crate::foo::bar` to `use super::bar`. + ## Order of Items Optimize for the reader who sees the file for the first time, and wants to get the general idea about what's going on. |
