diff options
Diffstat (limited to 'docs/dev/style.md')
-rw-r--r-- | docs/dev/style.md | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/docs/dev/style.md b/docs/dev/style.md index d91a9108e..be2c77847 100644 --- a/docs/dev/style.md +++ b/docs/dev/style.md | |||
@@ -435,7 +435,7 @@ Avoid local `use MyEnum::*` imports. | |||
435 | 435 | ||
436 | Prefer `use crate::foo::bar` to `use super::bar`. | 436 | Prefer `use crate::foo::bar` to `use super::bar`. |
437 | 437 | ||
438 | When implementing `Debug` or `Display`, import `std::fmt`: | 438 | When implementing traits from `std::fmt` or `std::ops`, import the module: |
439 | 439 | ||
440 | ```rust | 440 | ```rust |
441 | // Good | 441 | // Good |
@@ -449,6 +449,14 @@ impl fmt::Display for RenameError { | |||
449 | impl std::fmt::Display for RenameError { | 449 | impl std::fmt::Display for RenameError { |
450 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { .. } | 450 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { .. } |
451 | } | 451 | } |
452 | |||
453 | // Not as good | ||
454 | use std::ops::Deref; | ||
455 | |||
456 | impl Deref for Widget { | ||
457 | type Target = str; | ||
458 | fn deref(&self) -> &str { .. } | ||
459 | } | ||
452 | ``` | 460 | ``` |
453 | 461 | ||
454 | ## Order of Items | 462 | ## Order of Items |