mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-26 04:53:34 +00:00
Document std::ops
style
This commit is contained in:
parent
b821264f86
commit
eb710a63ca
1 changed files with 9 additions and 1 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue