如果rust模块功能是私有的,该怎么办



我想在我的rust项目中使用qoi,并尝试了这个模块https://github.com/ChevyRay/qoi_rs问题是,当我写这篇文章时:

use qoi::Pixel;

错误:

error[E0432]: unresolved import `qoi::Pixel`
--> src/create_images.rs:4:5
|
4 | use qoi::Pixel;
|     ^^^^^-----
|     |    |
|     |    help: a similar name exists in the module: `pixel`
|     no `Pixel` in the root
For more information about this error, try `rustc --explain E0432`.
error: could not compile `Thing_in_rust` due to previous error

所以我尝试了pixel:

use qoi::pixel;

这个错误信息弹出

error[E0603]: module `pixel` is private
--> src/create_images.rs:4:10
|
4  | use qoi::pixel;
|          ^^^^^ private module
|

我是个新手,但看看github代码https://github.com/ChevyRay/qoi_rs/blob/main/src/pixel.rs,我觉得它是公开的
cargo.toml:

[dependencies]
qoi = "0.4.0"

您链接的板条箱似乎没有在crates.io上发布,尽管那里有很多qoi板条箱。

所以你的选择是:

  • 使用crates.io上发布的其中一个板条箱
  • 使用直接git依赖项而不是货物依赖项
  • 第二种方法的一个变体是使用路径依赖性来提供机箱,以防您需要更新它

最新更新