[][src]Crate str_overlap

This crate provides a utility function for finding the overlap between two string slices.

The overlap is here defined as the largest substring contained both at the end of the first string slice and the beginning of the second string slice.

Example Usage

use string_overlap::overlap;

assert_eq!(overlap("abc", "bcd"), "bc");

The overlap is not evaluated on both sides of the strings to reduce complexity and maintain clarity on where the overlapping substring is in relation to the input strings. If evaluation of overlap is desired on both sides, both can be requested by calling the function twice:

use string_overlap::overlap;

let s1 = "abcd";
let s2 = "cdab";

assert_eq!(overlap(s1, s2), "cd");
assert_eq!(overlap(s2, s1), "ab");

Functions

overlap

Finds the overlap between two string slices.