Merge #7197
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:
commit
dce5f0c585
@ -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
|
||||||
|
Loading…
Reference in New Issue
Block a user