Trait AsDedupVec

Source
pub trait AsDedupVec {
    type Item;
    type Container;

    // Required methods
    fn new() -> Self;
    fn len(&self) -> usize;
    fn contains(&self, value: &Self::Item) -> bool;
    fn push(&mut self, value: Self::Item);
    fn remove(&mut self, value: &Self::Item) -> Option<Self::Item>;
    fn extend(&mut self, iter: impl IntoIterator<Item = Self::Item>);
    fn iter(&self) -> impl Iterator<Item = &Self::Item>;

    // Provided method
    fn is_empty(&self) -> bool { ... }
}
Expand description

A trait for DedupVec.

This trait provides common interfaces for DedupVec.

Required Associated Types§

Source

type Item

Vector item type.

Source

type Container

Vector type.

Required Methods§

Source

fn new() -> Self

Creates a new empty vector.

Source

fn len(&self) -> usize

Returns number of items.

Source

fn contains(&self, value: &Self::Item) -> bool

Returns true if the vector contains the given value.

Source

fn push(&mut self, value: Self::Item)

Appends the given value to the end of the vector.

Source

fn remove(&mut self, value: &Self::Item) -> Option<Self::Item>

Removes an item that is equal to the given value from the vector.

Source

fn extend(&mut self, iter: impl IntoIterator<Item = Self::Item>)

Extends the vector with the given iterator.

Source

fn iter(&self) -> impl Iterator<Item = &Self::Item>

Returns an iterator visiting all items in the vector.

Provided Methods§

Source

fn is_empty(&self) -> bool

Returns true if the vector is empty.

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.

Implementors§

Source§

impl<T> AsDedupVec for DedupVec<T, false>
where T: Hash + Eq + Default + Clone,

Source§

impl<T> AsDedupVec for DedupVec<T, true>
where T: Ord,