[go: up one dir, main page]

Trait SliceFind

Source
pub trait SliceFind {
    type Item;

    // Required methods
    fn find<U: ?Sized>(&self, elt: &U) -> Option<usize>
       where Self::Item: PartialEq<U>;
    fn rfind<U: ?Sized>(&self, elt: &U) -> Option<usize>
       where Self::Item: PartialEq<U>;
}
Expand description

Element-finding methods for slices

Required Associated Types§

Required Methods§

Source

fn find<U: ?Sized>(&self, elt: &U) -> Option<usize>
where Self::Item: PartialEq<U>,

Linear search for the first occurrence elt in the slice.

Return its index if it is found, or None.

Source

fn rfind<U: ?Sized>(&self, elt: &U) -> Option<usize>
where Self::Item: PartialEq<U>,

Linear search for the last occurrence elt in the slice.

Return its index if it is found, or None.

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<T> SliceFind for [T]

Source§

type Item = T

Source§

fn find<U: ?Sized>(&self, elt: &U) -> Option<usize>
where Self::Item: PartialEq<U>,

Source§

fn rfind<U: ?Sized>(&self, elt: &U) -> Option<usize>
where Self::Item: PartialEq<U>,

Implementors§

Source§

impl<T> SliceFind for RevSlice<T>

Source§

type Item = T