pub fn longest_common_substring(a: &[u8], b: &[u8]) -> SeqResult<(usize, usize)>Expand description
Longest common substring of a and b.
Builds the suffix automaton of a and streams b through it, tracking the
length of the current match and resetting via suffix links on a mismatch.
Runs in O(|a| + |b|) after the O(|a|) construction. Returns the
(start_in_b, length) of a longest common substring; on ties the match
ending earliest in b is returned. A length of 0 means the two strings
share no character.
ยงErrors
Returns SeqError::EmptyInput if either input is empty, since the
longest common substring is then trivially empty and start is undefined.
Callers that prefer to treat that as length 0 can check emptiness first.