4 ms·
> There is a 1 to 1 relationship between cargo crate names and what gets used in the rust file. With pip your pypi package moo can include Python package foo, o
by LegionMammal978 4y ago
> There is a 1 to 1 relationship between cargo crate names and what gets used in the rust file. With pip your pypi package moo can include Python package foo, or whatever else it likes.
This is false: by default, the crate name (i.e., the name of the lib target) will be the package name with hyphens replaced by underscores, but it can be overridden to any other name [0].
[0] https://doc.rust-lang.org/cargo/reference/cargo-targets.html#the-name-field https://doc.rust-lang.org/cargo/reference/cargo-targets.html...
- pie_flavor 4y agoThat's still 1 to 1.
- LegionMammal978 4y agoNo, multiple packages can (and do) declare the same crate name. For instance, both the "md5" package [0] and "md-5" package [1] declare the "md5" crate. You can even add both of them as a dependency at the same time: you'll only get a compile error when you try to refer to "md5" from the code. So a Cargo package may declare at most one crate name, but this name is not unique. [0] https://crates.io/crates/md5 https://crates.io/crates/md5 [1] https://crates.io/crates/md-5 https://crates.io/crates/md-5
- pie_flavor 4y agoI suppose, but one can also creatively define 'what gets used in the rust file'. If you somehow need to interface with both of those packages, you can say `md_5 = { package = "md-5" }`, and now in your code it will be renamed `md_5`.