Remove little-used itertools dependency

pull/826/head
Wilfred Hughes 2025-03-21 00:11:44 +07:00
parent c824f601df
commit 6e1ec52bdc
4 changed files with 23 additions and 36 deletions

12
Cargo.lock generated

@ -252,7 +252,6 @@ dependencies = [
"hashbrown",
"humansize",
"ignore",
"itertools 0.11.0",
"lazy_static",
"libc",
"libmimalloc-sys",
@ -492,15 +491,6 @@ dependencies = [
"either",
]
[[package]]
name = "itertools"
version = "0.11.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b1c173a5686ce8bfa551b3563d0c2170bf24ca44da99c7ca4bfdab5418c3fe57"
dependencies = [
"either",
]
[[package]]
name = "itoa"
version = "1.0.10"
@ -673,7 +663,7 @@ checksum = "59230a63c37f3e18569bdb90e4a89cbf5bf8b06fea0b84e65ea10cc4df47addd"
dependencies = [
"difflib",
"float-cmp",
"itertools 0.10.5",
"itertools",
"normalize-line-endings",
"predicates-core",
"regex",

@ -36,7 +36,6 @@ pkg-fmt = "zip"
[dependencies]
regex = "1.10.4"
clap = { version = "4.0.0", features = ["cargo", "env", "wrap_help", "string"] }
itertools = "0.11.0"
typed-arena = "2.0.2"
rustc-hash = "2.0.0"
strsim = "0.10.0"

@ -4,7 +4,6 @@
use std::{cmp::Reverse, env};
use bumpalo::Bump;
use itertools::Itertools;
use radix_heap::RadixHeapMap;
use crate::{
@ -240,7 +239,7 @@ pub(crate) fn mark_syntax<'a>(
)
})
.take(print_length)
.collect_vec()
.collect::<Vec<_>>()
);
populate_change_map(&route, change_map);
@ -249,7 +248,6 @@ pub(crate) fn mark_syntax<'a>(
#[cfg(test)]
mod tests {
use itertools::Itertools;
use line_numbers::SingleLineSpan;
use typed_arena::Arena;
@ -282,7 +280,7 @@ mod tests {
let vertex_arena = Bump::new();
let route = shortest_path(start, &vertex_arena, 0, DEFAULT_GRAPH_LIMIT).unwrap();
let actions = route.iter().map(|(action, _)| *action).collect_vec();
let actions = route.iter().map(|(action, _)| *action).collect::<Vec<_>>();
assert_eq!(
actions,
vec![UnchangedNode {
@ -324,7 +322,7 @@ mod tests {
let vertex_arena = Bump::new();
let route = shortest_path(start, &vertex_arena, 0, DEFAULT_GRAPH_LIMIT).unwrap();
let actions = route.iter().map(|(action, _)| *action).collect_vec();
let actions = route.iter().map(|(action, _)| *action).collect::<Vec<_>>();
assert_eq!(
actions,
vec![
@ -366,7 +364,7 @@ mod tests {
let vertex_arena = Bump::new();
let route = shortest_path(start, &vertex_arena, 0, DEFAULT_GRAPH_LIMIT).unwrap();
let actions = route.iter().map(|(action, _)| *action).collect_vec();
let actions = route.iter().map(|(action, _)| *action).collect::<Vec<_>>();
assert_eq!(
actions,
vec![
@ -412,7 +410,7 @@ mod tests {
let vertex_arena = Bump::new();
let route = shortest_path(start, &vertex_arena, 0, DEFAULT_GRAPH_LIMIT).unwrap();
let actions = route.iter().map(|(action, _)| *action).collect_vec();
let actions = route.iter().map(|(action, _)| *action).collect::<Vec<_>>();
assert_eq!(
actions,
vec![
@ -453,7 +451,7 @@ mod tests {
let vertex_arena = Bump::new();
let route = shortest_path(start, &vertex_arena, 0, DEFAULT_GRAPH_LIMIT).unwrap();
let actions = route.iter().map(|(action, _)| *action).collect_vec();
let actions = route.iter().map(|(action, _)| *action).collect::<Vec<_>>();
assert_eq!(
actions,
vec![ReplacedComment {
@ -485,7 +483,7 @@ mod tests {
let vertex_arena = Bump::new();
let route = shortest_path(start, &vertex_arena, 0, DEFAULT_GRAPH_LIMIT).unwrap();
let actions = route.iter().map(|(action, _)| *action).collect_vec();
let actions = route.iter().map(|(action, _)| *action).collect::<Vec<_>>();
assert_eq!(
actions,
vec![ReplacedComment {
@ -525,7 +523,7 @@ mod tests {
let vertex_arena = Bump::new();
let route = shortest_path(start, &vertex_arena, 0, DEFAULT_GRAPH_LIMIT).unwrap();
let actions = route.iter().map(|(action, _)| *action).collect_vec();
let actions = route.iter().map(|(action, _)| *action).collect::<Vec<_>>();
assert_eq!(
actions,
vec![

@ -9,7 +9,6 @@ use std::{
use clap::{crate_authors, crate_description, value_parser, Arg, ArgAction, Command};
use crossterm::tty::IsTty;
use itertools::Itertools;
use crate::{
display::style::BackgroundColor,
@ -612,19 +611,20 @@ fn parse_overrides_or_die(raw_overrides: &[String]) -> Vec<(LanguageOverride, Ve
std::process::exit(EXIT_BAD_ARGUMENTS);
}
overrides
.into_iter()
.coalesce(
|(prev_lang, mut prev_globs), (current_lang, current_globs)| {
if prev_lang == current_lang {
prev_globs.extend(current_globs);
Ok((prev_lang, prev_globs))
} else {
Err(((prev_lang, prev_globs), (current_lang, current_globs)))
}
},
)
.collect()
let mut combined_overrides: Vec<(LanguageOverride, Vec<glob::Pattern>)> = vec![];
for (lang, globs) in overrides {
if let Some((prev_lang, prev_globs)) = combined_overrides.last_mut() {
if *prev_lang == lang {
prev_globs.extend(globs);
} else {
combined_overrides.push((lang, globs));
}
} else {
combined_overrides.push((lang, globs));
}
}
combined_overrides
}
/// Parse CLI arguments passed to the binary.