array_tool::vec

Trait Intersect

Source
pub trait Intersect<T> {
    // Required methods
    fn intersect(&self, _: Self) -> Self;
    fn intersect_if<F: Fn(&T, &T) -> bool>(&self, _: Self, validator: F) -> Self;
}
Expand description

Set Intersection — Returns a new array containing elements common to the two arrays, excluding any duplicates. The order is preserved from the original array.

Required Methods§

Source

fn intersect(&self, _: Self) -> Self

§Example
use array_tool::vec::Intersect;

vec![1,1,3,5].intersect(vec![1,2,3]);
§Output
vec![1,3]
Source

fn intersect_if<F: Fn(&T, &T) -> bool>(&self, _: Self, validator: F) -> Self

§Example
use array_tool::vec::Intersect;

vec!['a','a','c','e'].intersect_if(vec!['A','B','C'], |l, r| l.eq_ignore_ascii_case(r));
§Output
vec!['a','c']

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: PartialEq + Clone> Intersect<T> for Vec<T>

Source§

fn intersect(&self, other: Vec<T>) -> Vec<T>

Source§

fn intersect_if<F: Fn(&T, &T) -> bool>(&self, other: Self, validator: F) -> Self

Implementors§