mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-26 04:53:34 +00:00
fmt import
This commit is contained in:
parent
32b089d6ec
commit
4f5d2ffac2
1 changed files with 16 additions and 0 deletions
|
@ -112,6 +112,22 @@ Avoid local `use MyEnum::*` imports.
|
||||||
|
|
||||||
Prefer `use crate::foo::bar` to `use super::bar`.
|
Prefer `use crate::foo::bar` to `use super::bar`.
|
||||||
|
|
||||||
|
When implementing `Debug` or `Display`, import `std::fmt`:
|
||||||
|
|
||||||
|
```rust
|
||||||
|
// Good
|
||||||
|
use std::fmt;
|
||||||
|
|
||||||
|
impl fmt::Display for RenameError {
|
||||||
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { .. }
|
||||||
|
}
|
||||||
|
|
||||||
|
// Not as good
|
||||||
|
impl std::fmt::Display for RenameError {
|
||||||
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { .. }
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
# Order of Items
|
# Order of Items
|
||||||
|
|
||||||
Optimize for the reader who sees the file for the first time, and wants to get a general idea about what's going on.
|
Optimize for the reader who sees the file for the first time, and wants to get a general idea about what's going on.
|
||||||
|
|
Loading…
Reference in a new issue