about summary refs log tree commit diff
path: root/docs/dev
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2021-01-07 16:28:43 +0000
committerGitHub <noreply@github.com>2021-01-07 16:28:43 +0000
commitdce5f0c5859ad538074a4e69cd4365813bf96863 (patch)
treea3d2d717b048cd99501ee4ba6dec86e8f6d05dd4 /docs/dev
parent344704a054fe3cf9c54893c2bfa0ec6ebbabf692 (diff)
parenteb710a63ca94409dd410ebde57923bcaf48f2975 (diff)
downloadrust-dce5f0c5859ad538074a4e69cd4365813bf96863.tar.gz
rust-dce5f0c5859ad538074a4e69cd4365813bf96863.zip
Merge #7197
7197: Document `std::ops` style r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
Diffstat (limited to 'docs/dev')
-rw-r--r--docs/dev/style.md10
1 files changed, 9 insertions, 1 deletions
diff --git a/docs/dev/style.md b/docs/dev/style.md
index d91a9108e1a..be2c7784730 100644
--- a/docs/dev/style.md
+++ b/docs/dev/style.md
@@ -435,7 +435,7 @@ Avoid local `use MyEnum::*` imports.
 
 Prefer `use crate::foo::bar` to `use super::bar`.
 
-When implementing `Debug` or `Display`, import `std::fmt`:
+When implementing traits from `std::fmt` or `std::ops`, import the module:
 
 ```rust
 // Good
@@ -449,6 +449,14 @@ impl fmt::Display for RenameError {
 impl std::fmt::Display for RenameError {
     fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { .. }
 }
+
+// Not as good
+use std::ops::Deref;
+
+impl Deref for Widget {
+    type Target = str;
+    fn deref(&self) -> &str { .. }
+}
 ```
 
 ## Order of Items