SubsliceExt

Trait SubsliceExt 

Source
pub trait SubsliceExt: Sealed {
    // Required methods
    fn find(&self, other: &Self) -> Option<usize>;
    fn rfind(&self, other: &Self) -> Option<usize>;
}
Expand description

Trait of types which can be searched for subsequences

Required Methods§

Source

fn find(&self, other: &Self) -> Option<usize>

Find the first subslice of self which is equal to other, and return the index of its start.

O(self.len() + other.len()) time

Source

fn rfind(&self, other: &Self) -> Option<usize>

Find the last subslice of self which is equal to other, and return the index of its start.

O(self.len() + other.len()) time

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl SubsliceExt for str

Source§

fn find(&self, other: &Self) -> Option<usize>

Source§

fn rfind(&self, other: &Self) -> Option<usize>

Source§

impl<A: Ord> SubsliceExt for [A]

Source§

fn find(&self, other: &Self) -> Option<usize>

Source§

fn rfind(&self, other: &Self) -> Option<usize>

Implementors§