Skip to main content

try_laws

Function try_laws 

Source
pub open spec fn try_laws<R: Try>() -> bool
Expand description
{
    &&& R::branch_model_is_valid()
    &&& forall |output: R::Output, result: R| {
        #[trigger] R::from_output.ensures((output,), result)
            ==> R::branch_model(result) == ControlFlow::Continue(output)
    }
    &&& forall |residual: R::Residual, result: R| {
        #[trigger]
        <R as FromResidual<R::Residual>>::from_residual.ensures((residual,), result)
            ==> R::branch_model(result) == ControlFlow::Break(residual)
    }

}

We can provide stronger guarantees for types that obey these laws