Row

Struct Row 

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

Source

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

Lookup the field name if it exists.

Also see the Index implementation, which just unwraps this.

Source

pub fn get_mut(&mut self, name: NameSegment) -> Option<&mut T>

Lookup the field name by mutable reference.

Source

pub fn get_with_label(&self, name: NameSegment) -> Option<&(LabelSegment, T)>

Lookup the field name if it exists, and get its value and label.

Source

pub fn iter(&self) -> impl Iterator<Item = (&NameSegment, &(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.

Source

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

Return whether the row contains the given field.

Source

pub fn empty() -> Self

Construct 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

pub fn insert(&mut self, field: NameSegment, label: LabelSegment, value: T)

Insert a new field.

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> Default for Row<T>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

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

Source§

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>

Source§

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

Creates a value from an iterator. Read more
Source§

impl<S: Clone + Into<Ustr>, T> FromIterator<(S, T)> for Row<T>

Source§

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

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: NameSegment) -> &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>
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> 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
Source§

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

Source§

fn __clone_box(&self, _: Private) -> *mut ()

§

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

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

§

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

Checks if this value is equivalent to the given key. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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
§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. 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

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more