pub struct Row<T>(/* private fields */);
Expand description
A cheaply cloneable, insertion-ordered map from FieldName
to T
.
Also stores a “label” for each entry, which may not be the same as the FieldName in the case that the FieldName 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: FieldName) -> Option<&T>
pub fn get(&self, name: FieldName) -> Option<&T>
Lookup the field name
if it exists.
Also see the Index implementation, which just unwrap
s this.
Sourcepub fn iter(&self) -> impl Iterator<Item = (&FieldName, &(LabelSegment, T))>
pub fn iter(&self) -> impl Iterator<Item = (&FieldName, &(LabelSegment, T))>
Iterate through the fields in insertion order.
Source§impl<T: Clone> Row<T>
impl<T: Clone> Row<T>
Sourcepub fn insert(self, field: FieldName, label: LabelSegment, value: T) -> Self
pub fn insert(self, field: FieldName, label: LabelSegment, value: T) -> Self
Insert a new field
Uses Rc::make_mut to mutate in place if there are no other references to self, otherwise performs a clone.
Trait Implementations§
Source§impl<T> From<IndexMap<NameSegment, (LabelSegment, T)>> for Row<T>
impl<T> From<IndexMap<NameSegment, (LabelSegment, T)>> for Row<T>
Source§impl<T> FromIterator<(NameSegment, (LabelSegment, T))> for Row<T>
impl<T> FromIterator<(NameSegment, (LabelSegment, T))> for Row<T>
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>
impl<T> !Sync for Row<T>
impl<T> Unpin for Row<T>
impl<T> UnwindSafe for Row<T>where
T: RefUnwindSafe,
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.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<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.