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 theinput_borrow
given/forfeited topolonius()
; -
or having no such type, i.e., having only “
Owned
” (as far as theinput_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
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
.
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.
Implementations§
source§impl<BorrowingOutput, OwnedOutput> PoloniusResult<BorrowingOutput, OwnedOutput>
impl<BorrowingOutput, OwnedOutput> PoloniusResult<BorrowingOutput, OwnedOutput>
sourcepub const fn Owned(value: OwnedOutput) -> Self
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.