pub struct PartialMap<V>(/* private fields */);Expand description
A map whose keys may contain holes (unresolved placeholders).
Backed by a Vec rather than IndexMap because hole keys are not
unconditionally deduplicated: anonymous holes (!) always create new
entries. Labeled holes (!label) and resolved keys are deduplicated
by value on lookup, matching the behavior of regular Map.
Use PartialMap::find to look up an existing entry before inserting.
Implementations§
Source§impl<V> PartialMap<V>
impl<V> PartialMap<V>
pub fn new() -> Self
Sourcepub fn push(&mut self, key: PartialObjectKey, value: V)
pub fn push(&mut self, key: PartialObjectKey, value: V)
Append a (key, value) pair unconditionally.
Callers should call Self::find first to avoid duplicate labeled entries.
Sourcepub fn find(&self, key: &PartialObjectKey) -> Option<&V>
pub fn find(&self, key: &PartialObjectKey) -> Option<&V>
Find the first entry matching key.
Keys containing anonymous holes never match — they are always unique.
pub fn iter(&self) -> impl Iterator<Item = (&PartialObjectKey, &V)>
pub fn len(&self) -> usize
pub fn is_empty(&self) -> bool
Trait Implementations§
Source§impl<V: Clone> Clone for PartialMap<V>
impl<V: Clone> Clone for PartialMap<V>
Source§fn clone(&self) -> PartialMap<V>
fn clone(&self) -> PartialMap<V>
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl<V: Debug> Debug for PartialMap<V>
impl<V: Debug> Debug for PartialMap<V>
Source§impl<V: Default> Default for PartialMap<V>
impl<V: Default> Default for PartialMap<V>
Source§fn default() -> PartialMap<V>
fn default() -> PartialMap<V>
Returns the “default value” for a type. Read more
Source§impl<V: PartialEq> PartialEq for PartialMap<V>
impl<V: PartialEq> PartialEq for PartialMap<V>
Auto Trait Implementations§
impl<V> Freeze for PartialMap<V>
impl<V> RefUnwindSafe for PartialMap<V>where
V: RefUnwindSafe,
impl<V> Send for PartialMap<V>where
V: Send,
impl<V> Sync for PartialMap<V>where
V: Sync,
impl<V> Unpin for PartialMap<V>where
V: Unpin,
impl<V> UnsafeUnpin for PartialMap<V>
impl<V> UnwindSafe for PartialMap<V>where
V: UnwindSafe,
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
Mutably borrows from an owned value. Read more