array_tool ::vec Trait Uniq Copy item path Source pub trait Uniq<T> {
// Required methods
fn uniq (&self, other: Self) -> Self;
fn unique (&self) -> Self;
fn is_unique (&self) -> bool ;
fn uniq_via <F: Fn (&T , &T ) -> bool >(&self, other: Self, f: F) -> Self;
fn unique_via <F: Fn (&T , &T ) -> bool >(&self, f: F) -> Self;
fn is_unique_via <F: Fn (&T , &T ) -> bool >(&self, f: F) -> bool ;
}
Expand description Several different methods for getting, or evaluating, uniqueness.
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 ] );
§ Outputunique
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();
§ Outputis_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();
§ Outputuniq_via
returns a vector of unique values within itself as compared to
the other vector which is provided as an input parameter, as defined by a
provided custom comparator.
§ Example
use array_tool::vec::Uniq;
vec! [1 ,2 ,3 ,4 ,5 ,6 ].uniq_via( vec! [1 ,2 ,5 ,7 ,9 ], |& l, r| l == r + 2 );
§ Outputunique_via
removes duplicates, as defined by a provided custom comparator,
from within the vector and returns Self.
§ Example
use array_tool::vec::Uniq;
vec! [1.0 ,2.0 ,1.4 ,3.3 ,2.1 ,3.5 ,4.6 ,5.2 ,6.2 ].unique_via( |l: & f64, r: & f64| l.floor() == r.floor() );
§ Outputvec![1.0,2.0,3.3,4.6,5.2,6.2]
is_unique_via
returns boolean value on whether all values within
Self are unique, as defined by a provided custom comparator.
§ Example
use array_tool::vec::Uniq;
vec! [1.0 ,2.0 ,1.4 ,3.3 ,2.1 ,3.5 ,4.6 ,5.2 ,6.2 ].is_unique_via( |l: & f64, r: & f64| l.floor() == r.floor() );
§ OutputThis trait is not dyn compatible .
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.