Struct memchr::arch::all::rabinkarp::FinderRev

source ·
pub struct FinderRev(Finder);
Expand description

A reverse substring searcher using the Rabin-Karp algorithm.

Tuple Fields§

§0: Finder

Implementations§

source§

impl FinderRev

source

pub fn new(needle: &[u8]) -> FinderRev

Create a new Rabin-Karp reverse searcher for the given needle.

source

pub fn rfind(&self, haystack: &[u8], needle: &[u8]) -> Option<usize>

Return the last occurrence of the needle in the haystack given. If no such occurrence exists, then None is returned.

The needle provided must match the needle given to this finder at construction time.

The maximum value this can return is haystack.len(), which can only occur when the needle and haystack both have length zero. Otherwise, for non-empty haystacks, the maximum value is haystack.len() - 1.

source

pub unsafe fn rfind_raw( &self, hstart: *const u8, hend: *const u8, nstart: *const u8, nend: *const u8, ) -> Option<*const u8>

Like rfind, but accepts and returns raw pointers.

When a match is found, the pointer returned is guaranteed to be >= start and <= end. The pointer returned is only ever equivalent to end when both the needle and haystack are empty. (That is, the empty string matches the empty string.)

This routine is useful if you’re already using raw pointers and would like to avoid converting back to a slice before executing a search.

§Safety

Note that start and end below refer to both pairs of pointers given to this routine. That is, the conditions apply to both hstart/hend and nstart/nend.

  • Both start and end must be valid for reads.
  • Both start and end must point to an initialized value.
  • Both start and end must point to the same allocated object and must either be in bounds or at most one byte past the end of the allocated object.
  • Both start and end must be derived from a pointer to the same object.
  • The distance between start and end must not overflow isize.
  • The distance being in bounds must not rely on “wrapping around” the address space.
  • It must be the case that start <= end.

Trait Implementations§

source§

impl Clone for FinderRev

source§

fn clone(&self) -> FinderRev

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for FinderRev

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> CloneToUninit for T
where T: Clone,

source§

unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for T
where T: Clone,

source§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

source§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.