mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-26 04:53:34 +00:00
Document import style
This commit is contained in:
parent
a609336d72
commit
ae1acbd09c
1 changed files with 21 additions and 0 deletions
|
@ -184,6 +184,27 @@ use crate::{}
|
||||||
use super::{} // but prefer `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
|
## 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.
|
Optimize for the reader who sees the file for the first time, and wants to get the general idea about what's going on.
|
||||||
|
|
Loading…
Reference in a new issue