Document std::ops style

This commit is contained in:
Aleksey Kladov 2021-01-07 19:27:47 +03:00
parent b821264f86
commit eb710a63ca

View file

@ -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