7197: Document `std::ops` style r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
This commit is contained in:
bors[bot] 2021-01-07 16:28:43 +00:00 committed by GitHub
commit dce5f0c585
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -435,7 +435,7 @@ Avoid local `use MyEnum::*` imports.
Prefer `use crate::foo::bar` to `use super::bar`. 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 ```rust
// Good // Good
@ -449,6 +449,14 @@ impl fmt::Display for RenameError {
impl std::fmt::Display for RenameError { impl std::fmt::Display for RenameError {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { .. } 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 ## Order of Items