Type Alias TabMor

Source
pub type TabMor<V, E> = Path<TabOb<V, E>, TabEdge<V, E>>;
Expand description

Morphism in a model of a discrete tabulator theory.

Aliased Type§

enum TabMor<V, E> {
    Id(TabOb<V, E>),
    Seq(NonEmpty<TabEdge<V, E>>),
}

Variants§

§

Id(TabOb<V, E>)

The identity, or empty, path at a vertex.

§

Seq(NonEmpty<TabEdge<V, E>>)

A nontrivial path, comprising a non-empty vector of consecutive edges.

Implementations

Source§

impl<V, E> Path<V, E>

Source

pub fn empty(v: V) -> Self

Constructs the empty or identity path.

Source

pub fn single(e: E) -> Self

Constructs a path with a single edge.

Source

pub fn pair(e: E, f: E) -> Self

Constructs a pair of consecutive edges, or path of length 2.

Source

pub fn collect<I>(iter: I) -> Option<Self>
where I: IntoIterator<Item = E>,

Constructs a path from an iterator over edges.

Returns None if the iterator is empty.

Source

pub fn from_vec(vec: Vec<E>) -> Option<Self>

Constructs a path from a vector of edges.

Returns None if the vector is empty.

Source

pub fn repeat_n(v: V, e: E, n: usize) -> Self
where E: Clone,

Constructs a path by repeating an edge n times.

The edge should have the same source and target, namely the first argument.

Source

pub fn len(&self) -> usize

Length of the path.

Source

pub fn is_empty(&self) -> bool

Is the path empty?

Source

pub fn iter(&self) -> impl Iterator<Item = &E>

Iterates over edges in the path, if any.

This method is a one-sided inverse to Path::collect.

Source

pub fn only(self) -> Option<E>

Returns the unique edge in a path of length 1.

This method is a one-sided inverse to Path::single.

Source

pub fn insert(&mut self, index: usize, edge: E)

Inserts an edge into the path at the given index.

Source

pub fn splice(self, range: Range<usize>, replace_with: Self) -> Self

Splices a path into another path at the given range of indices.

Source

pub fn src(&self, graph: &impl Graph<V = V, E = E>) -> V
where V: Clone,

Source of the path in the given graph.

Assumes that the path is contained in the graph.

Source

pub fn tgt(&self, graph: &impl Graph<V = V, E = E>) -> V
where V: Clone,

Target of the path in the given graph.

Assumes that the path is contained in the graph.

Source

pub fn subpath( &self, graph: &impl Graph<V = V, E = E>, range: Range<usize>, ) -> Self
where V: Eq + Clone, E: Clone,

Extracts a subpath of a path in a graph.

Panics if the range is invalid or an empty subpath would be inconsistent.

Source

pub fn replace_subpath<F>( self, graph: &impl Graph<V = V, E = E>, range: Range<usize>, f: F, ) -> Self
where V: Eq + Clone, E: Clone, F: FnOnce(Self) -> Self,

Replaces the subpath at the given range with a function of that subpath.

Panics under the same conditions as subpath.

Source

pub fn concat_in( self, graph: &impl Graph<V = V, E = E>, other: Self, ) -> Option<Self>
where V: Eq + Clone,

Concatenates this path with another path in the graph.

This methods checks that the two paths are compatible (the target of this path equals the source of the other path) and it assumes that both paths are contained in the graph, which should be checked with contained_in if in doubt. Thus, when returned, the concatenated path is also a valid path.

Source

pub fn contained_in(&self, graph: &impl Graph<V = V, E = E>) -> bool
where V: Eq,

Is the path contained in the given graph?

Source

pub fn is_simple(&self) -> bool
where E: Eq + Hash,

Returns whether the path is simple.

On our definition, a path is simple if it has no repeated edges.

Source

pub fn reduce<FnV, FnE>(self, fv: FnV, fe: FnE) -> E
where FnV: FnOnce(V) -> E, FnE: FnMut(E, E) -> E,

Reduces a path using functions on vertices and edges.

Source

pub fn map<CodV, CodE, FnV, FnE>(self, fv: FnV, fe: FnE) -> Path<CodV, CodE>
where FnV: FnOnce(V) -> CodV, FnE: FnMut(E) -> CodE,

Maps a path over functions on vertices and edges.

Source

pub fn partial_map<CodV, CodE, FnV, FnE>( self, fv: FnV, fe: FnE, ) -> Option<Path<CodV, CodE>>
where FnV: FnOnce(V) -> Option<CodV>, FnE: FnMut(E) -> Option<CodE>,

Maps a path over partial functions on vertices and edges.

Source

pub fn try_map<CodV, CodE, FnV, FnE, Err>( self, fv: FnV, fe: FnE, ) -> Result<Path<CodV, CodE>, Err>
where FnV: FnOnce(V) -> Result<CodV, Err>, FnE: FnMut(E) -> Result<CodE, Err>,

Maps a path over fallible functions on vertices and edges.

Trait Implementations§

Source§

impl<V, E> From<E> for TabMor<V, E>

Source§

fn from(value: E) -> Self

Converts to this type from the input type.
Source§

impl<V: Clone, E: Clone> Clone for Path<V, E>

Source§

fn clone(&self) -> Path<V, E>

Returns a copy 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<V: Debug, E: Debug> Debug for Path<V, E>

Source§

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

Formats the value using the given formatter. Read more
Source§

impl<'de, V, E> Deserialize<'de> for Path<V, E>
where V: Deserialize<'de>, E: Deserialize<'de>,

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl<V, E> From<E> for Path<V, E>

Converts an edge into a path of length one.

Source§

fn from(e: E) -> Self

Converts to this type from the input type.
Source§

impl<V, E> FromWasmAbi for Path<V, E>
where Self: DeserializeOwned,

Source§

type Abi = <JsType as FromWasmAbi>::Abi

The Wasm ABI type that this converts from when coming back out from the ABI boundary.
Source§

unsafe fn from_abi(js: Self::Abi) -> Self

Recover a Self from Self::Abi. Read more
Source§

impl<V: Hash, E: Hash> Hash for Path<V, E>

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl<V, E> IntoIterator for Path<V, E>

Converts the path into an iterater over its edges.

Source§

type Item = E

The type of the elements being iterated over.
Source§

type IntoIter = Either<Empty<E>, <NonEmpty<E> as IntoIterator>::IntoIter>

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
Source§

impl<V, E> IntoWasmAbi for Path<V, E>
where Path<V, E>: Serialize,

Source§

type Abi = <JsType as IntoWasmAbi>::Abi

The Wasm ABI type that this converts into when crossing the ABI boundary.
Source§

fn into_abi(self) -> Self::Abi

Convert self into Self::Abi so that it can be sent across the wasm ABI boundary.
Source§

impl<V, E> OptionFromWasmAbi for Path<V, E>
where Self: DeserializeOwned,

Source§

fn is_none(js: &Self::Abi) -> bool

Tests whether the argument is a “none” instance. If so it will be deserialized as None, and otherwise it will be passed to FromWasmAbi.
Source§

impl<V, E> OptionIntoWasmAbi for Path<V, E>
where Path<V, E>: Serialize,

Source§

fn none() -> Self::Abi

Returns an ABI instance indicating “none”, which JS will interpret as the None branch of this option. Read more
Source§

impl<V: PartialEq, E: PartialEq> PartialEq for Path<V, E>

Source§

fn eq(&self, other: &Path<V, E>) -> 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<V, E> RefFromWasmAbi for Path<V, E>
where Self: DeserializeOwned,

Source§

type Abi = <JsType as RefFromWasmAbi>::Abi

The Wasm ABI type references to Self are recovered from.
Source§

type Anchor = SelfOwner<Path<V, E>>

The type that holds the reference to Self for the duration of the invocation of the function that has an &Self parameter. This is required to ensure that the lifetimes don’t persist beyond one function call, and so that they remain anonymous.
Source§

unsafe fn ref_from_abi(js: Self::Abi) -> Self::Anchor

Recover a Self::Anchor from Self::Abi. Read more
Source§

impl<V, E> Serialize for Path<V, E>
where V: Serialize, E: Serialize,

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl<V, E> Tsify for Path<V, E>

Source§

const DECL: &'static str = "/**\n * A path in a [graph](Graph) or [category](crate::one::category::Category).\\n\\nThis definition by cases can be compared with the perhaps more obvious\\ndefinition:\\n\\n```\\nstruct Path<V, E> {\\n start: V,\\n end: V, // Optional: more symmetric but also more redundant.\\n seq: Vec<E>,\\n}\\n```\\n\\nNot only does the single struct store redundant (hence possibly inconsistent)\\ninformation when the sequence of edges is nonempty, one will often need to do a\\ncase analysis on the edge sequence anyway to determine whether, say,\\n[`fold`](std::iter::Iterator::fold) can be called or the result of\\n[`reduce`](std::iter::Iterator::reduce) is valid. Thus, it seems better to reify\\nthe two cases in the data structure itself.\\n\n */\nexport type Path<V, E> = { tag: \"Id\"; content: V } | { tag: \"Seq\"; content: NonEmpty<E> };"

Source§

const SERIALIZATION_CONFIG: SerializationConfig

Source§

type JsType = JsType

§

fn into_js(&self) -> Result<Self::JsType, Error>
where Self: Serialize,

§

fn from_js<T>(js: T) -> Result<Self, Error>
where T: Into<JsValue>, Self: DeserializeOwned,

Source§

impl<V, E> VectorFromWasmAbi for Path<V, E>
where Self: DeserializeOwned,

Source§

type Abi = <JsType as VectorFromWasmAbi>::Abi

Source§

unsafe fn vector_from_abi(js: Self::Abi) -> Box<[Self]>

Source§

impl<V, E> VectorIntoWasmAbi for Path<V, E>
where Path<V, E>: Serialize,

Source§

type Abi = <JsType as VectorIntoWasmAbi>::Abi

Source§

fn vector_into_abi(vector: Box<[Self]>) -> Self::Abi

Source§

impl<V, E> WasmDescribe for Path<V, E>

Source§

impl<V, E> WasmDescribeVector for Path<V, E>

Source§

impl<V: Eq, E: Eq> Eq for Path<V, E>

Source§

impl<V, E> StructuralPartialEq for Path<V, E>