Skip to content

Commit 8146700

Browse files
bors[bot]matklad
andauthored
Merge #5908
5908: fmt import r=matklad a=matklad bors r+ 🤖 Co-authored-by: Aleksey Kladov <[email protected]>
2 parents 32b089d + 4f5d2ff commit 8146700

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

docs/dev/style.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,22 @@ Avoid local `use MyEnum::*` imports.
112112

113113
Prefer `use crate::foo::bar` to `use super::bar`.
114114

115+
When implementing `Debug` or `Display`, import `std::fmt`:
116+
117+
```rust
118+
// Good
119+
use std::fmt;
120+
121+
impl fmt::Display for RenameError {
122+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { .. }
123+
}
124+
125+
// Not as good
126+
impl std::fmt::Display for RenameError {
127+
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { .. }
128+
}
129+
```
130+
115131
# Order of Items
116132

117133
Optimize for the reader who sees the file for the first time, and wants to get a general idea about what's going on.

0 commit comments

Comments
 (0)