Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhance user-like testing beyond 0.8.0 #77

Closed
foresterre opened this issue Nov 30, 2018 · 1 comment
Closed

Enhance user-like testing beyond 0.8.0 #77

foresterre opened this issue Nov 30, 2018 · 1 comment
Assignees
Labels
C-enhancement Category: enhancements S-in-progress Status: work in progress
Milestone

Comments

@foresterre
Copy link
Owner

foresterre commented Nov 30, 2018

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 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.

[1] https://doc.rust-lang.org/std/ops/trait.Try.html


PR: (none)
Previous issue: #71

@foresterre foresterre changed the title Enhance user-like testing Enhance user-like testing beyond 0.8.0 Nov 30, 2018
@foresterre foresterre self-assigned this Jan 31, 2019
@foresterre foresterre added C-enhancement Category: enhancements S-in-progress Status: work in progress labels Jan 31, 2019
@foresterre foresterre added this to the 0.9.0 milestone Jan 31, 2019
@foresterre
Copy link
Owner Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-enhancement Category: enhancements S-in-progress Status: work in progress
Projects
None yet
Development

No branches or pull requests

1 participant