Trait str_overlap::Overlap[][src]

pub trait Overlap {
    fn overlap_start(&self, other: &Self) -> &Self;
fn overlap_end(&self, other: &Self) -> &Self; }

Provides methods for finding overlaps between values.

This trait provides methods for finding overlaps at both the start and end of self. This allows for returning overlapping values that are owned by self, regardless of which side of self the overlap is occurring.

This trait is made available by pulling it into scope:

use str_overlap::Overlap;

Overlap is implemented on str, which means its methods are usable by str and any types which implement Deref<Target = str>, such as String.

Required methods

fn overlap_start(&self, other: &Self) -> &Self[src]

Returns the overlap found at the start of self and the end of other.

Example

This method can be used through its implementation on str, like so:

use str_overlap::Overlap;

assert_eq!("bcd".overlap_start("abc"), "bc");

fn overlap_end(&self, other: &Self) -> &Self[src]

Returns the overlap found at the end of self and the start of other.

Example

This method can be used through its implementation on str, like so:

use str_overlap::Overlap;

assert_eq!("abc".overlap_end("bcd"), "bc");
Loading content...

Implementors

impl Overlap for str[src]

Overlap methods for string slices.

This allows for the returned string slice to be a subset of either string slice from which an overlap is obtained.

#[must_use]fn overlap_start(&self, other: &Self) -> &Self[src]

Returns the substring which is both the prefix to self and the suffix to other.

The returned string slice is a reference to the substring contained in self.

Example

use str_overlap::Overlap;

assert_eq!("bcd".overlap_start("abc"), "bc");

#[must_use]fn overlap_end(&self, other: &Self) -> &Self[src]

Returns the substring which is both the suffix to self and the prefix to other.

The returned string slice is a reference to the substring contained in self.

Example

use str_overlap::Overlap;

assert_eq!("abc".overlap_end("bcd"), "bc");
Loading content...