pub struct SharedTagSet(/* private fields */);
Expand description
A shared, read-only set of tags.
§Structural sharing
In many cases, it is useful to extend a set of tags with additional tags, without needing to clone the additional
tags or re-allocate the underlying storage to fit the entire set of tags. SharedTagSet
supports this by utilizing
“structural sharing”, where SharedTagSet
is internally represented by a set of smart pointers to TagSet
.
This allows SharedTagSet
to be cheaply extended with additional SharedTagSet
instances, without needing to
allocate enough underlying storage to hold all of the individual tags. Extending a SharedTagSet
will allocate a
small amount of memory (8 bytes) for each additional SharedTagSet
that is chained after the first additional one:
this means that all new SharedTagSet
instances can be extended once with no allocations whatsoever.
Implementations§
Sourcepub fn has_tag<T>(&self, tag: T) -> bool
pub fn has_tag<T>(&self, tag: T) -> bool
Returns true
if the given tag is contained in the set.
This matches the complete tag, rather than just the name.
Sourcepub fn get_single_tag<T>(&self, tag_name: T) -> Option<&Tag>
pub fn get_single_tag<T>(&self, tag_name: T) -> Option<&Tag>
Gets a single tag, by name, from the set.
If multiple tags are present with the same name, the first tag with a matching name will be returned. If no tag
in the set matches, None
is returned.
Extends self
with the tags from the other
.
If any of the individual TagSet
instances in other
are already present in self
, they will not be added
again. This method does not avoid duplicates across different SharedTagSet
instances, so if the same tag is
present in both self
and other
, it will be present when querying the resulting SharedTagSet
.
Sourcepub fn as_tag_sets(&self) -> &[Arc<TagSet>]
pub fn as_tag_sets(&self) -> &[Arc<TagSet>]
Returns a reference to the underlying TagSet
instances.
Sourcepub fn size_of(&self) -> usize
pub fn size_of(&self) -> usize
Returns the size of the tag set, in bytes.
This includes the size of the vector holding any chained tagsets as well as each individual tag.
Additionally, the value returned by this method does not compensate for externalities such as whether or not tags are are inlined, interned, or heap allocated. This means that the value returned is essentially the worst-case usage, and should be used as a rough estimate.
Trait Implementations§
Source§fn clone(&self) -> SharedTagSet
fn clone(&self) -> SharedTagSet
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§fn default() -> SharedTagSet
fn default() -> SharedTagSet
Auto Trait Implementations§
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
§impl<T> Track for T
impl<T> Track for T
§fn track_allocations(self, token: AllocationGroupToken) -> Tracked<Self>
fn track_allocations(self, token: AllocationGroupToken) -> Tracked<Self>
Tracked
wrapper. Read more§fn in_current_allocation_group(self) -> Tracked<Self>
fn in_current_allocation_group(self) -> Tracked<Self>
Tracked
wrapper. Read more