diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ce27de2..687e770 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -11,7 +11,7 @@ jobs: strategy: matrix: toolchain: - - "1.65" + - "1.71" - stable runs-on: ubuntu-latest steps: diff --git a/Cargo.toml b/Cargo.toml index 8140405..4a96d2c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -3,7 +3,7 @@ name = "imara-diff" version = "0.1.7" edition = "2021" authors = ["pascalkuthe "] -rust-version = "1.61" +rust-version = "1.71" license = "Apache-2.0" description = "A high performance library for computing diffs." @@ -20,8 +20,7 @@ maintenance = { status = "actively-developed" } [dependencies] -ahash = "0.8.0" -hashbrown = { version = "0.15", default-features = false, features = ["inline-more"] } +hashbrown = { version = "0.15", default-features = false, features = ["default-hasher", "inline-more"] } [features] default = ["unified_diff"] diff --git a/src/intern.rs b/src/intern.rs index 62349d6..800fdca 100644 --- a/src/intern.rs +++ b/src/intern.rs @@ -1,8 +1,8 @@ -use std::hash::Hash; +use std::hash::{BuildHasher as _, Hash}; use std::ops::Index; -use ahash::RandomState; use hashbrown::hash_table::{Entry, HashTable}; +use hashbrown::DefaultHashBuilder as RandomState; /// A token represented as an interned integer. /// @@ -114,7 +114,7 @@ impl Interner { Interner { tokens: Vec::with_capacity(capacity), table: HashTable::with_capacity(capacity), - hasher: RandomState::new(), + hasher: RandomState::default(), } } diff --git a/src/lib.rs b/src/lib.rs index 19f0f5e..593f59b 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -171,7 +171,7 @@ mod tests; /// `imara-diff` supports multiple different algorithms /// for computing an edit sequence. /// These algorithms have different performance and all produce different output. -#[derive(Debug, PartialEq, Eq, Clone, Copy)] +#[derive(Debug, PartialEq, Eq, Clone, Copy, Default)] pub enum Algorithm { /// A variation of the [`patience` diff algorithm described by Bram Cohen's blog post](https://bramcohen.livejournal.com/73318.html) /// that uses a histogram to find the least common LCS. @@ -199,6 +199,7 @@ pub enum Algorithm { /// fallback to Myers algorithm. However this detection has a nontrivial overhead, so /// if its known upfront that the sort of tokens is very small `Myers` algorithm should /// be used instead. + #[default] Histogram, /// An implementation of the linear space variant of /// [Myers `O((N+M)D)` algorithm](http://www.xmailserver.org/diff2.pdf). @@ -230,12 +231,6 @@ impl Algorithm { const ALL: [Self; 2] = [Algorithm::Histogram, Algorithm::Myers]; } -impl Default for Algorithm { - fn default() -> Self { - Algorithm::Histogram - } -} - /// Computes an edit-script that transforms `input.before` into `input.after` using /// the specified `algorithm` /// The edit-script is passed to `sink.process_change` while it is produced. diff --git a/src/myers/middle_snake.rs b/src/myers/middle_snake.rs index 9a33554..4b2ba1d 100644 --- a/src/myers/middle_snake.rs +++ b/src/myers/middle_snake.rs @@ -245,7 +245,7 @@ impl MiddleSnakeSearch { k -= 2; } - (best_score > 0).then(|| (best_token_idx1, best_token_idx2)) + (best_score > 0).then_some((best_token_idx1, best_token_idx2)) } }