pub struct VmSet { /* private fields */ }Expand description
Backing store for VmValue::Set.
A Harn set is an ordered collection that deduplicates by structural
equality. Membership used to be answered by rebuilding a
HashSet<String> of structural hash keys from the backing Vec on every
contains / union / intersect / … call — O(n) work (plus an
allocation) per query. VmSet keeps that index resident alongside the
items, so membership is O(1) and the set-algebra builtins drop from
rebuild-per-call to a single key computation per probe.
Invariants:
keysholds exactly one entry per item:value_structural_hash_key(item).- Insertion order is preserved in
items(iteration, display, and serialization are order-stable); equality and hashing stay order-independent, matching the language spec.
Implementations§
Source§impl VmSet
impl VmSet
pub fn new() -> Self
pub fn with_capacity(capacity: usize) -> Self
Sourcepub fn insert(&mut self, value: VmValue) -> bool
pub fn insert(&mut self, value: VmValue) -> bool
Insert value, returning true when it was newly added (its structural
key was not already present).
Sourcepub fn remove(&mut self, value: &VmValue) -> bool
pub fn remove(&mut self, value: &VmValue) -> bool
Remove value if present, returning true when it was removed.
pub fn len(&self) -> usize
pub fn is_empty(&self) -> bool
pub fn iter(&self) -> Iter<'_, VmValue>
pub fn items(&self) -> &[VmValue]
The shared backing buffer, for iterators that walk a set without copying its elements (a refcount bump rather than an O(n) clone).
Sourcepub fn into_items(self) -> Vec<VmValue>
pub fn into_items(self) -> Vec<VmValue>
Consume the set, yielding its items in insertion order. Used by the iterative teardown path so deeply nested sets drop without recursing.
Sourcepub fn union(&self, other: &VmSet) -> VmSet
pub fn union(&self, other: &VmSet) -> VmSet
self ∪ other, preserving self’s order then other’s new items.
Sourcepub fn intersect(&self, other: &VmSet) -> VmSet
pub fn intersect(&self, other: &VmSet) -> VmSet
self ∩ other — items of self also present in other.
Sourcepub fn difference(&self, other: &VmSet) -> VmSet
pub fn difference(&self, other: &VmSet) -> VmSet
self \ other — items of self not present in other.
Sourcepub fn symmetric_difference(&self, other: &VmSet) -> VmSet
pub fn symmetric_difference(&self, other: &VmSet) -> VmSet
self △ other — items in exactly one of the two sets.
pub fn is_subset(&self, other: &VmSet) -> bool
pub fn is_superset(&self, other: &VmSet) -> bool
pub fn is_disjoint(&self, other: &VmSet) -> bool
Sourcepub fn sorted_keys(&self) -> Vec<&str>
pub fn sorted_keys(&self) -> Vec<&str>
Structural keys in sorted order. Backs the order-independent set hash
in value_structural_hash_key
without re-deriving a key per element.
Trait Implementations§
Source§impl FromIterator<VmValue> for VmSet
impl FromIterator<VmValue> for VmSet
Auto Trait Implementations§
impl !RefUnwindSafe for VmSet
impl !UnwindSafe for VmSet
impl Freeze for VmSet
impl Send for VmSet
impl Sync for VmSet
impl Unpin for VmSet
impl UnsafeUnpin for VmSet
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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<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>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Paint for Twhere
T: ?Sized,
impl<T> Paint for Twhere
T: ?Sized,
Source§fn fg(&self, value: Color) -> Painted<&T>
fn fg(&self, value: Color) -> Painted<&T>
Returns a styled value derived from self with the foreground set to
value.
This method should be used rarely. Instead, prefer to use color-specific
builder methods like red() and
green(), which have the same functionality but are
pithier.
§Example
Set foreground color to white using fg():
use yansi::{Paint, Color};
painted.fg(Color::White);Set foreground color to white using white().
use yansi::Paint;
painted.white();Source§fn bright_black(&self) -> Painted<&T>
fn bright_black(&self) -> Painted<&T>
Source§fn bright_red(&self) -> Painted<&T>
fn bright_red(&self) -> Painted<&T>
Source§fn bright_green(&self) -> Painted<&T>
fn bright_green(&self) -> Painted<&T>
Source§fn bright_yellow(&self) -> Painted<&T>
fn bright_yellow(&self) -> Painted<&T>
Source§fn bright_blue(&self) -> Painted<&T>
fn bright_blue(&self) -> Painted<&T>
Source§fn bright_magenta(&self) -> Painted<&T>
fn bright_magenta(&self) -> Painted<&T>
Source§fn bright_cyan(&self) -> Painted<&T>
fn bright_cyan(&self) -> Painted<&T>
Source§fn bright_white(&self) -> Painted<&T>
fn bright_white(&self) -> Painted<&T>
Source§fn bg(&self, value: Color) -> Painted<&T>
fn bg(&self, value: Color) -> Painted<&T>
Returns a styled value derived from self with the background set to
value.
This method should be used rarely. Instead, prefer to use color-specific
builder methods like on_red() and
on_green(), which have the same functionality but
are pithier.
§Example
Set background color to red using fg():
use yansi::{Paint, Color};
painted.bg(Color::Red);Set background color to red using on_red().
use yansi::Paint;
painted.on_red();Source§fn on_primary(&self) -> Painted<&T>
fn on_primary(&self) -> Painted<&T>
Source§fn on_magenta(&self) -> Painted<&T>
fn on_magenta(&self) -> Painted<&T>
Source§fn on_bright_black(&self) -> Painted<&T>
fn on_bright_black(&self) -> Painted<&T>
Source§fn on_bright_red(&self) -> Painted<&T>
fn on_bright_red(&self) -> Painted<&T>
Source§fn on_bright_green(&self) -> Painted<&T>
fn on_bright_green(&self) -> Painted<&T>
Source§fn on_bright_yellow(&self) -> Painted<&T>
fn on_bright_yellow(&self) -> Painted<&T>
Source§fn on_bright_blue(&self) -> Painted<&T>
fn on_bright_blue(&self) -> Painted<&T>
Source§fn on_bright_magenta(&self) -> Painted<&T>
fn on_bright_magenta(&self) -> Painted<&T>
Source§fn on_bright_cyan(&self) -> Painted<&T>
fn on_bright_cyan(&self) -> Painted<&T>
Source§fn on_bright_white(&self) -> Painted<&T>
fn on_bright_white(&self) -> Painted<&T>
Source§fn attr(&self, value: Attribute) -> Painted<&T>
fn attr(&self, value: Attribute) -> Painted<&T>
Enables the styling Attribute value.
This method should be used rarely. Instead, prefer to use
attribute-specific builder methods like bold() and
underline(), which have the same functionality
but are pithier.
§Example
Make text bold using attr():
use yansi::{Paint, Attribute};
painted.attr(Attribute::Bold);Make text bold using using bold().
use yansi::Paint;
painted.bold();Source§fn rapid_blink(&self) -> Painted<&T>
fn rapid_blink(&self) -> Painted<&T>
Source§fn quirk(&self, value: Quirk) -> Painted<&T>
fn quirk(&self, value: Quirk) -> Painted<&T>
Enables the yansi Quirk value.
This method should be used rarely. Instead, prefer to use quirk-specific
builder methods like mask() and
wrap(), which have the same functionality but are
pithier.
§Example
Enable wrapping using .quirk():
use yansi::{Paint, Quirk};
painted.quirk(Quirk::Wrap);Enable wrapping using wrap().
use yansi::Paint;
painted.wrap();Source§fn clear(&self) -> Painted<&T>
👎Deprecated since 1.0.1: renamed to resetting() due to conflicts with Vec::clear().
The clear() method will be removed in a future release.
fn clear(&self) -> Painted<&T>
renamed to resetting() due to conflicts with Vec::clear().
The clear() method will be removed in a future release.
Source§fn whenever(&self, value: Condition) -> Painted<&T>
fn whenever(&self, value: Condition) -> Painted<&T>
Conditionally enable styling based on whether the Condition value
applies. Replaces any previous condition.
See the crate level docs for more details.
§Example
Enable styling painted only when both stdout and stderr are TTYs:
use yansi::{Paint, Condition};
painted.red().on_yellow().whenever(Condition::STDOUTERR_ARE_TTY);