pub trait AttributeSet: Sized + Default {
type Item: PartialEq + Copy + Attributes;
const MAX_COUNT: usize;
const NONE: Self;
Show 27 methods
// Required methods
fn insert(&mut self, item: Self::Item) -> bool;
fn try_insert(&mut self, item: Self::Item) -> Result<(), InsertError>;
fn insert_or_replace_last(&mut self, item: Self::Item) -> bool;
fn remove(&mut self, item: &Self::Item) -> bool;
fn take(&mut self, item: &Self::Item) -> Option<Self::Item>;
fn replace(&mut self, item: &Self::Item, new_item: Self::Item) -> bool;
fn clear(&mut self);
fn iter_attributes(&self) -> impl Iterator<Item = ItemAttribute>;
fn as_slice(&self) -> &[Option<Self::Item>];
fn as_mut_slice(&mut self) -> &mut [Option<Self::Item>];
// Provided methods
fn get(&self, index: usize) -> Option<&Self::Item> { ... }
fn len(&self) -> usize { ... }
fn contains(&self, item: &Self::Item) -> bool { ... }
fn is_empty(&self) -> bool { ... }
fn is_full(&self) -> bool { ... }
fn capacity(&self) -> usize { ... }
fn first(&self) -> Option<&Self::Item> { ... }
fn last(&self) -> Option<&Self::Item> { ... }
fn difference(&self, other: &Self) -> Self { ... }
fn intersection(&self, other: &Self) -> Self { ... }
fn is_disjoint(&self, other: &Self) -> bool { ... }
fn is_subset(&self, other: &Self) -> bool { ... }
fn is_superset(&self, other: &Self) -> bool { ... }
fn iter(&self) -> impl Iterator<Item = &Self::Item> { ... }
fn iter_mut(&mut self) -> impl Iterator<Item = &mut Self::Item> { ... }
fn retain<F>(&mut self, f: F)
where F: FnMut(&Self::Item) -> bool { ... }
fn extend<I: IntoIterator<Item = Self::Item>>(&mut self, iter: I) { ... }
}
Expand description
A fixed set of attributes.
Required Associated Constants§
Required Associated Types§
Sourcetype Item: PartialEq + Copy + Attributes
type Item: PartialEq + Copy + Attributes
The item type.
Required Methods§
Sourcefn insert(&mut self, item: Self::Item) -> bool
fn insert(&mut self, item: Self::Item) -> bool
Adds an item to the first available slot. Returns false
if the set is full or already
contains the value.
Sourcefn try_insert(&mut self, item: Self::Item) -> Result<(), InsertError>
fn try_insert(&mut self, item: Self::Item) -> Result<(), InsertError>
Same as insert
, but returns a std::result::Result
with descriptive error to identify
why the insert failed.
Sourcefn insert_or_replace_last(&mut self, item: Self::Item) -> bool
fn insert_or_replace_last(&mut self, item: Self::Item) -> bool
Adds an item to the first available slot. Replaces the last item in the set if the set is
full. Returns false
if the set already contains the value.
Sourcefn remove(&mut self, item: &Self::Item) -> bool
fn remove(&mut self, item: &Self::Item) -> bool
Removes an item from the set. Returns whether the value was present in the set.
Sourcefn take(&mut self, item: &Self::Item) -> Option<Self::Item>
fn take(&mut self, item: &Self::Item) -> Option<Self::Item>
Removes and returns the item in the set, if any, that is equal to the given one.
Sourcefn replace(&mut self, item: &Self::Item, new_item: Self::Item) -> bool
fn replace(&mut self, item: &Self::Item, new_item: Self::Item) -> bool
Replaces an item in the set with a new item. false
if the item was not present.
Sourcefn iter_attributes(&self) -> impl Iterator<Item = ItemAttribute>
fn iter_attributes(&self) -> impl Iterator<Item = ItemAttribute>
Converts each element to an ItemAttribute
.
Sourcefn as_mut_slice(&mut self) -> &mut [Option<Self::Item>]
fn as_mut_slice(&mut self) -> &mut [Option<Self::Item>]
Returns the inner storage as a mutable slice.
Provided Methods§
Sourcefn is_full(&self) -> bool
fn is_full(&self) -> bool
Returns true if the set is full, i.e., it contains the maximum number of elements.
Sourcefn difference(&self, other: &Self) -> Self
fn difference(&self, other: &Self) -> Self
Returns the items that are in self
but not in other
.
Sourcefn intersection(&self, other: &Self) -> Self
fn intersection(&self, other: &Self) -> Self
Returns the items that are both in self
and other
.
Sourcefn is_disjoint(&self, other: &Self) -> bool
fn is_disjoint(&self, other: &Self) -> bool
Returns true
if self
has no items in common with other
. This is equivalent to
checking for an empty intersection.
Sourcefn is_subset(&self, other: &Self) -> bool
fn is_subset(&self, other: &Self) -> bool
Returns true if the set is a subset of another, i.e., other contains at least all the values in self.
Sourcefn is_superset(&self, other: &Self) -> bool
fn is_superset(&self, other: &Self) -> bool
Returns true if the set is a superset of another, i.e., self contains at least all the values in other.
Sourcefn iter_mut(&mut self) -> impl Iterator<Item = &mut Self::Item>
fn iter_mut(&mut self) -> impl Iterator<Item = &mut Self::Item>
Returns a mutable iterator over the set.
Sourcefn extend<I: IntoIterator<Item = Self::Item>>(&mut self, iter: I)
fn extend<I: IntoIterator<Item = Self::Item>>(&mut self, iter: I)
Extends items from an iterator into the set.
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.