diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2021-01-07 16:28:43 +0000 |
---|---|---|
committer | GitHub <[email protected]> | 2021-01-07 16:28:43 +0000 |
commit | dce5f0c5859ad538074a4e69cd4365813bf96863 (patch) | |
tree | a3d2d717b048cd99501ee4ba6dec86e8f6d05dd4 /docs/dev | |
parent | 344704a054fe3cf9c54893c2bfa0ec6ebbabf692 (diff) | |
parent | eb710a63ca94409dd410ebde57923bcaf48f2975 (diff) |
Merge #7197
7197: Document `std::ops` style r=matklad a=matklad
bors r+
🤖
Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'docs/dev')
-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 |