Enum ShortPath

Source
pub enum ShortPath<V, E> {
    Zero(V),
    One(E),
}
Expand description

A path of length at most one.

We call a path of length at most one, i.e., a path of lenth zero or one, a short path. This is not standard terminology, though it is inspired by “short maps” between metric spaces, which are Lipschitz maps with Lipschitz constant at most 1.

Short paths are convertible into, and fallibly from, paths. Short paths might seem like an odd data structure, but are occasionally useful, such as in:

  • finite categories defined by an explicit multiplication table, where every morphism is either a generator (path of length one) or an identity (path of length zero)
  • augmented virtual double categories (Koudenburg 2020), where the codomain of a cell is by definition a short path, and relatedly unital virtual double categories

Variants§

§

Zero(V)

Path of length zero.

§

One(E)

Path of length one.

Implementations§

Source§

impl<Id> ShortPath<ModeApp<Id>, ModeApp<Id>>

Source

pub fn apply(self, m: Modality) -> Self

Applies a modality.

Source

pub fn apply_all(self, iter: impl IntoIterator<Item = Modality>) -> Self

Applies a sequence of modalities.

Source§

impl<V, E> ShortPath<V, E>

Source

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

Is the path contained in the given graph?

Source

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

Source of the path in the given 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.

Source

pub fn as_edge(self, graph: &impl ReflexiveGraph<V = V, E = E>) -> E

Converts the short path into an edge in the given reflexive graph.

Source

pub fn map<CodV, CodE>( self, fv: impl FnOnce(V) -> CodV, fe: impl FnOnce(E) -> CodE, ) -> ShortPath<CodV, CodE>

Maps over the short path.

Trait Implementations§

Source§

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

Source§

fn clone(&self) -> ShortPath<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 ShortPath<V, E>

Source§

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

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

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

Source§

fn from(value: E) -> Self

Converts to this type from the input type.
Source§

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

Source§

fn from(path: ShortPath<V, E>) -> Self

Converts to this type from the input type.
Source§

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

Source§

fn eq(&self, other: &ShortPath<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> TryFrom<Path<V, E>> for ShortPath<V, E>

Source§

type Error = ()

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

fn try_from(path: Path<V, E>) -> Result<Self, Self::Error>

Performs the conversion.
Source§

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

Source§

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

Auto Trait Implementations§

§

impl<V, E> Freeze for ShortPath<V, E>
where V: Freeze, E: Freeze,

§

impl<V, E> RefUnwindSafe for ShortPath<V, E>

§

impl<V, E> Send for ShortPath<V, E>
where V: Send, E: Send,

§

impl<V, E> Sync for ShortPath<V, E>
where V: Sync, E: Sync,

§

impl<V, E> Unpin for ShortPath<V, E>
where V: Unpin, E: Unpin,

§

impl<V, E> UnwindSafe for ShortPath<V, E>
where V: UnwindSafe, E: 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
§

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<!> for T

Source§

fn from(t: !) -> T

Converts to this type from the input type.
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.
Source§

impl<T> Scalar for T
where T: 'static + Clone + PartialEq + Debug,