Feature request: reorder_type_constraints
@0xangelo is already working on this.
Since Apr 19, 2022.
- Dominant language
- Rust
- Stars
- 7k
- Forks
- 1.1k
- Avg merge
- 2d 13h
- Merged PRs (30d)
- 24
Description
Requested feature(s):
EDIT: (1) is a duplicate of #4112, which was a duplicate of #1867 - ignore this and focus on #2.
- Use
reorder_derive_itemsto haverustfmtchange:
#[derive(PartialEq, Copy, Display, Clone)]
Into:
#[derive(Clone, Copy, Display, PartialEq)]
That is, alphabetically sort the derived types.
- Use
reorder_type_constraintsto haverustfmtchange:
pub fn<T: PartialEq + Copy + Debug + 'static + Clone>foo(...) { ... }
Into:
pub fn<T: 'static + Clone + Copy + Debug + PartialEq>foo(...) { ... }
That is, alphabetically sort the contsraint types (and sort lifetimes before types).
Motivation:
When there are more than 2-3 types in either derive or a constraint, it is tedius and error-prone to manually ensure they all appear in the same order. However it is useful for them to be in a deterministic order as this makes it easier to read a list, and more importantly to see the difference between two lists.
Options
Perhaps "standard" traits should be sorted before all other traits?
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.