fmt import

This commit is contained in:
Aleksey Kladov 2020-08-28 16:53:49 +02:00
parent 32b089d6ec
commit 4f5d2ffac2

View file

@ -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.