pub struct HDict { /* private fields */ }Expand description
Haystack Dict — the fundamental entity/row type in Haystack.
An HDict is a mutable dictionary mapping tag names (String) to values (Kind).
Dicts are used as rows in grids, as entity records, and as metadata containers.
Implementations§
Source§impl HDict
impl HDict
Create a dict from a pre-built HashMap.
Sourcepub fn has(&self, name: &str) -> bool
pub fn has(&self, name: &str) -> bool
Returns true if the dict contains a tag with the given name.
Sourcepub fn get(&self, name: &str) -> Option<&Kind>
pub fn get(&self, name: &str) -> Option<&Kind>
Returns a reference to the value for the given tag name, if present.
Sourcepub fn missing(&self, name: &str) -> bool
pub fn missing(&self, name: &str) -> bool
Returns true if the dict does NOT contain a tag with the given name.
Sourcepub fn dis(&self) -> Option<&str>
pub fn dis(&self) -> Option<&str>
Returns the display string for this dict.
Prefers the dis tag (if it is a Str), then falls back to the
id ref’s display name.
Sourcepub fn remove_tag(&mut self, name: &str) -> Option<Kind>
pub fn remove_tag(&mut self, name: &str) -> Option<Kind>
Remove a tag by name, returning its value if it was present.
Sourcepub fn merge(&mut self, other: &HDict)
pub fn merge(&mut self, other: &HDict)
Merge another dict into this one.
Tags from other overwrite tags in self. If a tag in other is
Kind::Remove, the corresponding tag in self is removed instead.
Returns a reference to the underlying HashMap.
Sourcepub fn sorted_iter(&self) -> Vec<(&str, &Kind)>
pub fn sorted_iter(&self) -> Vec<(&str, &Kind)>
Iterate over tags sorted by key name.
Sourcepub fn tag_name_set(&self) -> HashSet<&str>
pub fn tag_name_set(&self) -> HashSet<&str>
Collect all tag names into a HashSet.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for HDict
impl RefUnwindSafe for HDict
impl Send for HDict
impl Sync for HDict
impl Unpin for HDict
impl UnsafeUnpin for HDict
impl UnwindSafe for HDict
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<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 more