fix(installer): satisfy clippy's unnecessary_sort_by on the CI toolchain
All checks were successful
PR Checks / rust-gates (pull_request) Successful in 58s
All checks were successful
PR Checks / rust-gates (pull_request) Successful in 58s
The two descending sorts in the applier used an explicit comparator. CI runs clippy 1.97, where `unnecessary_sort_by` flags that and `-D warnings` turns it into a build failure; the local toolchain here is 1.94, which does not have the lint. `sort_by_key` with `Reverse` says the same thing. Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -259,7 +259,7 @@ pub fn resolve(file: &FilePatch, content: &[u8]) -> Resolution {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Highest offset first, so applying one edit never invalidates the next one's range.
|
// Highest offset first, so applying one edit never invalidates the next one's range.
|
||||||
edits.sort_by(|a, b| b.start.cmp(&a.start));
|
edits.sort_by_key(|e| std::cmp::Reverse(e.start));
|
||||||
Resolution::Applicable {
|
Resolution::Applicable {
|
||||||
rung: if stock {
|
rung: if stock {
|
||||||
Rung::StockHash
|
Rung::StockHash
|
||||||
@@ -369,7 +369,7 @@ pub fn apply(content: &[u8], edits: &[Edit]) -> Vec<u8> {
|
|||||||
// The edits arrive highest-offset-first from `resolve`, so each splice leaves every remaining
|
// The edits arrive highest-offset-first from `resolve`, so each splice leaves every remaining
|
||||||
// range valid. Re-sorting here rather than trusting the caller keeps that a local property.
|
// range valid. Re-sorting here rather than trusting the caller keeps that a local property.
|
||||||
let mut ordered: Vec<&Edit> = edits.iter().collect();
|
let mut ordered: Vec<&Edit> = edits.iter().collect();
|
||||||
ordered.sort_by(|a, b| b.start.cmp(&a.start));
|
ordered.sort_by_key(|e| std::cmp::Reverse(e.start));
|
||||||
for edit in ordered {
|
for edit in ordered {
|
||||||
out.splice(edit.start..edit.end, edit.replacement.iter().copied());
|
out.splice(edit.start..edit.end, edit.replacement.iter().copied());
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user