My rust cargo examples folder can't use the cargo project

Here's my Cargo.toml:

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

Here's what I'm doing in examples/http_smol_tcp_tun_example.rs:

use smoltcp_plus::virtual_tun::smol_stack::SmolStack;

When I run cargo build --examples, I get:

  --> examples/http_smol_tcp_tun_example.rs:19:5
   |
19 | use smoltcp_plus::virtual_tun::smol_stack::SmolStack;
   |     ^^^^^^^^^^^^ use of undeclared type or module `smoltcp_plus`

I have both main.rs and lib.rs in src, they export

pub mod virtual_tun;
pub use virtual_tun::VirtualTunInterface;

I don't get why I can't use the package smoltcp_plus as it's the cargo package name

Direct dependencies of tests/ or examples/ other than the current crate should be declared under the [dev-dependencies] section of the Cargo.toml.

but the dependency is the crate itself. I even have another project for which I can simply do use my_crate_name in examples

Is there an edition = "2018" entry in there?

yes

[package]
name = "smoltcp_plus"
version = "0.1.0"
authors = ["lz me@lucaszanella.com"]
edition = "2018"

I did some test and this setup works.

Cargo.toml

[package]
name = "smoltcp_plus"
version = "0.1.0"
authors = ["lz me@lucaszanella.com"]
edition = "2018"

src/lib.rs

pub const FOO: &str = "foo";

examples/http_smol_tcp_tun_examples.rs

fn main() {
    println!("{}", smoltcp_plus::FOO);
}

Is there a [lib] section too? Can you paste the whole Cargo.toml?

here's lib.rs:

pub mod virtual_tun;
pub use virtual_tun::VirtualTunInterface;

#[cfg(test)]
mod tests {
    #[test]
    fn it_works() {
        assert_eq!(2 + 2, 4);
    }
}

Here's the whole Cargo.toml:

[package]
name = "smoltcp_plus"
version = "0.1.0"
authors = ["lz <me@lucaszanella.com>"]
edition = "2018"

[dependencies]
log = { version = "0.4.4", default-features = false, optional = true }
libc = { version = "0.2.18", optional = true }
rand = { version = "0.3" }
#smoltcp = {git = "https://github.com/lucaszanella/smoltcp/", branch="ip-interface-alt-managed"}
smoltcp = { path = "./smoltcp" }
#managed = { git = "https://github.com/smoltcp-rs/rust-managed", features = ["map"] }

[dev-dependencies]
env_logger = "0.5"
getopts = "0.2"
rand = "0.3"
url = "1.0"
log = "0.4.4"

#[dependencies.smoltcp]
#git = "https://github.com/lucaszanella/smoltcp/"
#rev = "8f9102a3ff6af18d8161f2d69102bffa1aebe6ba"
#features = ["std", "phy-tun_interface", "proto-ipv4", "proto-ipv6", "socket-tcp"]

[lib]
crate-type=["cdylib", "staticlib"]

Does it matter that this project is inside another cargo project? The other project which is also inside works fine

You'll need to build your library as an rlib to use it from other Rust files:

[lib]
crate-type=["cdylib", "staticlib", "rlib"]