Cargo.toml dependency syntax question - libpnet

I was told that:

[dependencies]
pnet = "0.21.0"

Is identical to specifying:

[depenencies]

[dependencies.pnet]
version = "0.21.0"

However, this does not seem to be the case because with libpnet, when I specify the former, there are build errors about code missing.

However, there was a situation in which I did use:

[dependencies.pnet]
version = "0.21.0"

And I tried to use a symbol from pnet_datalink, and that also threw build errors until I also did this:

[dependencies]
pnet_datalink = "whatever_version"
[dependencies.pnet]
version = "0.21.0"

Then, I was able to run the program fine. At this point, I am thoroughly confused and have no idea what's really going on here. Additionally, it doesn't help that the crate is supposedly called libpnet but is called pnet on crates.io . Finally, I don't understand the relationship here between pnet and pnet_datalink for example... They seem to be separate crates but also the same crate??? Can someone with more experience clear this up please?

1 Like