Skip to content

Commit

Permalink
Sort trait bounds by fn/trait/region
Browse files Browse the repository at this point in the history
  • Loading branch information
gavinleroy committed Aug 20, 2024
1 parent c61cfb4 commit ceff62c
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions ide/packages/print/src/private/argus.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -125,12 +125,20 @@ export const PrintWhereClause = ({
};

const PrintClauseWithBounds = ({ o }: { o: ClauseWithBounds }) => {
const [traits, lifetimes] = _.partition(o.bounds, bound => "Trait" in bound);
const traitBounds = _.map(traits, bound => <PrintClauseBound o={bound} />);
const lifetimeBounds = _.map(lifetimes, bound => (
// Sort the bounds to be Ty: Fn() + Trait + Region
const sortedBounds = _.sortBy(o.bounds, bound =>
"FnTrait" in bound
? 0
: "Trait" in bound
? 1
: "Region" in bound
? 2
: undefined
);

const boundComponents = _.map(sortedBounds, bound => (
<PrintClauseBound o={bound} />
));
const boundComponents = _.concat(traitBounds, lifetimeBounds);

return (
<>
Expand Down

0 comments on commit ceff62c

Please sign in to comment.