7519: add useless types to the styleguide r=matklad a=matklad

bors r+

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
This commit is contained in:
bors[bot] 2021-02-02 13:09:21 +00:00 committed by GitHub
commit 96f9f0741f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -267,6 +267,20 @@ Non-local code properties degrade under change, privacy makes invariant local.
Borrowed own data discloses irrelevant details about origin of data.
Irrelevant (neither right nor wrong) things obscure correctness.
## Useless Types
More generally, always prefer types on the left
```rust
// GOOD BAD
&[T] &Vec<T>
&str &String
Option<&T> &Option<T>
```
**Rationale:** types on the left are strictly more general.
Even when generality is not required, consistency is important.
## Constructors
Prefer `Default` to zero-argument `new` function