1

This is my Rust project structure:

zlmediakit_rust/examples
zlmediakit_rust/src
zlmediakit_rust/src/interface/lots_of_files_and_mod_rs
zlmediakit_rust/src/zl_media/lots_of_files_and_mod_rs
zlmediakit_rust/src/main.rs
zlmediakit_rust/Cargo.toml

In Cargo.toml:

[package]
name = "zlmediakit_rust"
version = "0.1.0"

In main.rs I have:

use zlmediakit_rust::zl_media;

fn main() {
    println!("hello world");
}

but it says it can't find any zlmediakit_rust. Also tried adding an example that uses zlmediakit_rust or declares it as an extern crate, won't work.

What am I doing wrong?

John Kugelman
  • 349,597
  • 67
  • 533
  • 578
Guerlando OCs
  • 1,886
  • 9
  • 61
  • 150
  • 1
    `mod zl_media; use crate::zl_media` – Shepmaster Oct 26 '20 at 19:24
  • @Shepmaster and what about for examples? – Guerlando OCs Oct 26 '20 at 19:34
  • 1
    @GuerlandoOCs in that case you `use zlmediakit_rust::zl_media`, as long as the `mod zl_media` in `main.rs` is a `pub mod zl_media`. – Optimistic Peach Oct 26 '20 at 19:43
  • @OptimisticPeach it isn't working on my case. `pub mod zl_media; pub mod interface;` in `main.rs`. Anything more needed? – Guerlando OCs Oct 26 '20 at 21:20
  • @OptimisticPeach for me what worked was to put them in lib.rs and use `use zlmediakit_rust::zl_media::zl_media::ZLMedia;` – Guerlando OCs Oct 26 '20 at 21:51
  • @GuerlandoOCs if you've got something along the lines of `use crate_name::module::module::whatever`, then that's pointing to you declaring another mod inside of the new file. `zl_media.rs` should contain the contents of the module; `pub mod zl_media` in `main.rs` already declares a new module. (IE, **do not** surround the contents of `zl_media.rs` with `mod zl_media { /** **/ }`) – Optimistic Peach Oct 27 '20 at 17:45

0 Answers0