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

Split between Status and Error #10

Merged
merged 3 commits into from
May 19, 2020

Conversation

hug-dev
Copy link
Member

@hug-dev hug-dev commented May 19, 2020

Also implements conversions between FFI types and Rust native types.

That allows to only have Error in the Err arm of the Result.

Signed-off-by: Hugues de Valon <[email protected]>
@hug-dev hug-dev added the enhancement New feature or request label May 19, 2020
@hug-dev hug-dev self-assigned this May 19, 2020
Comment on lines +22 to +30
impl Status {
/// Convert the Status into a Result returning the empty tuple
pub fn to_result(self) -> Result<()> {
match self {
Status::Success => Ok(()),
Status::Error(error) => Err(error),
}
}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not implementing From<Status> for Result?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will add it as well! I am keeping both as in some contexts when the compiler can not infer the type it might be more convenient to use ...to_result() rather than Result<()>::from(...)

@hug-dev hug-dev merged commit 1740969 into parallaxsecond:master May 19, 2020
@hug-dev hug-dev deleted the status-codes-split branch May 19, 2020 14:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants