diff options
author | Aleksey Kladov <[email protected]> | 2021-01-07 16:27:47 +0000 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2021-01-07 16:27:47 +0000 |
commit | eb710a63ca94409dd410ebde57923bcaf48f2975 (patch) | |
tree | 47e6c76c1c4580bf92bf721d98b19b613cf575a1 /docs | |
parent | b821264f861be959709aa0e7e87b4c5e1ce335b5 (diff) |
Document `std::ops` style
Diffstat (limited to 'docs')
-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 |