Expand description
A stable implementation of Rust’s Try and FromResidual.
This crate provides the trait machinery necessary to desugar the ? operator
on stable Rust across Result, Option, ControlFlow, Poll, and layered
types (e.g. Poll<Result<T, E>>, Poll<Option<Result<T, E>>>).
§The ? Desugaring Pattern
match cps_try::branch(expr) {
std::ops::ControlFlow::Continue(val) => val,
std::ops::ControlFlow::Break(residual) => return cps_try::from_residual(residual),
};Because return from_residual(residual) is evaluated in return position,
Rust’s standard type inference resolves the target return type automatically
without requiring any explicit type annotations.
Macros§
- try_op
- Desugars the
?operator on stable Rust.
Structs§
- Control
Flow Residual - The residual type representing an early break for
ControlFlow. - Option
Residual - The residual type representing a
Nonevalue forOption. - Result
Residual - The residual type representing a failed
Result.
Traits§
- From
Residual - Constructing a return type from an early-exit residual.
- Try
- Splitting an expression into a success value or an early-exit residual.
Functions§
- branch
- Branch a
Tryexpression intoControlFlow. - from_
residual - Convert an early-exit residual into the target return type.