The sequence matcher works on strings or vectors or slices of strings.
I have two problems I’d like to solve:
The “items” (i.e., strings or chars) that this works on must support the == operator; but the trait doesn’t seem to specify this. Can this be made specific?
I would like to implement this trait for any “item” type that has len() & at_index() methods & that supports ==. At the moment I have to use a local modified copy to process my custom Item type; I’d rather use a shared version in its own crate.
Is this possible?
PS At the moment I’ve got a local copy of this (& which I’ve changed to use FnvHashMap for speed & have made slightly closer to the Python original from Python’s difflib module).
The difference is mostly philosophical, i.e. whether trait doesn’t make sense without Eq, or whether it is only implemented for Eq currently and someone could make it work without Eq if they really wanted.
Note that you can’t create a blanket implementation for all types that have some method (like in Golang). Rust requires trait implementations to be an explicit opt-in (more like interfaces in Java), but you can implement a trait any type that implements some other trait (so “it has a trait” is an indirect way of saying “it has a method”).