Implement some other useful traits on EqOnFirstItem

These aren't immediately used, but they're handy for experimenting
with the similar library which requires these.
try_similar_lib
Wilfred Hughes 2023-08-04 23:29:29 +07:00
parent 892d4fdb58
commit 19cbf1d458
1 changed files with 19 additions and 0 deletions

@ -2,6 +2,7 @@
//! diff on smaller inputs.
use std::collections::HashSet;
use std::hash::Hash;
use crate::diff::changes::{insert_deep_unchanged, ChangeKind, ChangeMap};
use crate::diff::myers_diff;
@ -323,6 +324,24 @@ impl<X: Eq, Y> PartialEq for EqOnFirstItem<X, Y> {
}
impl<X: Eq, Y> Eq for EqOnFirstItem<X, Y> {}
impl<X: Eq + PartialOrd, Y> PartialOrd for EqOnFirstItem<X, Y> {
fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> {
self.0.partial_cmp(&other.0)
}
}
impl<X: Eq + Ord, Y> Ord for EqOnFirstItem<X, Y> {
fn cmp(&self, other: &Self) -> std::cmp::Ordering {
self.0.cmp(&other.0)
}
}
impl<X: Hash, Y> Hash for EqOnFirstItem<X, Y> {
fn hash<H: std::hash::Hasher>(&self, state: &mut H) {
self.0.hash(state);
}
}
fn as_singleton_list_children<'a>(
lhs_nodes: &[&'a Syntax<'a>],
rhs_nodes: &[&'a Syntax<'a>],