Trait array_tool::vec::Uniq [] [src]

pub trait Uniq {
    fn uniq(&self, other: Self) -> Self;
    fn unique(&self) -> Self;
    fn is_unique(&self) -> bool;
}

Several different methods for getting, or evaluating, uniqueness.

Required Methods

uniq returns a vector of unique values within itself as compared to the other vector which is provided as an input parameter.

Example

use array_tool::vec::Uniq;

vec![1,2,3,4,5,6].uniq( vec![1,2,5,7,9] );

Output

vec![3,4,6]

unique removes duplicates from within the vector and returns Self.

Example

use array_tool::vec::Uniq;

vec![1,2,1,3,2,3,4,5,6].unique();

Output

vec![1,2,3,4,5,6]

is_unique returns boolean value on whether all values within Self are unique.

Example

use array_tool::vec::Uniq;

vec![1,2,1,3,4,3,4,5,6].is_unique();

Output

false

Implementors