rust-lang/rust-clippy
Voir sur GitHubNew lint: Use `Into`/`TryInto` in bounds as opposed to `From`/`TryFrom`
Open
#4 894 ouverte le 10 déc. 2019
A-lintL-stylegood first issue
Métriques du dépôt
- Stars
- (10 406 stars)
- Métriques de merge PR
- (Merge moyen 19j 22h) (113 PRs mergées en 30 j)
Description
When writing generic bounds such as:
fn foo<T>(a: T) where u32: From<T>;
Into should be preferred, like this:
fn foo<T>(a: T) where T: Into<u32>;
Why the former is bad: Into is a superset of From. In some cases coherence rules prevent implementing From but do allow implementing Into. As a result Into is more generic bound than From.
Category: Style, I guess?