Skip to main content

SeqSlot

Struct SeqSlot 

Source
pub struct SeqSlot<Entry, ChildEntry> {
    pub wrap: fn(ChildEntry) -> Entry,
    pub project: fn(&Entry) -> Option<&ChildEntry>,
}
Expand description

Where a child’s appended entries live inside its parent’s sequence.

Slot’s counterpart, and the same idea one type along: the parent’s Entry is a sum, the child’s entries are one of its variants, and both append into one sequence rather than two. One sequence is what keeps the ordering between a parent’s entry and its child’s real — two would have no order between them at all, and a recovery replaying them would be inventing one.

wrap puts a child’s entry into the parent’s vocabulary; project takes it back out and says None for an entry that is not the child’s.

§The positions the child sees are the parent’s

The store handed to such a child filters the parent’s sequence to the child’s variant, so what the child reads back is its own entries in order — but the Positions are the parent’s, and therefore sparse: a child’s third entry may sit at position seven. That is deliberate and is all a cursor needs, since positions are only ever compared and advanced, never counted. A child that treated a position as an index into its own entries would be wrong, and would have been wrong about a plain store too.

fn pointers rather than closures, for the reason Slot gives: a slot names a fixed place in a type, and one that could close over state would name a different place on different calls.

Fields§

§wrap: fn(ChildEntry) -> Entry

A child’s entry, in the parent’s vocabulary.

§project: fn(&Entry) -> Option<&ChildEntry>

The child’s entry inside a parent’s, or None if this entry is not the child’s.

Trait Implementations§

Source§

impl<Entry, ChildEntry> Clone for SeqSlot<Entry, ChildEntry>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl<Entry, ChildEntry> Copy for SeqSlot<Entry, ChildEntry>

Source§

impl<Entry, ChildEntry> Debug for SeqSlot<Entry, ChildEntry>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<Entry, ChildEntry> Freeze for SeqSlot<Entry, ChildEntry>

§

impl<Entry, ChildEntry> RefUnwindSafe for SeqSlot<Entry, ChildEntry>

§

impl<Entry, ChildEntry> Send for SeqSlot<Entry, ChildEntry>

§

impl<Entry, ChildEntry> Sync for SeqSlot<Entry, ChildEntry>

§

impl<Entry, ChildEntry> Unpin for SeqSlot<Entry, ChildEntry>

§

impl<Entry, ChildEntry> UnsafeUnpin for SeqSlot<Entry, ChildEntry>

§

impl<Entry, ChildEntry> UnwindSafe for SeqSlot<Entry, ChildEntry>

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
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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

§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

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