Skip to main content

Prepared

Enum Prepared 

Source
#[doc(hidden)]
pub enum Prepared<T, E = <T as TryFromSexp>::Error> { Unprepared, Ready(T), Failed(E), Deferred { borrow: Option<NativeBorrow>, arms: Arms, }, Undecided(Option<NativeBorrow>), }
Expand description

An argument’s conversion as a generated wrapper’s alias check leaves it: T’s, whose conversion error is E.

The type has no TryFromSexp bound, so a wrapper can declare and read the state of an argument whose type has no conversion without a second error: convert reports it, at the type.

Variants§

§

Unprepared

Not prepared: it converts after the check, which takes its declared metadata.

§

Ready(T)

Converted during preparation and borrows nothing native: the value is the argument.

§

Failed(E)

Failed during preparation. The error is reported where the argument converts, so the order of argument errors does not change.

§

Deferred

A borrowing arm will convert: borrow is all it borrows, arms the way to it. Its reference is built after the check.

Fields

§borrow: Option<NativeBorrow>

What the selected arm borrows.

§arms: Arms

The arms from the argument’s type down to the borrowing leaf.

§

Undecided(Option<NativeBorrow>)

The arm could not be learned without building a reference: it converts after the check, which takes borrow (every arm it may still take).

Implementations§

Source§

impl<T: TryFromSexp> Prepared<T>

Source

pub fn deferred() -> Self

A borrowing leaf whose checks passed: its conversion will succeed and borrow what T::NATIVE_BORROW says.

Source§

impl<T, E> Prepared<T, E>

Source

pub fn from_result(result: Result<T, E>) -> Self

An owned conversion’s result.

Source

pub fn borrow(&self, declared: Option<NativeBorrow>) -> Option<NativeBorrow>

What the argument borrows for the second pass of the check, given its declared metadata.

Source

pub fn map<U: TryFromSexp>( self, value: impl FnOnce(T) -> U, error: impl FnOnce(E) -> U::Error, ) -> Prepared<U>

The preparation of a type that wraps T: value and error build its value and error, and its __mx_materialize must follow the same arms through T’s.

Source

pub fn arm<U: TryFromSexp>( self, right: bool, value: impl FnOnce(T) -> U, either: Option<NativeBorrow>, ) -> Prepared<U>

This preparation as one arm of an Either (right for the right arm), whose own metadata is either.

Layout§

Note: Unable to compute type layout, possibly due to this type having generic parameters. Layout can only be computed for concrete, fully-instantiated types.