str_overlap

GitHub Workflow Status codecov.io Crates.io Docs.rs MSRV License

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.

Usage

To use this crate, call the provided overlap function with two string slices in the left and right positions.

```rust use str_overlap::overlap;

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

Note that the positions of the string slices matter. The overlap found is the largest substring at both the end of the left string slice and the beginning of the right string slice.

Performance

The overlap function has temporal complexity O(n) in the worst case (where no overlap is found), where n is the length of the first string parameter.

Minimum Supported Rust Version

This crate is guaranteed to compile on stable rustc 1.0.0 and up.

License

This project is licensed under either of

at your option.