aboutsummaryrefslogtreecommitdiff
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 <[email protected]>2021-01-07 16:28:43 +0000
commitdce5f0c5859ad538074a4e69cd4365813bf96863 (patch)
treea3d2d717b048cd99501ee4ba6dec86e8f6d05dd4 /docs/dev
parent344704a054fe3cf9c54893c2bfa0ec6ebbabf692 (diff)
parenteb710a63ca94409dd410ebde57923bcaf48f2975 (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.md10
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
436Prefer `use crate::foo::bar` to `use super::bar`. 436Prefer `use crate::foo::bar` to `use super::bar`.
437 437
438When implementing `Debug` or `Display`, import `std::fmt`: 438When 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 {
449impl std::fmt::Display for RenameError { 449impl 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
454use std::ops::Deref;
455
456impl 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