Enum tear::ValRet[][src]

#[must_use = "Suggestion: use tear! to handle it"]pub enum ValRet<V, R> {
    Val(V),
    Ret(R),
}

Represents a usable value or an early return. Use with tear!

Description

The idea is to type an early return. The early return either evaluates to something (Val) or returns early (Ret).

Variants

Val(V)

The usable value

Ret(R)

The return value

Implementations

impl<V, R> ValRet<V, R>[src]

NB: Other combinators such as and, and_then, or, map_val aren’t implemented because I didn’t need them, not because they aren’t useful.

Examples will all use the following two variables

let ok:    ValRet<&str, &str> = Val("ok");
let error: ValRet<&str, &str> = Ret("error");

pub fn val(self) -> Option<V>[src]

Gets the Val(V) variant as Option<V>

pub fn ret(self) -> Option<R>[src]

Gets the Ret(R) variant as Option<R>

Trait Implementations

impl<V: Clone, R: Clone> Clone for ValRet<V, R>[src]

impl<V: Debug, R: Debug> Debug for ValRet<V, R>[src]

impl<T, R> Judge for ValRet<T, R>[src]

type Positive = T

This is considered Good

type Negative = R

This is considered Bad

impl<V: PartialEq, R: PartialEq> PartialEq<ValRet<V, R>> for ValRet<V, R>[src]

impl<V, R> StructuralPartialEq for ValRet<V, R>[src]

Auto Trait Implementations

impl<V, R> Send for ValRet<V, R> where
    R: Send,
    V: Send

impl<V, R> Sync for ValRet<V, R> where
    R: Sync,
    V: Sync

impl<V, R> Unpin for ValRet<V, R> where
    R: Unpin,
    V: Unpin

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, E, Me> Return for Me where
    Me: Judge<Positive = T, Negative = E>, 
[src]

type Value = T

The Val in ValRet

type Returned = E

The Ret in ValRet

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.