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

Best practice to handle Result/Option right now? #114

Open
stevefan1999-personal opened this issue May 24, 2022 · 1 comment
Open

Best practice to handle Result/Option right now? #114

stevefan1999-personal opened this issue May 24, 2022 · 1 comment
Assignees
Labels
K-feature Kind: proposed new code to implement new behaviour

Comments

@stevefan1999-personal
Copy link
Contributor

So I was thinking to build my own enum with ReprC using arbitrary enum discriminant but it seems like this isn't supported either. What should be replaced to work with 1. the Result type for error reporting? (while Option type are typically converted to T*)

@danielhenrymantilla danielhenrymantilla self-assigned this Jun 8, 2022
@danielhenrymantilla danielhenrymantilla added the K-feature Kind: proposed new code to implement new behaviour label Jun 8, 2022
@danielhenrymantilla
Copy link
Collaborator

I suspect we'll soon start supporting these (say, in a month or two), once the main revamp & cleanup of safer-ffi is done.

Until then, while not pretty, I guess you could try to setup something along the lines of:

#[derive_ReprC]
struct CResult<T : ReprC, Err: ReprC> {
    ok: Option<repr_c::Box<T>>,
    err: Option<repr_c::Box<Err>>,
}

else you could try to use an Error out parameter, as shown in: #113


Also, feel free to follow the more general Result-handdling discussion over #44 🙂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
K-feature Kind: proposed new code to implement new behaviour
Projects
None yet
Development

No branches or pull requests

2 participants