technocreatives/core2

bare_io::error::Error instead of bare_io::Error

hunhoffe opened this issue · 2 comments

Hello!

I'm having some issues porting a std-using library to no-std using core2/bare-io. I am getting some compiler complaints when I attempt to use my now-ported library:

              |    | expected struct `bare_io::error::Error`, found struct `bare_io::Error`
              |    | help: change the output type to match the trait: `Result<(), bare_io::error::Error>`
              |    |

The library code I have ported to use core2 is here. It builds correctly and passes the built-in library tests/benchmarks in both std and no-std mode.

I don't think I did anything fancy when porting to use bare-io.... I just replaced

    std::io::Write,
    std::io::Result as IOResult,

with

    bare_io::Write,
    bare_io::Result as IOResult,

If this is my error and I am using the library incorrectly, I apologize but either way I would welcome any guidance on how to fix this issue. I believe the error originates when an error is attempted to be handled with a ?.... but I believe this sort of error chaining is one of the main purposes for core2. I'd be happy to show the full error trace if there is interest. Thank you for your time!

Your Cargo.toml includes bare-io, which predates this crate and only included equivalents to std::io. Change to using core2 = "0.3" and use core2::io for IO-related things, such as IO errors. core2::error::Error is equivalent to std's Error type.

Thank you for the help! Sorry it was such a basic issue.