You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently 2 stages in the manually written pipeline use std::process:exit(0) to exit successfully, but early, from the pipeline. The usage of this exit()/1 function however also quits out of a test binary.
The pipeline should be streamlined by making using of Result and the try operator for early breaking.
The try operator itself (std::ops::Try) is unfortunately currently marked as unstable [1].
An alternative would be to use std::convert::From instead.
I have a working version which uses Rust nightly which wraps a Result<OkMarker, Result<OkButStopNowMarker, E>> in a struct (so traits can be implemented for the type) and implements the Try (?) operator. Now working on converting this solution to use std::convert::From` instead.
type InnerErr<E> = Result<OkButStopNowMarker, E>
The idea behind Result<OkMarker, InnerErr<E>> is that this outer result can be used with the ? try operator for clean early break with result, and that the inner result, InnerErr here, can be used to determine the Result (return value and error code) of the main() function.
When using the Try operator, the value can instead of being a wrapper around a double result be an 3 element enum with something like Ok, StopNow, Err(Box<dyn Error>) as variants. I'm not sure yet if this is possible in a clean way with From.
Succeeds #71.
Currently 2 stages in the manually written pipeline use
std::process:exit(0)
to exit successfully, but early, from the pipeline. The usage of thisexit()/1
function however also quits out of a test binary.The pipeline should be streamlined by making using of Result and the try operator for early breaking.
The try operator itself (
std::ops::Try
) is unfortunately currently marked as unstable [1].An alternative would be to use
std::convert::From
instead.[1] https://doc.rust-lang.org/std/ops/trait.Try.html
PR: (none)
Previous issue: #71
The text was updated successfully, but these errors were encountered: