From 4f5d2ffac2c15d00207f7452e7eb356b01de7317 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Fri, 28 Aug 2020 16:53:49 +0200 Subject: fmt import --- docs/dev/style.md | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) 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. 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 Optimize for the reader who sees the file for the first time, and wants to get a general idea about what's going on. -- cgit v1.2.3