Struct Row

Source
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>

Source

pub fn get(&self, name: FieldName) -> Option<&T>

Lookup the field name if it exists.

Also see the Index implementation, which just unwraps this.

Source

pub fn iter(&self) -> impl Iterator<Item = (&FieldName, &(LabelSegment, T))>

Iterate through the fields in insertion order.

Source

pub fn len(&self) -> usize

Return the number of fields.

Source

pub fn is_empty(&self) -> bool

Return whether the row is empty (Clippy wants this).

Source

pub fn has(&self, field_name: FieldName) -> bool

Return whether the row contains the given field

Source

pub fn empty() -> Self

Produce the empty row.

Source

pub fn map<S>(&self, f: impl Fn(&T) -> S) -> Row<S>

Map a function to produce a new row.

Source§

impl<T: Clone> Row<T>

Source

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: Clone> Clone for Row<T>

Source§

fn clone(&self) -> Row<T>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<T> From<IndexMap<NameSegment, (LabelSegment, T)>> for Row<T>

Source§

fn from(value: IndexMap<FieldName, (LabelSegment, T)>) -> Self

Converts to this type from the input type.
Source§

impl<T> FromIterator<(NameSegment, (LabelSegment, T))> for Row<T>

Source§

fn from_iter<I>(iter: I) -> Self
where I: IntoIterator<Item = (FieldName, (LabelSegment, T))>,

Creates a value from an iterator. Read more
Source§

impl<T> Index<NameSegment> for Row<T>

Source§

type Output = T

The returned type after indexing.
Source§

fn index(&self, index: FieldName) -> &Self::Output

Performs the indexing (container[index]) operation. Read more
Source§

impl<T: PartialEq> PartialEq for Row<T>

Source§

fn eq(&self, other: &Row<T>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<T: Eq> Eq for Row<T>

Source§

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

§

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

Checks if self is actually part of its subset T (and can be converted to it).
§

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

The inclusion map: converts self to the equivalent element of its superset.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V