Hi,
I am having some trouble with crate/modules doing a little test with an external crate (snowflake).
This is the tree of my little project:
├── Cargo.lock
├── Cargo.toml
└── src
├── lib.rs
└── player
├── mod.rs
└── player_test.rs
And in the Cargo.toml I have inserted this row:
[dependencies]
snowflake = "*"
The code in lib.rs
is just:
mod player;
While in mod.rs
I wrote this little code:
extern crate snowflake;
use snowflake::ProcessUniqueId;
#[cfg(test)]
mod player_test;
/// Represent a player that can join a game.
struct Player {
/// Player ID, it must be unique for each player.
pub id: ProcessUniqueId,
}
impl Player {
fn new() -> Player {
let new_id = ProcessUniqueId::new();
Player{ id: new_id }
}
}
And player_test.rs
is empty for the moment.
So, if I try to compile with cargo build
I get this error:
src/player/mod.rs:3:5: 3:14 error: unresolved import `snowflake::ProcessUniqueId`. Did you mean `self::snowflake`?
src/player/mod.rs:3 use snowflake::ProcessUniqueId;
^~~~~~~~~
Furthermore there is another strange thing: if I change my code removing the use
clause and use the absolute path for the snowflake module I don't get any errors.
I cannot understand the reason.
Thank you.