Skip to content

Commit 7789289

Browse files
authored
chore: resolve new clippy warnings (#1040)
1 parent 37c9e12 commit 7789289

4 files changed

Lines changed: 4 additions & 5 deletions

File tree

src/graph/lowest_common_ancestor.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ mod tests {
205205
}
206206
}
207207
let mut offline_answers = offline.answer_queries(1, &tree);
208-
offline_answers.sort_unstable_by(|a1, a2| a1.query_id.cmp(&a2.query_id));
208+
offline_answers.sort_unstable_by_key(|a| a.query_id);
209209
assert_eq!(offline_answers, online_answers);
210210
}
211211
}

src/greedy/job_sequencing.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ pub fn schedule_jobs(mut jobs: Vec<Job>) -> ScheduleResult {
8585
}
8686

8787
// Step 1 – sort jobs by profit, highest first.
88-
jobs.sort_unstable_by(|a, b| b.profit.cmp(&a.profit));
88+
jobs.sort_unstable_by_key(|a| std::cmp::Reverse(a.profit));
8989

9090
// Step 2 – allocate slots.
9191
// At most n jobs can ever be scheduled, so cap the slot count at jobs.len()

src/string/burrows_wheeler_transform.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ pub fn inv_burrows_wheeler_transform<T: AsRef<str>>(input: (T, usize)) -> String
2626
table.push((i, input.0.as_ref().chars().nth(i).unwrap()));
2727
}
2828

29-
table.sort_by(|a, b| a.1.cmp(&b.1));
29+
table.sort_by_key(|a| a.1);
3030

3131
let mut decoded = String::new();
3232
let mut idx = input.1;

src/string/manacher.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,7 @@ pub fn manacher(s: String) -> String {
5454
radius += 1;
5555
// 2: Checking palindrome.
5656
// Need to care about overflow usize.
57-
while i >= radius && i + radius <= chars.len() - 1 && chars[i - radius] == chars[i + radius]
58-
{
57+
while i >= radius && i + radius < chars.len() && chars[i - radius] == chars[i + radius] {
5958
length_of_palindrome[i] += 2;
6059
radius += 1;
6160
}

0 commit comments

Comments
 (0)