Skip to main content

Value

Enum Value 

Source
pub enum Value<T, B: BoundaryKind = GenericBoundary> {
    Interior(T),
    Boundary {
        reason: B,
        last: T,
    },
}
Expand description

The core type. Interior or Boundary. One distinction. Every domain.

Variants§

§

Interior(T)

Interior: the value is in safe territory.

§

Boundary

Boundary: the value crossed the edge. Carries the reason and last known value.

Fields

§reason: B
§last: T

Implementations§

Source§

impl<T, B: BoundaryKind> Value<T, B>

Source

pub fn interior(value: T) -> Self

Construct an interior value.

Source

pub fn boundary(reason: B, last: T) -> Self

Construct a boundary value with a reason and last known value.

Source

pub fn is_interior(&self) -> bool

Source

pub fn is_boundary(&self) -> bool

Source

pub fn or(self, fallback: T) -> T

Unwrap the interior value, or return a fallback.

Source

pub fn unwrap(self) -> T

Unwrap the interior value, or panic.

Source

pub fn map<U>(self, f: impl FnOnce(T) -> U) -> Value<U, B>

Map over the interior value. Boundaries propagate unchanged.

Source

pub fn propagate(self) -> Result<T, B>

Extract the interior value, or return the boundary reason as Err for ? propagation. The residual is not carried through propagation — match explicitly to access it.

Source

pub fn trace(self, chain: &mut Chain, label: &'static str) -> Result<T, B>
where T: Debug,

Extract the interior value while recording the step in a trace. If boundary, records the residual in the chain and returns the reason. If interior, records the value and continues.

Source

pub fn and_then<U: Default>( self, f: impl FnOnce(T) -> Value<U, B>, ) -> Value<U, B>

Chain operations that may themselves hit a boundary. Requires U: Default so a boundary can carry a last value when types change.

Trait Implementations§

Source§

impl<T: Debug, B: Debug + BoundaryKind> Debug for Value<T, B>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<T, B> Freeze for Value<T, B>
where T: Freeze, B: Freeze,

§

impl<T, B> RefUnwindSafe for Value<T, B>

§

impl<T, B> Send for Value<T, B>
where T: Send,

§

impl<T, B> Sync for Value<T, B>
where T: Sync,

§

impl<T, B> Unpin for Value<T, B>
where T: Unpin, B: Unpin,

§

impl<T, B> UnsafeUnpin for Value<T, B>
where T: UnsafeUnpin, B: UnsafeUnpin,

§

impl<T, B> UnwindSafe for Value<T, B>
where T: UnwindSafe, B: 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> 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, 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.