diff options
author | Aleksey Kladov <[email protected]> | 2020-08-28 15:53:49 +0100 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2020-08-28 15:53:49 +0100 |
commit | 4f5d2ffac2c15d00207f7452e7eb356b01de7317 (patch) | |
tree | 8e931baf0c9673b71c18949d39c66a4f63e57030 /docs/dev/style.md | |
parent | 32b089d6ec8e0ede0871f201437d16efd341b150 (diff) |
fmt import
Diffstat (limited to 'docs/dev/style.md')
-rw-r--r-- | docs/dev/style.md | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/docs/dev/style.md b/docs/dev/style.md index bb99c4855..397e85b35 100644 --- a/docs/dev/style.md +++ b/docs/dev/style.md | |||
@@ -112,6 +112,22 @@ Avoid local `use MyEnum::*` imports. | |||
112 | 112 | ||
113 | Prefer `use crate::foo::bar` to `use super::bar`. | 113 | Prefer `use crate::foo::bar` to `use super::bar`. |
114 | 114 | ||
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 | |||
115 | # Order of Items | 131 | # Order of Items |
116 | 132 | ||
117 | Optimize for the reader who sees the file for the first time, and wants to get a general idea about what's going on. | 133 | Optimize for the reader who sees the file for the first time, and wants to get a general idea about what's going on. |