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

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

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

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