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

the trait IntoValue is not implemented for Result<(), String> #114

Open
mimoo opened this issue Feb 26, 2023 · 3 comments
Open

the trait IntoValue is not implemented for Result<(), String> #114

mimoo opened this issue Feb 26, 2023 · 3 comments

Comments

@mimoo
Copy link
Contributor

mimoo commented Feb 26, 2023

error[E0277]: the trait bound `Result<(), String>: IntoValue` is not satisfied
  --> src/lib.rs:46:1
   |
46 | #[ocaml::func]
   | ^^^^^^^^^^^^^^ the trait `IntoValue` is not implemented for `Result<(), String>`
   |
   = help: the following other types implement trait `IntoValue`:
             Result<T, E>
             Result<T, ocaml::Error>
   = note: this error originates in the attribute macro `ocaml::func` (in Nightly builds, run with -Z macro-backtrace for more info)

I would have thought, following the doc, that any Result<T, E> would be converted to (t, e) result in OCaml as long as both T and E implemented the needed types, but using String as error doesn't seem to work.

in the Rust doc I see that IntoValue is only implemented if E = ocaml::Error:

Screenshot 2023-02-26 at 8 40 40 AM

I also can't find tests on that, I'm guessing the book is wrong?

EDIT: I see an implementation of ToValue which is weird as I thought ToValue was not a thing anymore... in any case I can't implement IntoValue on Result myself due to the orphan rule

@zshipko
Copy link
Owner

zshipko commented Feb 26, 2023

The book documents the 1.0.0-beta release, which switches back to ToValue and implements ToValue for Result - the latest non-beta doesn't.

@mimoo
Copy link
Contributor Author

mimoo commented Feb 26, 2023

oh I see :)) time for a non-beta release :D ?

@zshipko
Copy link
Owner

zshipko commented Feb 26, 2023

haha yes, the goal is to release 1.0.0 when the ocaml5 branch is merged. that should be relatively soon!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants