polonius_the_crab

Enum PoloniusResult

Source
pub enum PoloniusResult<BorrowingOutput, OwnedOutput, InputBorrow = Placeholder> {
    Borrowing(BorrowingOutput),
    Owned {
        value: OwnedOutput,
        input_borrow: InputBorrow,
    },
}
Expand description

Output type of both the polonius() function and the closure it takes.

It represents the conceptual code-flow / branch disjunction between:

  • having some dependent type still Borrowing from the input_borrow given/forfeited to polonius();

  • or having no such type, i.e., having only “Owned” (as far as the input_borrow is concerned) output.

    • polonius() magic makes it so, in this branch/case, its .input_borrow shall be populated for the caller to get back access to it.

Variants§

§

Borrowing(BorrowingOutput)

Variant to return in the “happy” case where our tentative (re)borrow actually yielded some dependent / still-Borrowing type which we wish to keep hold of, e.g., to return it from the function.

§

Owned

Variant to return in the branches where we are done with any dependent value, and we would like to instead get our input_borrow back.

Fields

§value: OwnedOutput

The inner value of the Self::Owned(value) case.

§input_borrow: InputBorrow

When constructing this variant, inside polonius()’ closure, a Placeholder is to be put in its stead, to let polonius() replace it with its input_borrow.

Implementations§

Source§

impl<BorrowingOutput, OwnedOutput> PoloniusResult<BorrowingOutput, OwnedOutput>

Source

pub const fn Owned(value: OwnedOutput) -> Self

Tuple-variant-looking sugar to construct the Self::Owned variant.

It’s just convenience sugar for Self::Owned { value, input_borrow: Placeholder }.

PoloniusResult::Owned(42)
// is the same as:
PoloniusResult::Owned {
    value: 42,
    input_borrow: Placeholder,
}

See Placeholder for more info.

Auto Trait Implementations§

§

impl<BorrowingOutput, OwnedOutput, InputBorrow> Freeze for PoloniusResult<BorrowingOutput, OwnedOutput, InputBorrow>
where BorrowingOutput: Freeze, OwnedOutput: Freeze, InputBorrow: Freeze,

§

impl<BorrowingOutput, OwnedOutput, InputBorrow> RefUnwindSafe for PoloniusResult<BorrowingOutput, OwnedOutput, InputBorrow>
where BorrowingOutput: RefUnwindSafe, OwnedOutput: RefUnwindSafe, InputBorrow: RefUnwindSafe,

§

impl<BorrowingOutput, OwnedOutput, InputBorrow> Send for PoloniusResult<BorrowingOutput, OwnedOutput, InputBorrow>
where BorrowingOutput: Send, OwnedOutput: Send, InputBorrow: Send,

§

impl<BorrowingOutput, OwnedOutput, InputBorrow> Sync for PoloniusResult<BorrowingOutput, OwnedOutput, InputBorrow>
where BorrowingOutput: Sync, OwnedOutput: Sync, InputBorrow: Sync,

§

impl<BorrowingOutput, OwnedOutput, InputBorrow> Unpin for PoloniusResult<BorrowingOutput, OwnedOutput, InputBorrow>
where BorrowingOutput: Unpin, OwnedOutput: Unpin, InputBorrow: Unpin,

§

impl<BorrowingOutput, OwnedOutput, InputBorrow> UnwindSafe for PoloniusResult<BorrowingOutput, OwnedOutput, InputBorrow>
where BorrowingOutput: UnwindSafe, OwnedOutput: UnwindSafe, InputBorrow: 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> Is for T
where T: ?Sized,

Source§

type EqTo = T

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.