noritada / grib-rs

GRIB format parser for Rust
Apache License 2.0
57 stars 9 forks source link

Examples do not build with crate version from crates.io #10

Closed Quba1 closed 2 years ago

Quba1 commented 3 years ago

Simple Description on the Bug

Copying and pasting list_surfaces.rs example into main.rs of a new binary crate and adding grib = "0.3.0" as a dependency into Cargo.toml results in build errors.

Steps to Reproduce

  1. Create a new bin crate with cargo new
  2. Copy paste list_surfaces.rs from examples into main.rs
  3. Add grib = "0.3.0" as a dependency into Cargo.toml
  4. Build errors occur

Expected Behavior

No build errors. Example should just successfully compile and run.

Actual Behavior

Build errors:

error[E0277]: the trait bound `GribError: std::error::Error` is not satisfied
   --> src/main.rs:31:85
    |
31  |     let grib2 = Grib2::<SeekableGrib2Reader<BufReader<File>>>::read_with_seekable(f)?;
    |                                                                                     ^ the trait `std::error::Error` is not implemented for `GribError`
    |
    = note: required because of the requirements on the impl of `From<GribError>` for `Box<dyn std::error::Error>`
    = note: required because of the requirements on the impl of `FromResidual<Result<Infallible, GribError>>` for `Result<(), Box<dyn std::error::Error>>`
note: required by `from_residual`
   --> /home/quba/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ops/try_trait.rs:339:5
    |
339 |     fn from_residual(residual: R) -> Self;
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error[E0599]: no method named `iter` found for struct `Grib2` in the current scope
  --> src/main.rs:34:29
   |
34 |     for submessage in grib2.iter() {
   |                             ^^^^ method not found in `Grib2<SeekableGrib2Reader<BufReader<File>>>`

Some errors have detailed explanations: E0277, E0599.
For more information about an error, try `rustc --explain E0277`.

Additional Context

The examples build correctly when the latest crate version from the repo is linked (`git clone --recurse-submodules -j8 https://github.com/noritada/grib-rs.git and link the crate locally). So the example is working just okay, and the issue is with the outdated version of the crate published on crates.io

Thus, the solution is simply updating the crate on crates.io (see issue #9).

noritada commented 3 years ago

Yes, I should have mentioned the required crate versions for the code.

noritada commented 2 years ago

@Quba1 Version 0.4.0 has now been released. Thank you for waiting.

I think this issue can be safely closed now. If you think the problem persists, please reopen the issue.