pub struct Row<T>(/* private fields */);Expand description
An insertion-ordered map from NameSegment to T.
Also stores a “label” for each entry, which may not be the same as the NameSegment in the case that the NameSegment is a UUID.
This is called “row” because it’s a short name, and it corresponds to the idea of a row in a database, which is a map from fields to values.
Create this using the FromIterator implementation.
Implementations§
Source§impl<T> Row<T>
impl<T> Row<T>
Sourcepub fn get(&self, name: NameSegment) -> Option<&T>
pub fn get(&self, name: NameSegment) -> Option<&T>
Lookup the field name if it exists.
Also see the Index implementation, which just unwraps this.
Sourcepub fn get_mut(&mut self, name: NameSegment) -> Option<&mut T>
pub fn get_mut(&mut self, name: NameSegment) -> Option<&mut T>
Lookup the field name by mutable reference.
Sourcepub fn get_with_label(&self, name: NameSegment) -> Option<&(LabelSegment, T)>
pub fn get_with_label(&self, name: NameSegment) -> Option<&(LabelSegment, T)>
Lookup the field name if it exists, and get its value and label.
Sourcepub fn iter(&self) -> impl Iterator<Item = (&NameSegment, &(LabelSegment, T))>
pub fn iter(&self) -> impl Iterator<Item = (&NameSegment, &(LabelSegment, T))>
Iterate through the fields in insertion order.
Sourcepub fn has(&self, field_name: NameSegment) -> bool
pub fn has(&self, field_name: NameSegment) -> bool
Return whether the row contains the given field.
Sourcepub fn insert(&mut self, field: NameSegment, label: LabelSegment, value: T)
pub fn insert(&mut self, field: NameSegment, label: LabelSegment, value: T)
Insert a new field.
Trait Implementations§
Source§impl<T> From<IndexMap<NameSegment, (LabelSegment, T)>> for Row<T>
impl<T> From<IndexMap<NameSegment, (LabelSegment, T)>> for Row<T>
Source§fn from(value: IndexMap<NameSegment, (LabelSegment, T)>) -> Self
fn from(value: IndexMap<NameSegment, (LabelSegment, T)>) -> Self
Converts to this type from the input type.
Source§impl<T> FromIterator<(NameSegment, (LabelSegment, T))> for Row<T>
impl<T> FromIterator<(NameSegment, (LabelSegment, T))> for Row<T>
Source§fn from_iter<I: IntoIterator<Item = (NameSegment, (LabelSegment, T))>>(
iter: I,
) -> Self
fn from_iter<I: IntoIterator<Item = (NameSegment, (LabelSegment, T))>>( iter: I, ) -> Self
Creates a value from an iterator. Read more
Source§impl<T> Index<NameSegment> for Row<T>
impl<T> Index<NameSegment> for Row<T>
impl<T: Eq> Eq for Row<T>
impl<T> StructuralPartialEq for Row<T>
Auto Trait Implementations§
impl<T> Freeze for Row<T>
impl<T> RefUnwindSafe for Row<T>where
T: RefUnwindSafe,
impl<T> Send for Row<T>where
T: Send,
impl<T> Sync for Row<T>where
T: Sync,
impl<T> Unpin for Row<T>where
T: Unpin,
impl<T> UnwindSafe for Row<T>where
T: 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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Checks if this value is equivalent to the given key. Read more
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§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>
Converts
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>
Converts
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§impl<T> Pointable for T
impl<T> Pointable for T
§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct
self from the equivalent element of its
superset. Read more§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
self is actually part of its subset T (and can be converted to it).§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
Use with care! Same as
self.to_subset but without any property checks. Always succeeds.§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self to the equivalent element of its superset.